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

return-type custom class doesn't apply style #3234

Closed
dxwil opened this issue May 7, 2024 · 0 comments
Closed

return-type custom class doesn't apply style #3234

dxwil opened this issue May 7, 2024 · 0 comments

Comments

@dxwil
Copy link

dxwil commented May 7, 2024

Make sure not to make this mistake in your custom modules. Let's say this is your module:

"custom/battery": {
"exec": "~/.config/waybar/scripts/battery.sh",
"interval": 60,
"tooltip": false,
"signal": 7,
"return-type": "json"
},

This script will work:

#!/bin/bash
capacity=$(<"/sys/class/power_supply/macsmc-battery/capacity")
if [ "$(<"/sys/class/power_supply/macsmc-battery/status")" = "Charging" ]; then
unbuffer echo "{\"text\":\"$capacity%\",\"class\":\"charging\"}"
else
unbuffer echo "{\"text\":\"$capacity%\"}"
fi

This script will not work:

#!/bin/bash
capacity=$(<"/sys/class/power_supply/macsmc-battery/capacity")
unbuffer echo "{\"text\":\"$capacity%\"}"
if [ "$(<"/sys/class/power_supply/macsmc-battery/status")" = "Charging" ]; then
unbuffer echo "{\"text\":\"$capacity%\",\"class\":\"charging\"}"
fi

Always put the json with more variables to be displayed first, because otherwise it will be overshadowed by the other one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant