diff options
author | mynacol | 2021-02-05 21:15:22 +0100 |
---|---|---|
committer | mynacol | 2021-02-05 21:42:28 +0100 |
commit | ccde96687b6c833fa45931812fdb8040c6737bf2 (patch) | |
tree | d01e304e6efc08fd2ca8b3ffecccb49d44fa122c | |
download | aur-ccde96687b6c833fa45931812fdb8040c6737bf2.tar.gz |
First commit
-rw-r--r-- | .SRCINFO | 25 | ||||
-rw-r--r-- | PKGBUILD | 32 | ||||
-rwxr-xr-x | dark-theme.sh | 76 |
3 files changed, 133 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..79e9c4b64e5c --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,25 @@ +pkgbase = theme-switcher-git + pkgdesc = Switching between light and dark themes made easy + pkgver = r. + pkgrel = 1 + url = https://aur.archlinux.org/packages/theme-switcher-git/ + arch = any + license = GPL + makedepends = git + depends = bash + depends = glib2 + depends = sed + depends = jq + depends = moreutils + optdepends = xfce4-settings: for GTK switching under Xorg + optdepends = qt5ct: for Qt5 switching. Additional setup required. + optdepends = adwaita-qt: Qt5 theme + optdepends = feh: for setting wallpaper under Xorg + optdepends = sway: for setting wallpaper in sway + provides = theme-switcher + conflicts = theme-switcher + source = theme-switcher::git+https://aur.archlinux.org/theme-switcher-git.git + sha256sums = SKIP + +pkgname = theme-switcher-git + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..4aa4d5892c82 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,32 @@ +# Maintainer: mynacol <paul àt dismail _ de> + +pkgname=theme-switcher-git +pkgver=r. +pkgrel=1 +pkgdesc="Switching between light and dark themes made easy" +arch=('any') +url="https://aur.archlinux.org/packages/${pkgname}/" +license=('GPL') +depends=('bash' 'glib2' 'sed' 'jq' 'moreutils') +optdepends=( + 'xfce4-settings: for GTK switching under Xorg' + 'qt5ct: for Qt5 switching. Additional setup required.' + 'adwaita-qt: Qt5 theme' + 'feh: for setting wallpaper under Xorg' + 'sway: for setting wallpaper in sway' +) +makedepends=('git') +provides=("${pkgname%-git}") +conflicts=("${pkgname%-git}") +source=("${pkgname%-git}::git+https://aur.archlinux.org/${pkgname}.git") +sha256sums=('SKIP') + +pkgver() { + cd "$srcdir/${pkgname%-git}" + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" +} + +package() { + cd "$srcdir/${pkgname%-git}" + install -Dm755 dark-mode.sh "$pkgdir/usr/bin/${pkgname%-git}" +} diff --git a/dark-theme.sh b/dark-theme.sh new file mode 100755 index 000000000000..8a4486cc5799 --- /dev/null +++ b/dark-theme.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash + +# Inspiration: https://www.reddit.com/r/unixporn/comments/f1oied/awesome_global_nightday_switch_for_gtk_vim/ + +# Requirements: +# glib2: for gsettings for GTK switching under Wayland +# xfce4-settings: for xfsettings for GTK switching under Xorg +# qt5ct: for Qt5 switching +# adwaita-qt: as Qt5 theme +# sed: for switching multiple things by editing config files +# jq: for switching code by editing JSON +# moreutils: providing sponge for in-place editing code config file +# feh: for setting wallpaper under Xorg +# sway: for setting wallpaper in sway + +# enable "strict mode" +set -euo pipefail +IFS=$'\n\t' + +CURRENT=$(gsettings get org.gnome.desktop.interface gtk-theme) + +if [[ $1 == "dark" ]]; then + UI_THEME_GTK="Adwaita-dark" + UI_THEME_QT="Adwaita-Dark" + UI_VSCODE="Default Dark+" + UI_ALACRITTY="dark" + BG_X11="-B black ${HOME}/.wallpaper/light.png" + BG_SWAY="--color #000000 --image ${HOME}/.wallpaper/light.png" +elif [[ $1 == "light" ]]; then + UI_THEME_GTK="Adwaita" + UI_THEME_QT="Adwaita" + UI_VSCODE="Default Light+" + UI_ALACRITTY="light" + BG_X11="-B white ${HOME}/.wallpaper/dark.png" + BG_SWAY="--color #ffffff --image ${HOME}/.wallpaper/dark.png" +elif [[ $1 == "toggle" ]]; then + [[ "$CURRENT" == *"dark"* ]] && exec $0 light || exec $0 dark +elif [[ $1 == "reapply" ]]; then + [[ "$CURRENT" == *"dark"* ]] && exec $0 dark || exec $0 light +else + exit 1 +fi + + +# set GTK theme +if [[ "$XDG_SESSION_TYPE" == "x11" ]]; then + # Start xfsettingsd - alreday running xfsettingd ignores this + xfsettingsd --daemon + # set GTK theme xia xsettings + xfconf-query -c xsettings -p /Net/ThemeName -s "$UI_THEME_GTK" + #xfconf-query -c xsettings -p /Net/IconThemeName -s "$UI_ICONS" +else + # set GTK theme via gsettings + gsettings set org.gnome.desktop.interface gtk-theme "$UI_THEME_GTK" +fi + +# set Qt theme +sed -i -E "s@^style=.*@style=${UI_THEME_QT}@" ~/.config/qt5ct/qt5ct.conf + +# set alacritty theme +sed -i -E "s/^colors: \*.*$/colors: *$UI_ALACRITTY/" ~/.config/alacritty/alacritty.yml + +# set vscode theme +f="$HOME/.config/Code - OSS/User/settings.json" +jq ".[\"workbench.colorTheme\"]=\"${UI_VSCODE}\"" "$f" | sponge "$f" + +# set background +if [[ "$XDG_SESSION_TYPE" == "x11" ]]; then + feh --no-fehbg --bg-center ${BG_X11} +elif [[ -n "$SWAYSOCK" ]]; then + killall -q swaybg + swaybg --mode center "$BG_SWAY" & +else + echo "No supported window manager." + echo "Not setting background" +fi |