From 499a65cfd8868b56c5739199f9731cbcd86887c9 Mon Sep 17 00:00:00 2001 From: Tyler Kelley Date: Mon, 17 Feb 2025 14:50:36 -0600 Subject: [PATCH] using a modified version of jakoolits keybind script and fixing scripts --- modules/core/packages.nix | 1 - modules/home/scripts/default.nix | 25 +- modules/home/scripts/keybinds.nix | 15 + modules/home/scripts/list-hypr-bindings.nix | 62 --- modules/home/scripts/rofi-launcher.nix | 10 +- modules/home/scripts/web-search.nix | 65 +-- modules/home/waybar.nix | 518 ++++++++++---------- 7 files changed, 325 insertions(+), 371 deletions(-) create mode 100644 modules/home/scripts/keybinds.nix delete mode 100755 modules/home/scripts/list-hypr-bindings.nix diff --git a/modules/core/packages.nix b/modules/core/packages.nix index e9101f3..e35b6e4 100644 --- a/modules/core/packages.nix +++ b/modules/core/packages.nix @@ -68,6 +68,5 @@ v4l-utils virt-viewer wget - yad ]; } diff --git a/modules/home/scripts/default.nix b/modules/home/scripts/default.nix index 08e9852..a519741 100644 --- a/modules/home/scripts/default.nix +++ b/modules/home/scripts/default.nix @@ -1,21 +1,20 @@ -{ pkgs, username, host, ... }: - { + pkgs, + username, + ... +}: { home.packages = [ - (import ./emopicker9000.nix { inherit pkgs; }) - (import ./task-waybar.nix { inherit pkgs; }) - (import ./squirtle.nix { inherit pkgs; }) - (import ./nvidia-offload.nix { inherit pkgs; }) + (import ./emopicker9000.nix {inherit pkgs;}) + (import ./keybinds.nix {inherit pkgs;}) + (import ./task-waybar.nix {inherit pkgs;}) + (import ./squirtle.nix {inherit pkgs;}) + (import ./nvidia-offload.nix {inherit pkgs;}) (import ./wallsetter.nix { inherit pkgs; inherit username; }) - (import ./web-search.nix { inherit pkgs; }) - (import ./rofi-launcher.nix { inherit pkgs; }) - (import ./screenshootin.nix { inherit pkgs; }) - (import ./list-hypr-bindings.nix { - inherit pkgs; - inherit host; - }) + (import ./web-search.nix {inherit pkgs;}) + (import ./rofi-launcher.nix {inherit pkgs;}) + (import ./screenshootin.nix {inherit pkgs;}) ]; } diff --git a/modules/home/scripts/keybinds.nix b/modules/home/scripts/keybinds.nix new file mode 100644 index 0000000..17042b4 --- /dev/null +++ b/modules/home/scripts/keybinds.nix @@ -0,0 +1,15 @@ +{pkgs}: +pkgs.writeShellScriptBin "list-keybinds" '' + # check if rofi is already running + if pidof rofi > /dev/null; then + pkill rofi + fi + + rofi_theme="$HOME/.config/rofi/config-wide.rasi" + msg='☣️ NOTE ☣️: Clicking with Mouse or Pressing ENTER will have NO function' + keybinds=$(cat ~/.config/hypr/hyprland.conf | grep modifier) + + # use rofi to display the keybinds with the modified content + echo "$keybinds" | rofi -dmenu -i -config "$rofi_theme" -mesg "$msg" + +'' diff --git a/modules/home/scripts/list-hypr-bindings.nix b/modules/home/scripts/list-hypr-bindings.nix deleted file mode 100755 index 69b55bd..0000000 --- a/modules/home/scripts/list-hypr-bindings.nix +++ /dev/null @@ -1,62 +0,0 @@ -{ pkgs, host, ... }: - -let - inherit (import ../../../hosts/${host}/variables.nix) terminal browser; -in -pkgs.writeShellScriptBin "list-hypr-bindings" '' - yad --width=800 --height=650 \ - --center \ - --fixed \ - --title="Hyprland Keybindings" \ - --no-buttons \ - --list \ - --column=Key: \ - --column=Description: \ - --column=Command: \ - --timeout=90 \ - --timeout-indicator=right \ - " = Windows/Super/CAPS LOCK" "Modifier Key, used for keybindings" "Doesn't really execute anything by itself." \ - " + ENTER" "Terminal" "${terminal}" \ - " + SHIFT + ENTER" "App Launcher" "rofi" \ - " + ALT + W" "Change Wallpaper" "wallsetter" \ - " + Q" "Kill Focused Window" "killactive" \ - " + SHIFT + W" "Search Websites Like Nix Packages" "web-search" \ - " + SHIFT + N" "Reload SwayNC Styling" "swaync-client -rs" \ - " + W" "Launch Web Browser" "${browser}" \ - " + E" "Launch Emoji Selector" "emopicker9000" \ - " + S" "Take Screenshot" "screenshootin" \ - " + D" "Launch Discord" "discord" \ - " + O" "Launch OBS" "obs" \ - " + G" "Launch GIMP" "gimp" \ - " + N" "Launch New File Browser Window" "thunar" \ - " + M" "Launch Spotify" "spotify" \ - " + P" "Pseudo Tiling" "pseudo" \ - " + SHIFT + I" "Toggle Split Direction" "togglesplit" \ - " + F" "Toggle Focused Fullscreen" "fullscreen" \ - " + SHIFT + F" "Toggle Focused Floating" "fullscreen" \ - " + SHIFT + C" "Quit / Exit Hyprland" "exit" \ - " + Left" "Move Focus To Window On The Left" "movefocus,l" \ - " + Right" "Move Focus To Window On The Right" "movefocus,r" \ - " + Up" "Move Focus To Window On The Up" "movefocus,u" \ - " + Down" "Move Focus To Window On The Down" "movefocus,d" \ - " + SHIFT + Left" "Move Focused Window Left" "movewindow,l" \ - " + SHIFT + Right" "Move Focused Window Right" "movewindow,r" \ - " + SHIFT + Up" "Move Focused Window Up" "movewindow,u" \ - " + SHIFT + Down" "Move Focused Window Down" "movewindow,d" \ - " + H" "Move Focus To Window On The Left" "movefocus,l" \ - " + L" "Move Focus To Window On The Right" "movefocus,r" \ - " + K" "Move Focus To Window On The Up" "movefocus,u" \ - " + J" "Move Focus To Window On The Down" "movefocus,d" \ - " + SHIFT + H" "Move Focused Window Left" "movewindow,l" \ - " + SHIFT + L" "Move Focused Window Right" "movewindow,r" \ - " + SHIFT + K" "Move Focused Window Up" "movewindow,u" \ - " + SHIFT + J" "Move Focused Window Down" "movewindow,d" \ - " + SPACE" "Toggle Special Workspace" "togglespecialworkspace" \ - " + SHIFT + SPACE" "Send Focused Window To Special Workspace" "movetoworkspace,special" \ - " + 1-0" "Move To Workspace 1 - 10" "workspace,X" \ - " + SHIFT + 1-0" "Move Focused Window To Workspace 1 - 10" "movetoworkspace,X" \ - " + MOUSE_LEFT" "Move/Drag Window" "movewindow" \ - " + MOUSE_RIGHT" "Resize Window" "resizewindow" \ - "ALT + TAB" "Cycle Window Focus + Bring To Front" "cyclenext & bringactivetotop" \ - "" -'' diff --git a/modules/home/scripts/rofi-launcher.nix b/modules/home/scripts/rofi-launcher.nix index 153b3ec..b1a3eb2 100644 --- a/modules/home/scripts/rofi-launcher.nix +++ b/modules/home/scripts/rofi-launcher.nix @@ -1,10 +1,8 @@ -{ pkgs }: - +{pkgs}: pkgs.writeShellScriptBin "rofi-launcher" '' - if pgrep -x "rofi" > /dev/null; then - # Rofi is running, kill it - pkill -x rofi - exit 0 + # check if rofi is already running + if pidof rofi > /dev/null; then + pkill rofi fi rofi -show drun '' diff --git a/modules/home/scripts/web-search.nix b/modules/home/scripts/web-search.nix index 8b1e3e9..263b228 100644 --- a/modules/home/scripts/web-search.nix +++ b/modules/home/scripts/web-search.nix @@ -1,40 +1,45 @@ {pkgs}: pkgs.writeShellScriptBin "web-search" '' - declare -A URLS + # check if rofi is already running + if pidof rofi > /dev/null; then + pkill rofi + fi - URLS=( - ["🌎 Search"]="https://search.brave.com/search?q=" - ["❄️ Unstable Packages"]="https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=" - ["🎞️ YouTube"]="https://www.youtube.com/results?search_query=" - ["🦥 Arch Wiki"]="https://wiki.archlinux.org/title/" - ["🐃 Gentoo Wiki"]="https://wiki.gentoo.org/index.php?title=" - ) + declare -A URLS - # List for rofi - gen_list() { - for i in "''${!URLS[@]}" - do - echo "$i" - done - } + URLS=( + ["🌎 Search"]="https://search.brave.com/search?q=" + ["❄️ Unstable Packages"]="https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=" + ["🎞️ YouTube"]="https://www.youtube.com/results?search_query=" + ["🦥 Arch Wiki"]="https://wiki.archlinux.org/title/" + ["🐃 Gentoo Wiki"]="https://wiki.gentoo.org/index.php?title=" + ) - main() { - # Pass the list to rofi - platform=$( (gen_list) | ${pkgs.rofi-wayland}/bin/rofi -dmenu -config ~/.config/rofi/config-long.rasi ) + # List for rofi + gen_list() { + for i in "''${!URLS[@]}" + do + echo "$i" + done + } - if [[ -n "$platform" ]]; then - query=$( (echo ) | ${pkgs.rofi-wayland}/bin/rofi -dmenu -config ~/.config/rofi/config-long.rasi ) + main() { + # Pass the list to rofi + platform=$( (gen_list) | ${pkgs.rofi-wayland}/bin/rofi -dmenu -config ~/.config/rofi/config-long.rasi ) - if [[ -n "$query" ]]; then - url=''${URLS[$platform]}$query - xdg-open "$url" - else - exit - fi - else - exit - fi - } + if [[ -n "$platform" ]]; then + query=$( (echo ) | ${pkgs.rofi-wayland}/bin/rofi -dmenu -config ~/.config/rofi/config-long.rasi ) + + if [[ -n "$query" ]]; then + url=''${URLS[$platform]}$query + xdg-open "$url" + else + exit + fi + else + exit + fi + } main diff --git a/modules/home/waybar.nix b/modules/home/waybar.nix index 03757d5..d36813b 100644 --- a/modules/home/waybar.nix +++ b/modules/home/waybar.nix @@ -4,274 +4,274 @@ host, config, ... -}: - -let +}: let betterTransition = "all 0.3s cubic-bezier(.55,-0.68,.48,1.682)"; inherit (import ../../hosts/${host}/variables.nix) clock24h; in -with lib; -{ - # Configure & Theme Waybar - programs.waybar = { - enable = true; - package = pkgs.waybar; - settings = [ - { - layer = "top"; - position = "top"; - modules-center = [ "hyprland/workspaces" ]; - modules-left = [ - "custom/startmenu" - "hyprland/window" - "pulseaudio" - "cpu" - "memory" - "idle_inhibitor" - ]; - modules-right = [ - "custom/hyprbindings" - "custom/notification" - "custom/exit" - "battery" - "tray" - "clock" - ]; + with lib; { + # Configure & Theme Waybar + programs.waybar = { + enable = true; + package = pkgs.waybar; + settings = [ + { + layer = "top"; + position = "top"; + modules-center = ["hyprland/workspaces"]; + modules-left = [ + "custom/startmenu" + "hyprland/window" + "pulseaudio" + "cpu" + "memory" + "idle_inhibitor" + ]; + modules-right = [ + "custom/hyprbindings" + "custom/notification" + "custom/exit" + "battery" + "tray" + "clock" + ]; - "hyprland/workspaces" = { - format = "{name}"; - format-icons = { - default = " "; - active = " "; - urgent = " "; + "hyprland/workspaces" = { + format = "{name}"; + format-icons = { + default = " "; + active = " "; + urgent = " "; + }; + on-scroll-up = "hyprctl dispatch workspace e+1"; + on-scroll-down = "hyprctl dispatch workspace e-1"; }; - on-scroll-up = "hyprctl dispatch workspace e+1"; - on-scroll-down = "hyprctl dispatch workspace e-1"; - }; - "clock" = { - format = if clock24h == true then '' {:L%H:%M}'' else '' {:L%I:%M %p}''; - tooltip = true; - tooltip-format = "{:%A, %d.%B %Y }\n{calendar}"; - }; - "hyprland/window" = { - max-length = 22; - separate-outputs = false; - rewrite = { - "" = " 🙈 No Windows? "; + "clock" = { + format = + if clock24h == true + then '' {:L%H:%M}'' + else '' {:L%I:%M %p}''; + tooltip = true; + tooltip-format = "{:%A, %d.%B %Y }\n{calendar}"; }; - }; - "memory" = { - interval = 5; - format = " {}%"; - tooltip = true; - }; - "cpu" = { - interval = 5; - format = " {usage:2}%"; - tooltip = true; - }; - "disk" = { - format = " {free}"; - tooltip = true; - }; - "network" = { - format-icons = [ - "󰤯" - "󰤟" - "󰤢" - "󰤥" - "󰤨" - ]; - format-ethernet = " {bandwidthDownOctets}"; - format-wifi = "{icon} {signalStrength}%"; - format-disconnected = "󰤮"; - tooltip = false; - }; - "tray" = { - spacing = 12; - }; - "pulseaudio" = { - format = "{icon} {volume}% {format_source}"; - format-bluetooth = "{volume}% {icon} {format_source}"; - format-bluetooth-muted = " {icon} {format_source}"; - format-muted = " {format_source}"; - format-source = " {volume}%"; - format-source-muted = ""; - format-icons = { - headphone = ""; - hands-free = ""; - headset = ""; - phone = ""; - portable = ""; - car = ""; - default = [ - "" - "" - "" + "hyprland/window" = { + max-length = 22; + separate-outputs = false; + rewrite = { + "" = " 🙈 No Windows? "; + }; + }; + "memory" = { + interval = 5; + format = " {}%"; + tooltip = true; + }; + "cpu" = { + interval = 5; + format = " {usage:2}%"; + tooltip = true; + }; + "disk" = { + format = " {free}"; + tooltip = true; + }; + "network" = { + format-icons = [ + "󰤯" + "󰤟" + "󰤢" + "󰤥" + "󰤨" ]; + format-ethernet = " {bandwidthDownOctets}"; + format-wifi = "{icon} {signalStrength}%"; + format-disconnected = "󰤮"; + tooltip = false; }; - on-click = "sleep 0.1 && pavucontrol"; - }; - "custom/exit" = { - tooltip = false; - format = ""; - on-click = "sleep 0.1 && wlogout"; - }; - "custom/startmenu" = { - tooltip = false; - format = ""; - # exec = "rofi -show drun"; - on-click = "sleep 0.1 && rofi-launcher"; - }; - "custom/hyprbindings" = { - tooltip = false; - format = "󱕴"; - on-click = "sleep 0.1 && list-hypr-bindings"; - }; - "idle_inhibitor" = { - format = "{icon}"; - format-icons = { - activated = ""; - deactivated = ""; + "tray" = { + spacing = 12; }; - tooltip = "true"; - }; - "custom/notification" = { - tooltip = false; - format = "{icon} {}"; - format-icons = { - notification = ""; - none = ""; - dnd-notification = ""; - dnd-none = ""; - inhibited-notification = ""; - inhibited-none = ""; - dnd-inhibited-notification = ""; - dnd-inhibited-none = ""; + "pulseaudio" = { + format = "{icon} {volume}% {format_source}"; + format-bluetooth = "{volume}% {icon} {format_source}"; + format-bluetooth-muted = " {icon} {format_source}"; + format-muted = " {format_source}"; + format-source = " {volume}%"; + format-source-muted = ""; + format-icons = { + headphone = ""; + hands-free = ""; + headset = ""; + phone = ""; + portable = ""; + car = ""; + default = [ + "" + "" + "" + ]; + }; + on-click = "sleep 0.1 && pavucontrol"; }; - return-type = "json"; - exec-if = "which swaync-client"; - exec = "swaync-client -swb"; - on-click = "sleep 0.1 && task-waybar"; - escape = true; - }; - "battery" = { - states = { - warning = 30; - critical = 15; + "custom/exit" = { + tooltip = false; + format = ""; + on-click = "sleep 0.1 && wlogout"; + }; + "custom/startmenu" = { + tooltip = false; + format = ""; + # exec = "rofi -show drun"; + on-click = "sleep 0.1 && rofi-launcher"; + }; + "custom/hyprbindings" = { + tooltip = false; + format = "󱕴"; + on-click = "sleep 0.1 && list-keybinds"; + }; + "idle_inhibitor" = { + format = "{icon}"; + format-icons = { + activated = ""; + deactivated = ""; + }; + tooltip = "true"; + }; + "custom/notification" = { + tooltip = false; + format = "{icon} {}"; + format-icons = { + notification = ""; + none = ""; + dnd-notification = ""; + dnd-none = ""; + inhibited-notification = ""; + inhibited-none = ""; + dnd-inhibited-notification = ""; + dnd-inhibited-none = ""; + }; + return-type = "json"; + exec-if = "which swaync-client"; + exec = "swaync-client -swb"; + on-click = "sleep 0.1 && task-waybar"; + escape = true; + }; + "battery" = { + states = { + warning = 30; + critical = 15; + }; + format = "{icon} {capacity}%"; + format-charging = "󰂄 {capacity}%"; + format-plugged = "󱘖 {capacity}%"; + format-icons = [ + "󰁺" + "󰁻" + "󰁼" + "󰁽" + "󰁾" + "󰁿" + "󰂀" + "󰂁" + "󰂂" + "󰁹" + ]; + on-click = ""; + tooltip = false; }; - format = "{icon} {capacity}%"; - format-charging = "󰂄 {capacity}%"; - format-plugged = "󱘖 {capacity}%"; - format-icons = [ - "󰁺" - "󰁻" - "󰁼" - "󰁽" - "󰁾" - "󰁿" - "󰂀" - "󰂁" - "󰂂" - "󰁹" - ]; - on-click = ""; - tooltip = false; - }; - } - ]; - style = concatStrings [ - '' - * { - font-family: JetBrainsMono Nerd Font Mono; - font-size: 16px; - border-radius: 0px; - border: none; - min-height: 0px; } - window#waybar { - background: rgba(0,0,0,0); - } - #workspaces { - color: #${config.lib.stylix.colors.base00}; - background: #${config.lib.stylix.colors.base01}; - margin: 4px 4px; - padding: 5px 5px; - border-radius: 16px; - } - #workspaces button { - font-weight: bold; - padding: 0px 5px; - margin: 0px 3px; - border-radius: 16px; - color: #${config.lib.stylix.colors.base00}; - background: linear-gradient(45deg, #${config.lib.stylix.colors.base08}, #${config.lib.stylix.colors.base0D}); - opacity: 0.5; - transition: ${betterTransition}; - } - #workspaces button.active { - font-weight: bold; - padding: 0px 5px; - margin: 0px 3px; - border-radius: 16px; - color: #${config.lib.stylix.colors.base00}; - background: linear-gradient(45deg, #${config.lib.stylix.colors.base08}, #${config.lib.stylix.colors.base0D}); - transition: ${betterTransition}; - opacity: 1.0; - min-width: 40px; - } - #workspaces button:hover { - font-weight: bold; - border-radius: 16px; - color: #${config.lib.stylix.colors.base00}; - background: linear-gradient(45deg, #${config.lib.stylix.colors.base08}, #${config.lib.stylix.colors.base0D}); - opacity: 0.8; - transition: ${betterTransition}; - } - tooltip { - background: #${config.lib.stylix.colors.base00}; - border: 1px solid #${config.lib.stylix.colors.base08}; - border-radius: 12px; - } - tooltip label { - color: #${config.lib.stylix.colors.base08}; - } - #window, #pulseaudio, #cpu, #memory, #idle_inhibitor { - font-weight: bold; - margin: 4px 0px; - margin-left: 7px; - padding: 0px 18px; - background: #${config.lib.stylix.colors.base04}; - color: #${config.lib.stylix.colors.base00}; - border-radius: 24px 10px 24px 10px; - } - #custom-startmenu { - color: #${config.lib.stylix.colors.base0B}; - background: #${config.lib.stylix.colors.base02}; - font-size: 28px; - margin: 0px; - padding: 0px 30px 0px 15px; - border-radius: 0px 0px 40px 0px; - } - #custom-hyprbindings, #network, #battery, - #custom-notification, #tray, #custom-exit { - font-weight: bold; - background: #${config.lib.stylix.colors.base0F}; - color: #${config.lib.stylix.colors.base00}; - margin: 4px 0px; - margin-right: 7px; - border-radius: 10px 24px 10px 24px; - padding: 0px 18px; - } - #clock { - font-weight: bold; - color: #0D0E15; - background: linear-gradient(90deg, #${config.lib.stylix.colors.base0E}, #${config.lib.stylix.colors.base0C}); - margin: 0px; - padding: 0px 15px 0px 30px; - border-radius: 0px 0px 0px 40px; - } - '' - ]; - }; -} + ]; + style = concatStrings [ + '' + * { + font-family: JetBrainsMono Nerd Font Mono; + font-size: 16px; + border-radius: 0px; + border: none; + min-height: 0px; + } + window#waybar { + background: rgba(0,0,0,0); + } + #workspaces { + color: #${config.lib.stylix.colors.base00}; + background: #${config.lib.stylix.colors.base01}; + margin: 4px 4px; + padding: 5px 5px; + border-radius: 16px; + } + #workspaces button { + font-weight: bold; + padding: 0px 5px; + margin: 0px 3px; + border-radius: 16px; + color: #${config.lib.stylix.colors.base00}; + background: linear-gradient(45deg, #${config.lib.stylix.colors.base08}, #${config.lib.stylix.colors.base0D}); + opacity: 0.5; + transition: ${betterTransition}; + } + #workspaces button.active { + font-weight: bold; + padding: 0px 5px; + margin: 0px 3px; + border-radius: 16px; + color: #${config.lib.stylix.colors.base00}; + background: linear-gradient(45deg, #${config.lib.stylix.colors.base08}, #${config.lib.stylix.colors.base0D}); + transition: ${betterTransition}; + opacity: 1.0; + min-width: 40px; + } + #workspaces button:hover { + font-weight: bold; + border-radius: 16px; + color: #${config.lib.stylix.colors.base00}; + background: linear-gradient(45deg, #${config.lib.stylix.colors.base08}, #${config.lib.stylix.colors.base0D}); + opacity: 0.8; + transition: ${betterTransition}; + } + tooltip { + background: #${config.lib.stylix.colors.base00}; + border: 1px solid #${config.lib.stylix.colors.base08}; + border-radius: 12px; + } + tooltip label { + color: #${config.lib.stylix.colors.base08}; + } + #window, #pulseaudio, #cpu, #memory, #idle_inhibitor { + font-weight: bold; + margin: 4px 0px; + margin-left: 7px; + padding: 0px 18px; + background: #${config.lib.stylix.colors.base04}; + color: #${config.lib.stylix.colors.base00}; + border-radius: 24px 10px 24px 10px; + } + #custom-startmenu { + color: #${config.lib.stylix.colors.base0B}; + background: #${config.lib.stylix.colors.base02}; + font-size: 28px; + margin: 0px; + padding: 0px 30px 0px 15px; + border-radius: 0px 0px 40px 0px; + } + #custom-hyprbindings, #network, #battery, + #custom-notification, #tray, #custom-exit { + font-weight: bold; + background: #${config.lib.stylix.colors.base0F}; + color: #${config.lib.stylix.colors.base00}; + margin: 4px 0px; + margin-right: 7px; + border-radius: 10px 24px 10px 24px; + padding: 0px 18px; + } + #clock { + font-weight: bold; + color: #0D0E15; + background: linear-gradient(90deg, #${config.lib.stylix.colors.base0E}, #${config.lib.stylix.colors.base0C}); + margin: 0px; + padding: 0px 15px 0px 30px; + border-radius: 0px 0px 0px 40px; + } + '' + ]; + }; + }