From 488dec64b403ae4aba65cad0e46b4d2767f0b2dd Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Thu, 27 Nov 2025 01:08:37 -0500 Subject: Automatic light/dark mode switching. What a pain. --- river/.gitignore | 1 + river/init | 38 +++++++++++++++++++++++++++----------- river/theme_helper | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 11 deletions(-) create mode 100755 river/theme_helper (limited to 'river') diff --git a/river/.gitignore b/river/.gitignore index 6275a75..f211f8c 100644 --- a/river/.gitignore +++ b/river/.gitignore @@ -1 +1,2 @@ padding_conf +theme_conf diff --git a/river/init b/river/init index 9bdd360..848403e 100755 --- a/river/init +++ b/river/init @@ -1,5 +1,6 @@ #!/bin/sh +XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" # This is the example configuration file for river. # # If you wish to edit this, you will probably want to copy it to @@ -13,8 +14,12 @@ # Super+Shift+Return to start an instance of foot (https://codeberg.org/dnkl/foot) # riverctl map normal Super+Shift Return spawn foot # riverctl map normal Super Return spawn alacritty -riverctl map normal Super Return spawn foot -riverctl map normal Super+Shift Return spawn 'foot -c "$HOME/.config/foot/light.ini"' +# riverctl map normal Super Return spawn foot + +foot --server & +riverctl map normal Super Return spawn footclient +riverctl map normal Super M spawn "${XDG_CONFIG_HOME}"/river/theme_helper +riverctl map normal Super+Shift b spawn footclient btop # Super+Q to close the focused view riverctl map normal Super+Shift Q close @@ -172,11 +177,11 @@ riverctl rule-add -app-id "bar" csd riverctl default-layout rivertile rivertile -view-padding 10 -outer-padding 0 & -riverctl map normal Super Equal spawn "$HOME/.config/river/padding_helper 0 25" -riverctl map normal Super Minus spawn "$HOME/.config/river/padding_helper 0 -25" +riverctl map normal Super Equal spawn "${XDG_CONFIG_HOME}/river/padding_helper 0 25" +riverctl map normal Super Minus spawn "${XDG_CONFIG_HOME}/river/padding_helper 0 -25" -riverctl map normal Super+Shift Equal spawn "$HOME/.config/river/padding_helper 10 0" -riverctl map normal Super+Shift Minus spawn "$HOME/.config/river/padding_helper -10 0" +riverctl map normal Super+Shift Equal spawn "${XDG_CONFIG_HOME}/river/padding_helper 10 0" +riverctl map normal Super+Shift Minus spawn "${XDG_CONFIG_HOME}/river/padding_helper -10 0" riverctl map normal Super+Control L spawn swaylock riverctl map normal Super D spawn bemenu-run @@ -203,15 +208,23 @@ if ! pgrep waybar >/dev/null 2>&1 ; then waybar & fi -"$HOME"/.config/river/pointer +"${XDG_CONFIG_HOME}"/river/pointer if ! pgrep swaybg >/dev/null 2>&1 ; then - swaybg -i .wallpaper.jpg & + echo "" + # swaybg -i .wallpaper.jpg & fi # If Chromium dialogs aren't working these are suspect dbus-update-activation-environment --systemd WAYLAND_DISPLAY "XDG_CURRENT_DESKTOP=$XDG_CURRENT_DESKTOP" systemctl --user restart xdg-desktop-portal +# I hate calling this directly but the systemd unit is bugged on arch at +# least, running it by hand appears to work just fine +_gtk_portal=/usr/lib/xdg-desktop-portal-gtk +if [ -x "$_gtk_portal" ] ; then + "$_gtk_portal" & +fi + riverctl rule-add -title '*Firefox*' ssd riverctl rule-add -app-id '*chromium*' ssd riverctl rule-add -title '*paypal*' float @@ -224,6 +237,9 @@ riverctl rule-add -app-id "*evolution*" tags $((1 << (8 - 1))) riverctl rule-add -app-id "*pavu*" ssd riverctl rule-add -app-id "*blueman*" ssd -. ~/.kshrc -checkSSHAgent -k -checkSSHAgent +if [ -e ~/.kshrc ] ; then + . ~/.kshrc + checkSSHAgent -k + checkSSHAgent +fi + diff --git a/river/theme_helper b/river/theme_helper new file mode 100755 index 0000000..398910d --- /dev/null +++ b/river/theme_helper @@ -0,0 +1,43 @@ +#!/bin/sh +set -ex +exec >/tmp/theme.log 2>&1 +XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +conf="$XDG_CONFIG_HOME/river/theme_conf" + +gnomeSet() { + gsettings set org.gnome.desktop.interface color-scheme "$1" +} + +bgcolor_dark=0x282828 +bgcolor_light=0xfbf1c7 + +if ! [ -e "$conf" ] ; then +cat > "$conf" < "$conf" <