From 8294dbdd0b56e21bb1699069097117c6d0eef225 Mon Sep 17 00:00:00 2001 From: ahuston-0 Date: Thu, 13 Mar 2025 17:43:41 -0400 Subject: [PATCH] add waybar --- shell.nix | 4 +++ systems/artemision/programs.nix | 1 + users/alice/home.nix | 1 + users/alice/home/hypr/default.nix | 1 + users/alice/home/hypr/hyprland.conf | 7 +++++ users/alice/home/hypr/show-hide.sh | 25 ++++++++++++++++++ users/alice/home/waybar.json | 40 +++++++++++++++++++++++++++++ users/alice/home/waybar.nix | 2 +- users/alice/non-server.nix | 1 + 9 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 users/alice/home/hypr/show-hide.sh create mode 100644 users/alice/home/waybar.json diff --git a/shell.nix b/shell.nix index d39ff96..604d119 100644 --- a/shell.nix +++ b/shell.nix @@ -45,6 +45,10 @@ forEachSystem ( treefmt statix nixfmt-rfc-style + jsonfmt + mdformat + shfmt + yamlfmt ]; }; in diff --git a/systems/artemision/programs.nix b/systems/artemision/programs.nix index 9366934..217e5cc 100644 --- a/systems/artemision/programs.nix +++ b/systems/artemision/programs.nix @@ -42,6 +42,7 @@ kitty kubectl kubernetes-helm + libreoffice-fresh libtool lsof lynis diff --git a/users/alice/home.nix b/users/alice/home.nix index 237ef68..330cae1 100644 --- a/users/alice/home.nix +++ b/users/alice/home.nix @@ -16,6 +16,7 @@ ./home/gammastep.nix ./home/doom ./home/hypr + ./home/waybar.nix ./non-server.nix ]; diff --git a/users/alice/home/hypr/default.nix b/users/alice/home/hypr/default.nix index 04280e6..6fbb2ed 100644 --- a/users/alice/home/hypr/default.nix +++ b/users/alice/home/hypr/default.nix @@ -8,6 +8,7 @@ { xdg.configFile = { "hypr/hyprland.conf".source = ./hyprland.conf; + "hypr/show-hide.sh".source = ./show-hide.sh; }; imports = [ diff --git a/users/alice/home/hypr/hyprland.conf b/users/alice/home/hypr/hyprland.conf index 095df5e..a5dd1ff 100644 --- a/users/alice/home/hypr/hyprland.conf +++ b/users/alice/home/hypr/hyprland.conf @@ -22,6 +22,9 @@ monitor=,preferred,auto,auto # exec-once = waybar & hyprpaper & firefox exec-once = wired & +exec-once = wired +exec-once = systemctl --user start polkit-gnome-authentication-agent-1.service + # Source a file (multi-file configs) # source = ~/.config/hypr/myColors.conf @@ -207,3 +210,7 @@ bind = $mainMod, P, exec, bwm # lock screen bind = $mainMod, L, exec, loginctl lock-session +# hide active window +bind = $mainMod,H,exec,/home/alice/config/hypr/hide_unhide_window.sh h +# show hide window +bind = $mainMod,I,exec,/home/alice/config/hypr/hide_unhide_window.sh s diff --git a/users/alice/home/hypr/show-hide.sh b/users/alice/home/hypr/show-hide.sh new file mode 100644 index 0000000..ecbf6c1 --- /dev/null +++ b/users/alice/home/hypr/show-hide.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +stack_file="/tmp/hide_window_pid_stack.txt" + +function hide_window() { + pid=$(hyprctl activewindow -j | jq '.pid') + hyprctl dispatch movetoworkspacesilent "88,pid:$pid" + echo "$pid" >>$stack_file +} + +function show_window() { + pid=$(tail -1 $stack_file && sed -i '$d' $stack_file) + [ -z "$pid" ] && exit + + current_workspace=$(hyprctl activeworkspace -j | jq '.id') + hyprctl dispatch movetoworkspacesilent "$current_workspace,pid:$pid" +} + +if [ -n "$1" ]; then + if [ "$1" == "h" ]; then + hide_window >>/dev/null + else + show_window >>/dev/null + fi +fi diff --git a/users/alice/home/waybar.json b/users/alice/home/waybar.json new file mode 100644 index 0000000..759372e --- /dev/null +++ b/users/alice/home/waybar.json @@ -0,0 +1,40 @@ +[ + { + "height": 20, + "layer": "top", + "position": "top", + "output": [ + "eDP-2", + "eDP-1", + "HDMI-0", + "DP-0" + ], + "hyprland/workspaces": { + "active-only": true, + "all-outputs": false, + "show-special": true, + "move-to-monitor": true, + "format": "{icon} {windows}", + "format-window-separator": " ", + "format-icons": { + "1": "󰎤", + "2": "󰎧", + "3": "󰎪", + "default": "", + "empty": "󱓼", + "urgent": "󱨇" + }, + "persistent-workspaces": { + "1": "HDMI-0" + }, + "on-scroll-down": "hyprctl dispatch workspace e-1", + "on-scroll-up": "hyprctl dispatch workspace e+1", + "window-rewrite": { + "title": "" + }, + "window-rewrite-default": "", + "window-rewrite-separator": " ", + "sort-by": "number" + } + } +] diff --git a/users/alice/home/waybar.nix b/users/alice/home/waybar.nix index 77d6d11..fa9e333 100644 --- a/users/alice/home/waybar.nix +++ b/users/alice/home/waybar.nix @@ -2,6 +2,6 @@ lib.mkIf (!machineConfig.server) { programs.waybar = { enable = true; - #settings = builtins.fromJSON (import ./waybar.json); + settings = builtins.fromJSON (builtins.readFile ./waybar.json); }; } diff --git a/users/alice/non-server.nix b/users/alice/non-server.nix index aa7ab1d..891cac2 100644 --- a/users/alice/non-server.nix +++ b/users/alice/non-server.nix @@ -64,5 +64,6 @@ zathura obsidian libreoffice-qt-fresh + wlr-randr ]; }