summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2024-08-24 21:18:45 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2024-08-24 21:18:45 +0200
commit7b8ace725486a3c5072a1da65d9fb5876b05efe6 (patch)
tree9b09d2fe33dad0ba06e940e62d8384d344b8b393
parent3b97bf86dd0a510bb196eac5230bc3e03240b91d (diff)
downloadnixos-7b8ace725486a3c5072a1da65d9fb5876b05efe6.tar
nixos-7b8ace725486a3c5072a1da65d9fb5876b05efe6.tar.gz
nixos-7b8ace725486a3c5072a1da65d9fb5876b05efe6.tar.bz2
nixos-7b8ace725486a3c5072a1da65d9fb5876b05efe6.tar.xz
nixos-7b8ace725486a3c5072a1da65d9fb5876b05efe6.zip
...
-rw-r--r--accounts/gkleen@sif/hyprland.nix66
1 files changed, 66 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/hyprland.nix b/accounts/gkleen@sif/hyprland.nix
index 052f35b0..d4105952 100644
--- a/accounts/gkleen@sif/hyprland.nix
+++ b/accounts/gkleen@sif/hyprland.nix
@@ -256,6 +256,72 @@ in {
256 [[ -n "$FUZZEL_RES" ]] || exit 1 256 [[ -n "$FUZZEL_RES" ]] || exit 1
257 wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste 257 wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste
258 ''}" 258 ''}"
259 "$mainMod, B, exec, ${pkgs.writeShellScript "bring" ''
260 export PATH="${lib.makeBinPath (with pkgs; [ cfg.programs.fuzzel.package gawk gojq cfg.wayland.windowManager.hyprland.package ])}:$PATH"
261
262 state="$(hyprctl -j clients)"
263 active_window="$(hyprctl -j activewindow)"
264 active_workspace="$(hyprctl -j activeworkspace | gojq -r '.id')"
265
266 current_addr="$(echo "$active_window" | gojq -r '.address')"
267
268 window="$(echo "$state" |
269 gojq -r '.[] | select(.workspace.id == '"$active_workspace"') | select(.monitor != -1 ) | "\(.title)\t\(.address)"' |
270 fuzzel --log-level=warning --dmenu)"
271
272 addr="$(echo "$window" | awk -F $'\t' '{print $2}')"
273
274 if [[ "$addr" = "$current_addr" ]]; then
275 exit 0
276 fi
277
278 fullscreen_on_same_ws="$(echo "$state" | gojq -r '.[] | select(.fullscreen == true) | select(.workspace.id == '"$active_workspace"') | .address')"
279
280 if [[ "$window" != "" ]]; then
281 if [[ "$fullscreen_on_same_ws" == "" ]]; then
282 hyprctl dispatch focuswindow address:"''${addr}"
283 else
284 # If we want to focus app_A and app_B is fullscreen on the same workspace,
285 # app_A will get focus, but app_B will remain on top.
286 # This monstrosity is to make sure app_A will end up on top instead.
287 # XXX: doesn't handle fullscreen 0, but I don't care.
288 hyprctl --batch "dispatch focuswindow address:''${fullscreen_on_same_ws}; dispatch fullscreen 1; dispatch focuswindow address:''${addr}; dispatch fullscreen 1"
289 fi
290 fi
291 ''}"
292 "$mainMod SHIFT, B, exec, ${pkgs.writeShellScript "bring" ''
293 export PATH="${lib.makeBinPath (with pkgs; [ cfg.programs.fuzzel.package gawk gojq cfg.wayland.windowManager.hyprland.package ])}:$PATH"
294
295 state="$(hyprctl -j clients)"
296 active_window="$(hyprctl -j activewindow)"
297
298 current_addr="$(echo "$active_window" | gojq -r '.address')"
299
300 window="$(echo "$state" |
301 gojq -r '.[] | select(.monitor != -1 ) | "\(.title)\t\(.workspace.name)\t\(.address)"' |
302 fuzzel --log-level=warning --dmenu)"
303
304 addr="$(echo "$window" | awk -F $'\t' '{print $3}')"
305 ws="$(echo "$window" | awk -F $'\t' '{print $2}')"
306
307 if [[ "$addr" = "$current_addr" ]]; then
308 exit 0
309 fi
310
311 fullscreen_on_same_ws="$(echo "$state" | gojq -r ".[] | select(.fullscreen == true) | select(.workspace.name == \"$ws\") | .address")"
312
313 if [[ "$window" != "" ]]; then
314 if [[ "$fullscreen_on_same_ws" == "" ]]; then
315 hyprctl dispatch focuswindow address:"''${addr}"
316 else
317 # If we want to focus app_A and app_B is fullscreen on the same workspace,
318 # app_A will get focus, but app_B will remain on top.
319 # This monstrosity is to make sure app_A will end up on top instead.
320 # XXX: doesn't handle fullscreen 0, but I don't care.
321 hyprctl --batch "dispatch focuswindow address:''${fullscreen_on_same_ws}; dispatch fullscreen 1; dispatch focuswindow address:''${addr}; dispatch fullscreen 1"
322 fi
323 fi
324 ''}"
259 325
260 "$mainMod CTRL, return, togglespecialworkspace, term" 326 "$mainMod CTRL, return, togglespecialworkspace, term"
261 "$mainMod CTRL, e, togglespecialworkspace, edit" 327 "$mainMod CTRL, e, togglespecialworkspace, edit"