diff --git a/modules/home/colors/default.nix b/modules/home/colors/default.nix index 4c59774..e851f8b 100644 --- a/modules/home/colors/default.nix +++ b/modules/home/colors/default.nix @@ -1,19 +1,27 @@ -{ nix-colors, lib, pkgs, ... }: rec { - imports = [ nix-colors.homeManagerModule ]; - +{ + nix-colors, + lib, + pkgs, + ... +}: let + theme-switcher = pkgs.writeShellScriptBin "settheme" (builtins.readFile ./settheme.sh); +in rec { + imports = [nix-colors.homeManagerModule]; home.packages = with pkgs; [ (google-chrome.override { commandLineArgs = ["--force-dark-mode" "--enable-features=WebUIDarkMode"]; }) home-manager + theme-switcher ]; - colorScheme = lib.mkDefault specialization.dark.configuration.colorScheme; darkColors = specialization.dark.configuration.colorScheme.colors; specialization = { dark.configuration = { + home.file.".local/state/theme".text = "dark"; + colorScheme = { slug = "catppuccin-mocha"; name = "Catppuccin Mocha"; @@ -40,6 +48,8 @@ }; light.configuration = { + home.file.".local/state/theme".text = "light"; + colorScheme = { slug = "catppuccin-latte"; name = "Catppuccin Latte"; @@ -69,5 +79,4 @@ }; }; }; - } diff --git a/modules/home/colors/settheme.sh b/modules/home/colors/settheme.sh new file mode 100755 index 0000000..1c731a2 --- /dev/null +++ b/modules/home/colors/settheme.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e + +GENERATION=$(home-manager generations | cut -d \> -f 2 | cut -c2- | sed 's@$@/specialization/@' | xargs -d \\n -I{} find "{}" -type d 2> /dev/null | head -n1) +CURRENT_THEME=$(cat ~/.local/state/theme) +THEME=${1:-$([ "$CURRENT_THEME" == "light" ] && echo "dark" || echo "light")} + +echo "Current generation is $GENERATION, current theme is $CURRENT_THEME." +echo "Switching to theme $THEME" + +"$GENERATION/$THEME/activate" diff --git a/modules/home/eww/panel/yuck/_music.yuck b/modules/home/eww/panel/yuck/_music.yuck index f6ce415..a3a4b16 100644 --- a/modules/home/eww/panel/yuck/_music.yuck +++ b/modules/home/eww/panel/yuck/_music.yuck @@ -2,8 +2,8 @@ (deflisten music_cover "./panel/music.sh cover") ; TODO: Use a hook on change instead of polling. -(defpoll volume :interval "5s" "pamixer --get-volume") -(defpoll is_mute :interval "5s" "pamixer --get-mute") +(defpoll volume :interval "1s" "pamixer --get-volume") +(defpoll is_mute :interval "1s" "pamixer --get-mute") (defwidget dmusic [] (box :vexpand true diff --git a/modules/home/eww/panel/yuck/_stats.yuck b/modules/home/eww/panel/yuck/_stats.yuck index 5cda030..517e973 100644 --- a/modules/home/eww/panel/yuck/_stats.yuck +++ b/modules/home/eww/panel/yuck/_stats.yuck @@ -1,30 +1,50 @@ ; TODO: Update this value when pressing the button. -(defpoll bright :interval '5s' "brightnessctl -m | cut -d , -f 4 | head -c -2") +(defpoll bright :interval '1s' "brightnessctl -m | cut -d , -f 4 | head -c -2") -(defpoll ssid :interval "5s" `nmcli -terse -fields SSID,ACTIVE device wifi | awk --field-separator ':' '{if($2=="yes")print$1}'`) -(defpoll bluethooth :interval '5s' "echo info | timeout 1 bluetoothctl | grep 'Name'") +(defpoll ssid :interval "1s" `nmcli -terse -fields SSID,ACTIVE device wifi | awk --field-separator ':' '{if($2=="yes")print$1}'`) +(defpoll bluethooth :interval '1s' "echo info | timeout 1 bluetoothctl | grep 'Name'") +(defpoll theme :interval '1s' "cat ~/.local/state/theme") -(defwidget stat_card [icon name percent value colorClass] - (box :space-evenly false - :class "disclose-stats-box" - (circular-progress :value percent - :thickness 10 - :class "${colorClass}-txt" - (label :halign "center" :class "stats-label ${colorClass}-txt" :text icon)) - (label :class "stats-separator" :text "") - (box :hexpand true :halign "center" :orientation "vertical" :class "disclose-stats-info-box" - (label :halign "center" :class "info-value ${colorClass}-txt" :text value) - (label :halign "start" :class "info-label" :text name)))) +(defwidget stat_card [icon name percent value colorClass ?click] + (button + :click click + (box + :space-evenly false + :class "disclose-stats-box" + (circular-progress :value percent + :thickness 10 + :class "${colorClass}-txt" + (label :halign "center" :class "stats-label ${colorClass}-txt" :text icon)) + (label :class "stats-separator" :text "") + (box :hexpand true :halign "center" :orientation "vertical" :class "disclose-stats-info-box" + (label :halign "center" :class "info-value ${colorClass}-txt" :text value) + (label :halign "start" :class "info-label" :text name))))) (defwidget dstats [] (box :space-evenly false :orientation "vertical" :class "disclose-stats" :spacing 10 - (stat_card :icon "" :name "CPU" :percent 0 :value {round(EWW_CPU.avg, 2)} :colorClass "red") - (stat_card :icon "" :name "Memory" :percent {EWW_RAM.used_mem_perc} :value "${round(EWW_RAM.used_mem_perc, 0)}%" :colorClass "green") - (stat_card :icon "󰃠" :name "Brightness" :percent bright :value "${bright}%" :colorClass "blue"))) + (stat_card + :icon "" + :name "CPU" + :percent 0 + :value {round(EWW_CPU.avg, 2)} + :colorClass "red") + (stat_card + :icon "" + :name "Memory" + :percent {EWW_RAM.used_mem_perc} + :value "${round(EWW_RAM.used_mem_perc, 0)}%" + :colorClass "green") + (stat_card + :icon {theme == "light" ? "󰃞" : "󰃝"} + :name "Brightness" + :percent bright + :value "${bright}%" + :colorClass "blue" + :click "settheme"))) (defwidget wifi [] diff --git a/modules/home/hyprland/hyprland.conf b/modules/home/hyprland/hyprland.conf index 95a50c7..116d5de 100644 --- a/modules/home/hyprland/hyprland.conf +++ b/modules/home/hyprland/hyprland.conf @@ -5,7 +5,6 @@ exec-once=fusuma -c /home/zoriya/.config/fusuma/config.yaml exec-once=swayidle -w timeout 1200 lock before-sleep lock exec-once=/home/zoriya/.config/hypr/wallpaper.sh init exec-once=kitty --class=scratchpad -#exec-once=fcitx5 -d # TAKEN CARE BY SYSTEMD exec-once = wl-paste --type text --watch cliphist store autogenerated = 0 @@ -179,7 +178,8 @@ bind = $mainMod, V, exec, cliphist list | rofi -dmenu | cliphist decode | wl-cop $WOBSOCK = $XDG_RUNTIME_DIR/wob.sock -exec-once=rm -f $WOBSOCK && mkfifo $WOBSOCK && tail -f $WOBSOCK | wob +# Use exec and killall to refresh the colorscheme of wob. +exec=killall wob && rm -f $WOBSOCK && mkfifo $WOBSOCK && tail -f $WOBSOCK | wob bindle=,XF86MonBrightnessDown,exec,brightnessctl set 5%- | sed -En 's/.*\(([0-9]+)%\).*/\1/p' > $WOBSOCK bindle=,XF86MonBrightnessUp,exec,brightnessctl set +5% | sed -En 's/.*\(([0-9]+)%\).*/\1/p' > $WOBSOCK