Closed katashisano closed 7 months ago
This can be easily implemented as a script:
#!/bin/sh
# This script cycles the temperature between temp1 and temp2 on each execution
temp1="6500"
temp2="5000"
dbus="rs.wl-gammarelay / rs.wl.gammarelay"
if [ "$(busctl --user get-property $dbus Temperature)" = "q $temp1" ]; then
busctl --user set-property $dbus Temperature q $temp2
else
busctl --user set-property $dbus Temperature q $temp1
fi
This can be easily implemented as a script:
#!/bin/sh # This script cycles the temperature between temp1 and temp2 on each execution temp1="6500" temp2="5000" dbus="rs.wl-gammarelay / rs.wl.gammarelay" if [ "$(busctl --user get-property $dbus Temperature)" = "q $temp1" ]; then busctl --user set-property $dbus Temperature q $temp2 else busctl --user set-property $dbus Temperature q $temp1 fi
Very useful, thanks!
EDIT: I made a "better" version which does exactly what I want, in case anyone wants to use it:
#!/bin/sh
dbus="rs.wl-gammarelay / rs.wl.gammarelay"
if [ "$1" = "--update-val" ]; then
[ -z $2 ] && echo Expected inc/dec value. && exit
busctl --user -- call rs.wl-gammarelay / rs.wl.gammarelay UpdateTemperature n $2
echo $(busctl --user get-property $dbus Temperature) > /home/USER/.script_stuff/lastmontemp
exit
fi
catresult="$(cat /home/USER/.script_stuff/lastmontemp 2>/dev/null)"
if [ -z "$catresult" ]; then
lasttemp="q 6500"
else
lasttemp="$catresult"
fi
echo "$catresult"
if [ "$(busctl --user get-property $dbus Temperature)" = "q 6500" ]; then
busctl --user set-property $dbus Temperature $lasttemp
else
busctl --user set-property $dbus Temperature q 6500
fi
This would be a waybar module (purpose of this issue) for it:
"custom/nightlight": {
"format": "{}",
"exec": "wl-gammarelay-rs watch {t}",
"on-scroll-up": "nightlight --update-val +100",
"on-scroll-down": "nightlight --update-val -100",
"on-click": "nightlight"
}
Great :)
As the title says, I'd like to see a toggle "command", it would be a really cool detail being able to click the waybar module and make it toggle on/off, keeping the temperature it had when it was toggled off, not just setting it always to a fixed value.
I would like to contribute a bit and do it myself, but I don't know rust, nor have I used Dbus ever before in a project.