hypr: add tofi launcher and custom window switch script
This commit is contained in:
parent
818562d6a2
commit
d358fb2ec4
2 changed files with 39 additions and 1 deletions
|
@ -32,7 +32,7 @@ gsettings set org.gnome.desktop.interface cursor-size 24
|
||||||
# Set programs that you use
|
# Set programs that you use
|
||||||
$terminal = kitty
|
$terminal = kitty
|
||||||
$fileManager = nemo
|
$fileManager = nemo
|
||||||
$menu = wofi -a --show drun --allow-images
|
$menu = tofi-drun --drun-launch=true
|
||||||
|
|
||||||
# Some default env vars.
|
# Some default env vars.
|
||||||
env = XCURSOR_SIZE,24
|
env = XCURSOR_SIZE,24
|
||||||
|
@ -152,6 +152,7 @@ bind = $mainMod, M, exit,
|
||||||
bind = $mainMod, E, exec, $fileManager
|
bind = $mainMod, E, exec, $fileManager
|
||||||
bind = $mainMod, V, togglefloating,
|
bind = $mainMod, V, togglefloating,
|
||||||
bind = ALT, SPACE , exec, $menu
|
bind = ALT, SPACE , exec, $menu
|
||||||
|
bind = ALT, B, exec, $HOME/dotfiles/scripts/third-party/tofi_window_switch.sh
|
||||||
bind = $mainMod, P, pseudo, # dwindle
|
bind = $mainMod, P, pseudo, # dwindle
|
||||||
bind = $mainMod, T, togglesplit, # dwindle
|
bind = $mainMod, T, togglesplit, # dwindle
|
||||||
bind = $mainMod, F, fullscreen, 1
|
bind = $mainMod, F, fullscreen, 1
|
||||||
|
|
37
scripts/third-party/tofi_window_switch.sh
vendored
Executable file
37
scripts/third-party/tofi_window_switch.sh
vendored
Executable file
|
@ -0,0 +1,37 @@
|
||||||
|
# Source = https://github.com/hyprwm/Hyprland/discussions/830
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# rofi -show window for Hyprland, basically
|
||||||
|
|
||||||
|
state="$(hyprctl -j clients)"
|
||||||
|
active_window="$(hyprctl -j activewindow)"
|
||||||
|
|
||||||
|
current_addr="$(echo "$active_window" | gojq -r '.address')"
|
||||||
|
|
||||||
|
window="$(echo "$state" |
|
||||||
|
gojq -r '.[] | select(.monitor != -1 ) | "\(.address) \(.workspace.name) \(.title)"' |
|
||||||
|
sed "s|$current_addr|focused ->|" |
|
||||||
|
sort -r |
|
||||||
|
tofi --fuzzy-match true)"
|
||||||
|
|
||||||
|
addr="$(echo "$window" | awk '{print $1}')"
|
||||||
|
ws="$(echo "$window" | awk '{print $2}')"
|
||||||
|
|
||||||
|
if [[ "$addr" =~ focused* ]]; then
|
||||||
|
echo 'already focused, exiting'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
fullscreen_on_same_ws="$(echo "$state" | gojq -r ".[] | select(.fullscreen == true) | select(.workspace.name == \"$ws\") | .address")"
|
||||||
|
|
||||||
|
if [[ "$window" != "" ]]; then
|
||||||
|
if [[ "$fullscreen_on_same_ws" == "" ]]; then
|
||||||
|
hyprctl dispatch focuswindow address:${addr}
|
||||||
|
else
|
||||||
|
# If we want to focus app_A and app_B is fullscreen on the same workspace,
|
||||||
|
# app_A will get focus, but app_B will remain on top.
|
||||||
|
# This monstrosity is to make sure app_A will end up on top instead.
|
||||||
|
# XXX: doesn't handle fullscreen 0, but I don't care.
|
||||||
|
notify-send 'Complex switch' "$window"
|
||||||
|
hyprctl --batch "dispatch focuswindow address:${fullscreen_on_same_ws}; dispatch fullscreen 1; dispatch focuswindow address:${addr}; dispatch fullscreen 1"
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
Add table
Reference in a new issue