From d720c7cdaeccfa5427d2e249d563bcd03f3c256e Mon Sep 17 00:00:00 2001 From: Christian Ulrich Date: Wed, 17 Mar 2021 12:56:33 +0100 Subject: [PATCH] add screen brightness script for Gnome --- gnome/brightness.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 gnome/brightness.sh diff --git a/gnome/brightness.sh b/gnome/brightness.sh new file mode 100755 index 0000000..7cb17cc --- /dev/null +++ b/gnome/brightness.sh @@ -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 "$@"