i3lock-color icon indicating copy to clipboard operation
i3lock-color copied to clipboard

Support displaying custom dynamic text

Open r4t1o opened this issue 4 years ago • 6 comments

This issue is a....

[ ] Bug
[x] Other kind of issue (Please describe in detail)

Current Behavior

Hello, I have written a small script to display the current playing music through mpc. The current way I'm displaying the music is by adding that to the greeter text. However, with this method when the music changes and the lock is still active it does not change the music text.

Lock executed when music is playing Lock executed when music is paused
prev prev

Expected Behavior

Code

#!/bin/sh
mcurrent=$(mpc $current | head -n 1)
mtime=$(mpc $status | grep "%)" | awk '{ print $3 }')
mstatus=$(mpc $status | grep "%)" | sed 's/[][]//g' | awk '{ print $1 }')

if [ "$mstatus" = "playing" ]; then
    echo " ${mcurrent} ${mtime}"
elif [ "$mstatus" = "paused" ]; then
    echo " PAUSED: $mcurrent"
else»
    echo "No music playing"
fi

This script is placed in /usr/bin and When this script is run through greeter text like this ( --greeter-text="$(musicstat)" ) it should display the music and the current music and also when the music changes the greeter text should change as well.

When this script is run through, watch -n1 musicstat it display the current music time as well as changing what song and state it currently is I would like to achive that with greeter text or any other means possible.

My question is this something I can do without modifying the sourcecode?

Reproduction Instructions

Environment

Output of i3lock --version:

i3lock version: version 2.13.c.4

Where'd you get i3lock-color from?

[x] AUR package (which one?)
[ ] Built from source yourself
[ ] Other (Please describe in detail)

r4t1o avatar Aug 20 '21 23:08 r4t1o

This won't work as expected because i3lock is an static program. All the params you pass to i3lock will remain the same through all its lifetime.

Currently, i3lock does not have any kind of "API" to communicate to it, neither a way to load data dinamically.

A simple solution to this could be to add an option to run a script at intervals. The downside is that every change you make won't be instantaneous, and i3lock will make unnecessary executions that aren't needed.

Therefore, I think creating a kind of API would be great.

JezerM avatar Aug 21 '21 00:08 JezerM

You can always have a script to start a new instance of i3lock periodically, check that it's running, and terminate the original one. An API for showing custom things on a lock screen is too much IMO.

Raymo111 avatar Aug 21 '21 00:08 Raymo111

You can always have a script to start a new instance of i3lock periodically, check that it's running, and terminate the original one. An API for showing custom things on a lock screen is too much IMO.

I like this solution, thanks!

r4t1o avatar Aug 21 '21 00:08 r4t1o

Glad I could help!

Raymo111 avatar Aug 21 '21 01:08 Raymo111

Actually @r4t1o my solution won't work because the new instance won't be able to grab since the old one already grabs it.

Edit: We're discussing a solution to this on Discord, here's a link to the server if you wanna join us: https://discord.gg/FzVPghyDt2

Raymo111 avatar Aug 21 '21 03:08 Raymo111

I have tried it and it did not work as expected. Great, thanks for the link!

r4t1o avatar Aug 21 '21 12:08 r4t1o