Add option to execute user script on mode change
Let the user execute custom commands on mode change, for example change wallpaper, terminal theme, etc.
This commit is contained in:
parent
4c6ae90598
commit
6bd5b9b8fd
2 changed files with 45 additions and 0 deletions
37
README.adoc
37
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 <property> --set </path/to/image.jpg>
|
||||
```
|
||||
|
||||
==== 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
|
||||
|
|
|
|||
|
|
@ -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 "<txt>$TEXT</txt>"
|
||||
echo "<txtclick>$0 toggle</txtclick>"
|
||||
echo "<tool>
|
||||
|
|
|
|||
Loading…
Reference in a new issue