Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support displaying custom dynamic text #234

Open
r4t1o opened this issue Aug 20, 2021 · 6 comments · May be fixed by #279
Open

Support displaying custom dynamic text #234

r4t1o opened this issue Aug 20, 2021 · 6 comments · May be fixed by #279

Comments

@r4t1o
Copy link

r4t1o commented Aug 20, 2021

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)
@JezerM
Copy link

JezerM commented Aug 21, 2021

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.

@Raymo111
Copy link
Owner

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.

@r4t1o
Copy link
Author

r4t1o commented Aug 21, 2021

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!

@Raymo111
Copy link
Owner

Glad I could help!

@Raymo111 Raymo111 reopened this Aug 21, 2021
@Raymo111
Copy link
Owner

Raymo111 commented Aug 21, 2021

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

@r4t1o
Copy link
Author

r4t1o commented Aug 21, 2021

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

@Raymo111 Raymo111 changed the title Greeter text display current music Support displaying custom dynamic text Aug 25, 2021
@JezerM JezerM mentioned this issue Aug 26, 2021
@mjkloeckner mjkloeckner linked a pull request May 23, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants