i3lock-color
i3lock-color copied to clipboard
Support displaying custom dynamic text
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 |
|---|---|
![]() |
![]() |
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)
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.
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.
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!
Glad I could help!
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
I have tried it and it did not work as expected. Great, thanks for the link!

