diff --git a/README.adoc b/README.adoc index 110ce61..455550c 100644 --- a/README.adoc +++ b/README.adoc @@ -56,6 +56,43 @@ from the appropriate location: * Window manager theme ** `xfwm4/general/theme` +The specified `UserScript` will be executed when switching the mode, you can use +this for example to change the theme of the terminal, set desktop wallpaper, +etc. You can use the variable `XFCE_NIGHT_MODE` in your script if you want to +use the same script in both cases, for example: + +.... +#!/bin/bash +notify-send --icon "dialog-info" "Mode: $XFCE_NIGHT_MODE" +.... + +=== Example `UserScript` + +==== Change wallpaper + +First you have to find the property of the wallpaper (this could be different on +multi-monitor setup) by executing the command below then changing the wallpaper +in _Desktop_ setting. + +``` +xfconf-query --channel xfce4-desktop --monitor +``` + +You have to execute the command below to set up the wallpaper for this desktop. + +``` +xfconf-query --channel xfce4-desktop --property --set +``` + +==== Change panel dark mode + +You have to execute the command below to change the panel mode opposite to the +windows mode (light windows, dark panel). + +``` +xfconf-query --channel xfce4-panel --property /panels/dark-mode --set "$([ "$XFCE_NIGHT_MODE" = "day" ] && echo true || echo false)" +``` + === Switch at a time specified by antoher program For example, to use http://jonls.dk/redshift/[Redshift] or another program to diff --git a/xfce4-night-mode.sh b/xfce4-night-mode.sh index 250bb1c..6b6746d 100755 --- a/xfce4-night-mode.sh +++ b/xfce4-night-mode.sh @@ -105,6 +105,8 @@ CURSOR_LIGHT="$(get_config 'Light/CursorTheme' 'string' $(xfconf-query --channel CURSOR_DARK="$(get_config 'Dark/CursorTheme' 'string' $(xfconf-query --channel xsettings --property /Gtk/CursorThemeName))" WM_LIGHT="$(get_config 'Light/WindowManagerTheme' 'string' $(xfconf-query --channel xfwm4 --property /general/theme))" WM_DARK="$(get_config 'Dark/WindowManagerTheme' 'string' $(xfconf-query --channel xfwm4 --property /general/theme))" +USERSCRIPT_LIGHT="$(get_config 'Light/UserScript' 'string')" +USERSCRIPT_DARK="$(get_config 'Dark/UserScript' 'string')" mode="$(parse_args $@)" @@ -152,6 +154,12 @@ set_theme 'xfwm4' '/general/theme' "WM_$suffix" set_config 'active' 'string' "$mode" +# Execute user script to change wallpaper, terminal theme, etc. +userscript="USERSCRIPT_$suffix" +if [ ! -z "${!userscript}" ]; then + XFCE_NIGHT_MODE="$mode" eval "${!userscript}" 2>&1 > /dev/null +fi + echo "$TEXT" echo "$0 toggle" echo "