From 8794189bbf8bacf80987e088222f15c0060860d5 Mon Sep 17 00:00:00 2001 From: bimlas Date: Thu, 9 Apr 2020 11:32:12 +0200 Subject: [PATCH] Modify to use with Genmon XFCE panel plugin Genmon does not allow to pass arguments thus I need to hardcode sunrise and sunset values. https://docs.xfce.org/panel-plugins/xfce4-genmon-plugin --- xfce-night-mode.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/xfce-night-mode.sh b/xfce-night-mode.sh index decf67f..5dfd6d0 100755 --- a/xfce-night-mode.sh +++ b/xfce-night-mode.sh @@ -1,24 +1,25 @@ #!/bin/bash +TEXT='' +SUNRISE='8:00' +SUNSET='18:00' + function show_usage() { progname=`basename "$0"` - echo "$progname [night|day|toggle] (defaults to 'toggle')" - echo "$progname SUNRISE SUNSET (e.g. '8:00 18:00')" + echo "$progname [night|day|toggle]" + echo "Without parameters it will set dark theme from $SUNSET to $SUNRISE" } function parse_args() { case $# in 0) - echo 'toggle' + _get_mode_by_time ;; 1) echo "$1" ;; - 2) - _get_mode_by_time "$1" "$2" - ;; *) exit 1 esac @@ -27,10 +28,8 @@ function parse_args() function _get_mode_by_time() { now=`date +"%H%M"` - sunrise="${1/:/}" - sunset="${2/:/}" - if [ $now -ge $sunrise -a $now -le $sunset ]; then + if [ $now -ge "${SUNRISE/:/}" -a $now -le "${SUNSET/:/}" ]; then echo 'day' else echo 'night' @@ -41,7 +40,7 @@ function set_night_mode() { current_theme=`xfconf-query -c $2 -p $3` if ( _is_mode_already_set "$current_theme" "$1" ); then - exit 0 + return fi new_theme=`_set_$1 "$current_theme" 2> /dev/null` @@ -106,3 +105,7 @@ set_night_mode $mode xsettings /Net/IconThemeName # Window manager theme # set_night_mode $mode xfwm4 /general/theme + +echo "$TEXT" +echo "$0 toggle" +echo "Night mode: $SUNSET - $SUNRISE"