From 84c8f5097dbf171815c4cc7d930aa4dee8954e17 Mon Sep 17 00:00:00 2001 From: kiana-S Date: Tue, 3 Jan 2023 22:14:05 -0500 Subject: [PATCH] Fix bugs with rofi workspace modes --- home-manager/wayland/rofi/config.rasi | 4 ++-- home-manager/wayland/rofi/window.sh | 14 -------------- home-manager/wayland/rofi/workspace.sh | 12 ++++-------- home-manager/wayland/rofi/workspacemove.sh | 8 ++++++++ home-manager/wayland/sway.nix | 4 ++-- 5 files changed, 16 insertions(+), 26 deletions(-) delete mode 100755 home-manager/wayland/rofi/window.sh create mode 100755 home-manager/wayland/rofi/workspacemove.sh diff --git a/home-manager/wayland/rofi/config.rasi b/home-manager/wayland/rofi/config.rasi index 593c9de..092fc7a 100644 --- a/home-manager/wayland/rofi/config.rasi +++ b/home-manager/wayland/rofi/config.rasi @@ -1,6 +1,6 @@ configuration { cycle: false; - modi: "drun,run,window:~/.config/rofi/window.sh,workspace:~/.config/rofi/workspace.sh"; + modi: "drun,run,workspace:~/.config/rofi/workspace.sh,workspacemove:~/.config/rofi/workspacemove.sh"; font: "JetBrainsMono Nerd Font 14"; location: 0; terminal: "alacritty"; @@ -11,8 +11,8 @@ configuration { drun-display-format: "{name}"; display-drun: "  Apps "; display-run: "  Run "; - display-window: " 﩯 Window "; display-workspace: "  Workspace "; + display-workspacemove: "  Move to Workspace "; } @theme "tokyonight" diff --git a/home-manager/wayland/rofi/window.sh b/home-manager/wayland/rofi/window.sh deleted file mode 100755 index 2b658d3..0000000 --- a/home-manager/wayland/rofi/window.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -if [ $# -ne 0 ]; then - id=$(echo "$@" | cut -d ' ' -f1) - swaymsg "[con_id=$id]" focus - - # Hack to get around weird bug - pkill rofi - exit 0 -fi - -swaymsg -t get_tree | - jq -r '.nodes[].nodes[] | if .nodes then [recurse(.nodes[])] else [] end + .floating_nodes | - .[] | select(.nodes==[]) | ((.id | tostring) + " " + .name)' diff --git a/home-manager/wayland/rofi/workspace.sh b/home-manager/wayland/rofi/workspace.sh index d4e491d..707441e 100755 --- a/home-manager/wayland/rofi/workspace.sh +++ b/home-manager/wayland/rofi/workspace.sh @@ -1,12 +1,8 @@ #!/usr/bin/env bash if [ $# -ne 0 ]; then - swaymsg workspace "$@" - - # Hack to get around weird bug - pkill rofi - exit 0 + swaymsg workspace "$@" > /dev/null +else + swaymsg -t get_workspaces | + jq -r 'map(.name) + ["10:browser","20:terminal","30:code","40:files","50:discord","60:settings"] | unique | .[]' fi - -swaymsg -t get_workspaces | - jq -r '.[].name' diff --git a/home-manager/wayland/rofi/workspacemove.sh b/home-manager/wayland/rofi/workspacemove.sh new file mode 100755 index 0000000..1a68a01 --- /dev/null +++ b/home-manager/wayland/rofi/workspacemove.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +if [ $# -ne 0 ]; then + swaymsg move container to workspace "$@" > /dev/null +else + swaymsg -t get_workspaces | + jq -r 'map(.name) + ["10:browser","20:terminal","30:code","40:files","50:discord","60:settings"] | unique | .[]' +fi diff --git a/home-manager/wayland/sway.nix b/home-manager/wayland/sway.nix index 1f36b99..bde8bb2 100644 --- a/home-manager/wayland/sway.nix +++ b/home-manager/wayland/sway.nix @@ -76,8 +76,8 @@ in { filename = ''~/Pictures/$(date +%Y-%m-%d_%H-%M-%S).png''; in pkgs.lib.mkOptionDefault { "${modifier}+Shift+d" = "exec rofi -show run -config ~/.config/rofi/noicons.rasi"; - "${modifier}+w" = "exec rofi -show window -config ~/.config/rofi/noicons.rasi"; - "${modifier}+Shift+w" = "exec rofi -show workspace -config ~/.config/rofi/noicons.rasi"; + "${modifier}+w" = "exec rofi -show workspace -config ~/.config/rofi/noicons.rasi"; + "${modifier}+Shift+w" = "exec rofi -show workspacemove -config ~/.config/rofi/noicons.rasi"; "${modifier}+t" = "layout tabbed"; "${modifier}+Shift+m" = "exec swaylock";