add screen brightness script for Gnome

This commit is contained in:
Christian Ulrich 2021-03-17 12:56:33 +01:00
parent c14b3c5ff1
commit d720c7cdae
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 28 additions and 0 deletions

28
gnome/brightness.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
function usage {
echo "usage: $0 up|down"
}
function main {
if [ "$#" -ne 1 ]; then
usage
exit 1
fi
local method=""
if [ "$1" == "up" ]; then
method="org.gnome.SettingsDaemon.Power.Screen.StepUp"
elif [ "$1" == "down" ]; then
method="org.gnome.SettingsDaemon.Power.Screen.StepDown"
else
usage
exit 1
fi
dbus_result=$(gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path /org/gnome/SettingsDaemon/Power --method "$method" | tr -d "(,)")
level=$(echo "$dbus_result" | awk '{ printf "%f", $1 / 100 }')
connector=$(echo "$dbus_result" | awk '{ print $2 }')
gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.ShowOSD "{'icon': <'display-brightness-symbolic'>, 'level': <$level>, 'connector': <$connector>}"
}
main "$@"