mirror of
https://github.com/zoriya/flake.git
synced 2026-06-02 18:51:15 +00:00
Create theme switcher
This commit is contained in:
@@ -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 @@
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Executable
+12
@@ -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"
|
||||
@@ -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
|
||||
|
||||
@@ -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 []
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user