summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradam <56338480+adastx@users.noreply.github.com>2022-10-09 19:04:36 +0200
committeradam <56338480+adastx@users.noreply.github.com>2022-10-09 19:04:36 +0200
commit3292d6b30ede78a4429a663bee0f3c78c66d52f7 (patch)
tree2005aed257bef1c2323647f313567742a39f0650
parentc725dbf2d99f3557e660c20e74452fb2864fdc53 (diff)
script: 'scheme' for switching between light/dark modes
-rw-r--r--.config/scheme/fzf-color1
-rw-r--r--.config/scheme/gtk-theme-dark1
-rw-r--r--.config/scheme/gtk-theme-light1
-rw-r--r--.config/scheme/qt-theme-dark1
-rw-r--r--.config/scheme/qt-theme-light1
-rw-r--r--.config/scheme/term-theme-dark1
-rw-r--r--.config/scheme/term-theme-light1
-rwxr-xr-x.local/bin/scheme58
8 files changed, 65 insertions, 0 deletions
diff --git a/.config/scheme/fzf-color b/.config/scheme/fzf-color
new file mode 100644
index 0000000..df9f911
--- /dev/null
+++ b/.config/scheme/fzf-color
@@ -0,0 +1 @@
+dark \ No newline at end of file
diff --git a/.config/scheme/gtk-theme-dark b/.config/scheme/gtk-theme-dark
new file mode 100644
index 0000000..f17ba0e
--- /dev/null
+++ b/.config/scheme/gtk-theme-dark
@@ -0,0 +1 @@
+Arc-Dark
diff --git a/.config/scheme/gtk-theme-light b/.config/scheme/gtk-theme-light
new file mode 100644
index 0000000..b03117f
--- /dev/null
+++ b/.config/scheme/gtk-theme-light
@@ -0,0 +1 @@
+Arc
diff --git a/.config/scheme/qt-theme-dark b/.config/scheme/qt-theme-dark
new file mode 100644
index 0000000..a04a7a1
--- /dev/null
+++ b/.config/scheme/qt-theme-dark
@@ -0,0 +1 @@
+KvArcDark
diff --git a/.config/scheme/qt-theme-light b/.config/scheme/qt-theme-light
new file mode 100644
index 0000000..244572f
--- /dev/null
+++ b/.config/scheme/qt-theme-light
@@ -0,0 +1 @@
+KvArc
diff --git a/.config/scheme/term-theme-dark b/.config/scheme/term-theme-dark
new file mode 100644
index 0000000..61ba56d
--- /dev/null
+++ b/.config/scheme/term-theme-dark
@@ -0,0 +1 @@
+*dark
diff --git a/.config/scheme/term-theme-light b/.config/scheme/term-theme-light
new file mode 100644
index 0000000..be05131
--- /dev/null
+++ b/.config/scheme/term-theme-light
@@ -0,0 +1 @@
+*light
diff --git a/.local/bin/scheme b/.local/bin/scheme
new file mode 100755
index 0000000..4708316
--- /dev/null
+++ b/.local/bin/scheme
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+main () {
+ case "$1" in
+ d|dark)
+ set_scheme dark ;;
+ l|light)
+ set_scheme light ;;
+ *)
+ echo "usage: scheme [dark|light]" ;;
+ esac
+}
+
+set_scheme () {
+ if [[ $1 == "dark" ]]; then
+ GTK_THEME=$(<$XDG_CONFIG_HOME/scheme/gtk-theme-dark)
+ QT_THEME=$(<$XDG_CONFIG_HOME/scheme/qt-theme-dark)
+ TERM_THEME=$(<$XDG_CONFIG_HOME/scheme/term-theme-dark)
+ FZF_COLOR=dark
+ PREFER_DARK="true"
+ PREFER_DARK_STR="prefer-dark"
+ else
+ GTK_THEME=$(<$XDG_CONFIG_HOME/scheme/gtk-theme-light)
+ QT_THEME=$(<$XDG_CONFIG_HOME/scheme/qt-theme-light)
+ TERM_THEME=$(<$XDG_CONFIG_HOME/scheme/term-theme-light)
+ FZF_COLOR=light
+ PREFER_DARK="false"
+ PREFER_DARK_STR="prefer-light"
+ fi
+
+ sed -ir "s|^colors: .*$|colors: $TERM_THEME|" $XDG_CONFIG_HOME/alacritty/alacritty.yml
+
+ sed -ir "s|theme=.*$|theme=$QT_THEME|" \
+ $XDG_CONFIG_HOME/Kvantum/kvantum.kvconfig
+
+ sed -ir "s|gtk-theme-name=.*$|gtk-theme-name=\"$GTK_THEME\"|" \
+ $XDG_CONFIG_HOME/gtk-2.0/gtkrc
+
+ sed -ir \
+ -e "s|gtk-theme-name=.*$|gtk-theme-name=$GTK_THEME|" \
+ -e "s|gtk-application-prefer-dark-theme=.*$|gtk-application-prefer-dark-theme=$PREFER_DARK|" \
+ $XDG_CONFIG_HOME/gtk-3.0/settings.ini \
+ $XDG_CONFIG_HOME/gtk-4.0/settings.ini
+
+ gsettings set org.gnome.desktop.interface color-scheme $PREFER_DARK_STR
+ gsettings set org.gnome.desktop.interface gtk-theme $GTK_THEME
+ gsettings set org.gnome.desktop.wm.preferences theme $GTK_THEME
+
+ echo -n $FZF_COLOR > $XDG_CONFIG_HOME/scheme/fzf-color
+
+ # todo:
+ # - send nvim clients theme update
+ # - delta ?
+ # - restart firefox ?
+ # - restart thunderbird ?
+}
+
+main "$@"