summarylogtreecommitdiffstats
path: root/dark-theme.sh
blob: 92bf957d96346f0e4784aa50e15453daa06f439e (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
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env sh

# enable "strict mode"
set -eu

CURRENT=$(gsettings get org.gnome.desktop.interface gtk-theme)

case $1 in
    dark | night)
      for f in "$HOME/.local/share/dark-mode.d/"*; do
        if [ -x "$f" ]; then
            "$f" &
        fi
      done
    ;;
    light | day | daytime)
      for f in "$HOME/.local/share/light-mode.d/"*; do
        if [ -x "$f" ]; then
            "$f" &
        fi
      done
    ;;
    toggle | transition)
      if echo "$CURRENT" | grep -q "dark"; then
        exec $0 light
      else
        exec $0 dark
      fi
    ;;
    reapply)
      if echo "$CURRENT" | grep -q "dark"; then
        exec $0 dark
      else
        exec $0 light
      fi
    ;;
    none)
      # ignore this command
    ;;
    *)
      echo "Command $1 not valid."
      exit 1
esac

wait