From 416d1cc2029e28519a2ccafabcf7c01c00837f50 Mon Sep 17 00:00:00 2001 From: TypoMustakes Date: Wed, 8 Apr 2026 14:24:18 +0200 Subject: [PATCH] Declared hyprland scripts --- hyprland/hypr/hyprland.nix | 3 + hyprland/scripts/powermenu.nix | 35 +++++++++ hyprland/scripts/screenshot.nix | 28 +++++++ hyprland/scripts/themeswitch.nix | 130 +++++++++++++++++++++++++++++++ 4 files changed, 196 insertions(+) create mode 100644 hyprland/scripts/powermenu.nix create mode 100644 hyprland/scripts/screenshot.nix create mode 100644 hyprland/scripts/themeswitch.nix diff --git a/hyprland/hypr/hyprland.nix b/hyprland/hypr/hyprland.nix index e5c8921..0f52587 100644 --- a/hyprland/hypr/hyprland.nix +++ b/hyprland/hypr/hyprland.nix @@ -2,5 +2,8 @@ imports = [ ../programs/fuzzel.nix ../programs/kitty.nix + ../scripts/powermenu.nix + ../scripts/screenshot.nix + ../scripts/themeswitch.nix ]; } diff --git a/hyprland/scripts/powermenu.nix b/hyprland/scripts/powermenu.nix new file mode 100644 index 0000000..b1f7f43 --- /dev/null +++ b/hyprland/scripts/powermenu.nix @@ -0,0 +1,35 @@ +{ lib, config, ... }: + +{ + home.file.".config/hypr/hyprland/scripts/powermenu.sh".text = '' +#!/bin/bash + +INPUT="echo -e Lock\nLogout\nReboot\nShutdown\nSuspend" + +# Execute the input command and get the selected choice +SELECTED=$($INPUT | fuzzel -d) + +case "$SELECTED" in +"Lock") + hyprlock + ;; +"Logout") + hyprctl dispatch exit + ;; +"Reboot") + reboot + ;; +"Shutdown") + shutdown now + ;; +"Suspend") + systemctl suspend + ;; +*) + echo "Invalid selection" + ;; +esac + ''; + + home.file.".config/hypr/hyprland/scripts/powermenu.sh".force = true; +} diff --git a/hyprland/scripts/screenshot.nix b/hyprland/scripts/screenshot.nix new file mode 100644 index 0000000..04fa95c --- /dev/null +++ b/hyprland/scripts/screenshot.nix @@ -0,0 +1,28 @@ +{ lib, config, ... }: + +{ + home.file.".config/hypr/hyprland/scripts/screenshot.sh".text = '' +#!/bin/bash + +INPUT="echo -e Screen\nWindow\nRegion" + +SELECTED=$($INPUT | fuzzel -d) + +case "$SELECTED" in +"Screen") + hyprshot -m output + ;; +"Window") + hyprshot -m window + ;; +"Region") + hyprshot -m region + ;; +*) + echo "Invalid selection" + ;; +esac + ''; + + home.file.".config/hypr/hyprland/scripts/screenshot.sh".force = true; +} diff --git a/hyprland/scripts/themeswitch.nix b/hyprland/scripts/themeswitch.nix new file mode 100644 index 0000000..da0db29 --- /dev/null +++ b/hyprland/scripts/themeswitch.nix @@ -0,0 +1,130 @@ +{ lib, config, ... }: + +{ + home.file.".config/hypr/hyprland/scripts/themeswitch.sh".text = '' +#!/bin/bash + +OPTION_DARK="Gruvbox Dark" +OPTION_LIGHT="Gruvbox Light" + +EMACS_LIGHT_THEME="doom-gruvbox-light" +EMACS_DARK_THEME="doom-gruvbox" + +INPUT="echo -e $OPTION_DARK\n$OPTION_LIGHT" + +# Execute the input command and get the selected choice +SELECTED=$($INPUT | fuzzel -d) + +declare -A TARGETS=( + ["kitty"]="$XDG_CONFIG_HOME/kitty/kitty.conf" + ["waybar"]="$XDG_CONFIG_HOME/waybar/style.css" + ["fuzzel"]="$XDG_CONFIG_HOME/fuzzel/fuzzel.ini" + ["swaync"]="$XDG_CONFIG_HOME/swaync/style.css" + ["swayosd"]="$XDG_CONFIG_HOME/swayosd/style.css" +) + +make_link() { + ln -sf $1 $2 +} + +switch_emacs() { + if [[ "$1" == "$OPTION_LIGHT" ]]; then + emacsclient -e "(load-theme '$EMACS_LIGHT_THEME)" + elif [[ "$1" == "$OPTION_DARK" ]]; then + emacsclient -e "(load-theme '$EMACS_DARK_THEME)" + else + echo "Invalid parameter $1" + fi +} + +switch_fuzzel() { + if [[ "$1" == "$OPTION_LIGHT" ]]; then + make_link $HOME/.config/fuzzel/fuzzel_light.ini $HOME/.config/fuzzel/fuzzel.ini + elif [[ "$1" == "$OPTION_DARK" ]]; then + make_link $HOME/.config/fuzzel/fuzzel_dark.ini $HOME/.config/fuzzel/fuzzel.ini + else + echo "Invalid parameter $1" + fi +} + +switch_swayosd() { + if [[ "$1" == "$OPTION_LIGHT" ]]; then + make_link $HOME/.config/swayosd/style_light.css $HOME/.config/swayosd/style.css + elif [[ "$1" == "$OPTION_DARK" ]]; then + make_link $HOME/.config/swayosd/style_dark.css $HOME/.config/swayosd/style.css + else + echo "Invalid parameter $1" + fi +} + +switch_swaync() { + if [[ "$1" == "$OPTION_LIGHT" ]]; then + make_link $HOME/.config/swaync/style_light.css $HOME/.config/swaync/style.css + elif [[ "$1" == "$OPTION_DARK" ]]; then + make_link $HOME/.config/swaync/style_dark.css $HOME/.config/swaync/style.css + else + echo "Invalid parameter $1" + fi +} + +switch_kitty() { + if [[ "$1" == "$OPTION_LIGHT" ]]; then + make_link $HOME/.config/kitty/kitty_light.conf $HOME/.config/kitty/kitty.conf + elif [[ "$1" == "$OPTION_DARK" ]]; then + make_link $HOME/.config/kitty/kitty_dark.conf $HOME/.config/kitty/kitty.conf + else + echo "Invalid parameter $1" + fi +} + +switch_waybar() { + if [[ "$1" == "$OPTION_LIGHT" ]]; then + make_link $HOME/.config/waybar/style_light.css $HOME/.config/waybar/style.css + elif [[ "$1" == "$OPTION_DARK" ]]; then + make_link $HOME/.config/waybar/style_dark.css $HOME/.config/waybar/style.css + else + echo "Invalid parameter $1" + fi +} + +update() { + #kitty + pgrep -x kitty >/dev/null && kill -SIGUSR1 $(pgrep -x kitty) + + #waybar + pgrep -x waybar >/dev/null && kill -SIGUSR2 $(pgrep -x waybar) + + #swaync + pgrep -x swaync >/dev/null && swaync-client --reload-css + + #swayosd + killall swayosd-server + swayosd-server & +} + +case "$SELECTED" in +$OPTION_DARK) + dconf write /org/gnome/desktop/interface/color-scheme \'prefer-dark\' + awww img /home/typo/.config/backgrounds/gruvbox/wp11058332.png -t grow --transition-duration 1 --transition-fps 60 --transition-pos 0.$((1 + $RANDOM % 9)),0.$((1 + $RANDOM % 9)) + ;; +$OPTION_LIGHT) + dconf write /org/gnome/desktop/interface/color-scheme \'prefer-light\' + awww img /home/typo/.config/backgrounds/gruvbox/chinese-hills.jpg -t grow --transition-duration 1 --transition-fps 60 --transition-pos 0.$((1 + $RANDOM % 9)),0.$((1 + $RANDOM % 9)) + + ;; +*) + echo "Invalid selection" + ;; +esac + +switch_kitty "$SELECTED" +switch_waybar "$SELECTED" +switch_swaync "$SELECTED" +switch_swayosd "$SELECTED" +switch_fuzzel "$SELECTED" +switch_emacs "$SELECTED" +update + ''; + + home.file.".config/hypr/hyprland/scripts/themeswitch.sh".force = true; +}