blob: 69c7a1f4d33de95123f9a160c63d4d19ff7b5724 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/usr/bin/env sh
# Switch the COSMIC desktop between light and dark mode, and optionally the
# wallpaper with it: set SYSTEM_THEME_WALLPAPER_DARK and
# SYSTEM_THEME_WALLPAPER_LIGHT to image files, in the environment or in
# ~/.config/system-theme/config. Emacs's auto-dark follows the desktop's mode
# on its own. On another desktop, this is the file to rewrite.
CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}"
COSMIC="$CONFIG/cosmic"
# shellcheck source=/dev/null
[ -f "$CONFIG/system-theme/config" ] && . "$CONFIG/system-theme/config"
set_wallpaper() {
[ -n "$1" ] || return 0
wallpaper="$(realpath "$1")" || return 1
sed -i 's|^.*source: Path(".*"),$| source: Path("'"$wallpaper"'"),|' \
"$COSMIC/com.system76.CosmicBackground/v1/all"
}
case "$1" in
dark)
echo "true" > "$COSMIC/com.system76.CosmicTheme.Mode/v1/is_dark"
set_wallpaper "${SYSTEM_THEME_WALLPAPER_DARK:-}"
;;
light)
echo "false" > "$COSMIC/com.system76.CosmicTheme.Mode/v1/is_dark"
set_wallpaper "${SYSTEM_THEME_WALLPAPER_LIGHT:-}"
;;
*)
echo "usage: system-theme dark|light" >&2
exit 1
;;
esac
|