dotfiles

My PC Dotfiles & Website
commit e7351b1b8683495e767e4e4490ee60b83680c69e
parent a66d44b813dfce48ce5061753c4da4251a0fa104
Author: maydayv7 <maydayv7@gmail.com>
Date:   Wed, 27 Nov 2024 13:55:53 +0530

feat: More Hyprland keybinds

Diffstat:

Mdevices/valkyrie/drivers.nix | 39+++++++++++++++++++++++----------------
Mmodules/gui/desktop/hyprland/settings/keybindings.nix | 7+++++++
Mscripts/commands.sh | 2+-
Mscripts/hyprutils.nix | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 86 insertions(+), 17 deletions(-)

diff --git a/devices/valkyrie/drivers.nix b/devices/valkyrie/drivers.nix @@ -68,24 +68,31 @@ in { )''; }; - user.homeConfig.dconf.settings = mkIf (hasPrefix "gnome" config.gui.desktop) { - "org/gnome/settings-daemon/plugins/media-keys" = { - custom-keybindings = [ - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/" - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4/" - ]; - }; + user.homeConfig = { + wayland.windowManager.hyprland.settings.bindl = mkIf (hasPrefix "hyprland" config.gui.desktop) [ + ", XF86Launch3, exec, asusctl led-mode -n" + ", XF86Launch4, exec, asusctl profile -n" + ]; - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3" = { - binding = "Launch3"; - command = "asusctl led-mode -n"; - name = "Keyboard Mode"; - }; + dconf.settings = mkIf (hasPrefix "gnome" config.gui.desktop) { + "org/gnome/settings-daemon/plugins/media-keys" = { + custom-keybindings = [ + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/" + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4/" + ]; + }; - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4" = { - binding = "Launch4"; - command = "asusctl profile -n"; - name = "Fan Control"; + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3" = { + binding = "Launch3"; + command = "asusctl led-mode -n"; + name = "Keyboard Mode"; + }; + + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4" = { + binding = "Launch4"; + command = "asusctl profile -n"; + name = "Fan Control"; + }; }; }; } diff --git a/modules/gui/desktop/hyprland/settings/keybindings.nix b/modules/gui/desktop/hyprland/settings/keybindings.nix @@ -100,6 +100,13 @@ # Volume ", XF86AudioMute, exec, hyprutils volume mute" + + # Keyboard Backlight + ", XF86KbdBrightnessUp, exec, hyprutils backlight up" + ", XF86KbdBrightnessDown, exec, hyprutils backlight down" + + # Touchpad + ", XF86TouchpadToggle, exec, hyprutils toggle touchpad" ]; # Repeat on Hold diff --git a/scripts/commands.sh b/scripts/commands.sh @@ -5,7 +5,7 @@ temp(){ TEMP=/tmp/"$1" - rm -rf "$TEMP" + if ! [ "$2" -eq 1 ]; then rm -rf "$TEMP"; fi mkdir -p "$TEMP" } diff --git a/scripts/hyprutils.nix b/scripts/hyprutils.nix @@ -13,6 +13,7 @@ # Usage # help - Show this information brightness [up,down] - Screen Brightness Controls + backlight [up,down] - Keyboard Backlight Controls volume [up,down,mute] - Volume Controls media [next,previous,toggle] - Media Controls minimize [show] - Show Minimized windows @@ -24,6 +25,7 @@ monitor - Toggle specified Monitor panel - Toggle top Panel shader - Toggle Compositor Shader + touchpad - Toggle touchpad ''; minimize = builtins.toFile "minimize.sh" '' @@ -57,6 +59,7 @@ in waybar alsa-utils + brightnessctl brillo coreutils gnugrep @@ -81,6 +84,7 @@ in media_icon="audio-speakers" if $show_album_art then + temp media-icon 1 url=$(playerctl -f "{{mpris:artUrl}}" metadata) if [[ "$url" == "file://"* ]] then @@ -115,6 +119,27 @@ in *) error "Unexpected Option 'brightness $2'" "Try 'hyprutils help' for more information" ;; esac ;; + "backlight") + backlight_notification() { + backlight="$(cat /sys/class/leds/*::kbd_backlight/brightness)" + light=0; if [ "$backlight" -eq 1 ]; then light=33; fi + if [ "$backlight" -eq 2 ]; then light=67; fi + if [ "$backlight" -eq 3 ]; then light=100; fi + notify backlight -i "keyboard" -h int:value:"$light" " $light%" + } + case "$2" in + "up") + brightnessctl -d "*::kbd_backlight" set 33%+ + backlight_notification + ;; + "down") + brightnessctl -d "*::kbd_backlight" set 33%- + backlight_notification + ;; + "") error "Expected an Option" "Try 'hyprutils help' for more information" ;; + *) error "Unexpected Option 'brightness $2'" "Try 'hyprutils help' for more information" ;; + esac + ;; "volume") volume_notification() { volume=$(amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1) @@ -292,6 +317,36 @@ in SHADER=$(zenity --list --title="Compositor Shader Toggle" --column="Shaders" "''${SHADERS[@]}" | sed "s/^[ \t]*//") hyprshade on "$SHADER" && hyprctl seterror "" ;; + "touchpad") + temp touchpad 1 + STATUS="$TEMP/status" + touchpad=$(hyprctl devices | grep touchpad | xargs) + + enable() { + hyprctl keyword "device[$touchpad]:enabled" true + printf "true" >"$STATUS" + notify touchpad -i "touchpad" "Touchpad Enabled" + } + + disable() { + hyprctl keyword "device[$touchpad]:enabled" false + printf "false" >"$STATUS" + notify touchpad -i "touchpad" "Touchpad Disabled" + } + + if ! [ -f "$STATUS" ] + then + disable + else + if [ "$(cat "$STATUS")" = "true" ] + then + disable + elif [ "$(cat "$STATUS")" = "false" ] + then + enable + fi + fi + ;; "") error "Expected an Option" "Try 'hyprutils help' for more information" ;; *) error "Unexpected Option 'toggle $2'" "Try 'hyprutils help' for more information" ;; esac