scripts/gnome/brightness.sh

29 lines
847 B
Bash
Executable File

#!/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 "$@"