#!/bin/bash ################################################################################ # # gnome-toggle-night-light # Requires notify-send to be installed # ################################################################################ ################################################################################ # User configuration ################################################################################ title="Night Light" body_enabled="Night light has been enabled." body_disabled="Night light has been disabled." icon_enabled="night-light" icon_disabled="night-light-disabled" key="org.gnome.settings-daemon.plugins.color night-light-enabled" ################################################################################ # gnome-toggle code ################################################################################ value=$(gsettings get $key) notif_id_file_name=/tmp/tmp.$(echo $key | tr -d ' ').nid { prev_notif_id=$(<$notif_id_file_name); } 2> /dev/null replace_flag="" case $prev_notif_id in ''|*[!0-9]*) ;; *) replace_flag="--replace-id=$prev_notif_id" ;; esac if [[ $value == "true" ]]; then gsettings set $key false notify-send "$title Disabled" "$body_disabled" --icon $icon_disabled $replace_flag --transient --expire-time=0 --print-id > $notif_id_file_name else gsettings set $key true notify-send "$title Enabled" "$body_enabled" --icon $icon_enabled $replace_flag --transient --expire-time=0 --print-id > $notif_id_file_name fi