hyprland: moved select-window script to rofi.nix
This commit is contained in:
parent
50d83811ba
commit
9fa75cd522
|
@ -1,11 +1,6 @@
|
||||||
{ lib, pkgs, config, ... }:
|
{ lib, pkgs, config, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.profile.hyprland;
|
cfg = config.profile.hyprland;
|
||||||
select-window = rec {
|
|
||||||
filename = "select-window.sh";
|
|
||||||
script = pkgs.writeScriptBin filename (builtins.readFile (./scripts/search-window.sh));
|
|
||||||
path = "${script}/bin/${filename}";
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
|
@ -85,7 +80,6 @@ in
|
||||||
"$mod, E, exec, thunar"
|
"$mod, E, exec, thunar"
|
||||||
"$mod, B, exec, microsoft-edge"
|
"$mod, B, exec, microsoft-edge"
|
||||||
"$mod, BackSpace, exec, wlogout"
|
"$mod, BackSpace, exec, wlogout"
|
||||||
''$mod, F, exec, ${select-window.path}''
|
|
||||||
"$mod, S, exec, foot ssh homeserver@vpn.tigor.web.id"
|
"$mod, S, exec, foot ssh homeserver@vpn.tigor.web.id"
|
||||||
|
|
||||||
# Workspaces
|
# Workspaces
|
||||||
|
|
|
@ -1,11 +1,49 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.profile.hyprland;
|
cfg = config.profile.hyprland;
|
||||||
|
inherit (lib.meta) getExe;
|
||||||
|
selectWindowScript = pkgs.writeShellScriptBin ''select-window.sh'' /*sh*/ ''
|
||||||
|
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)"' |
|
||||||
|
grep -v "scratch_term" |
|
||||||
|
sed "s|$current_addr|focused ->|" |
|
||||||
|
sort -r |
|
||||||
|
rofi -dmenu -i -matching fuzzy)"
|
||||||
|
|
||||||
|
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
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
home.packages = [
|
home.packages = with pkgs; [
|
||||||
pkgs.rofi-wayland
|
rofi-wayland
|
||||||
|
gojq
|
||||||
];
|
];
|
||||||
|
|
||||||
home.file.".config/rofi" = {
|
home.file.".config/rofi" = {
|
||||||
|
@ -15,6 +53,7 @@ in
|
||||||
|
|
||||||
wayland.windowManager.hyprland.settings.bind = [
|
wayland.windowManager.hyprland.settings.bind = [
|
||||||
"$mod, D, exec, rofi -show drun -replace -i"
|
"$mod, D, exec, rofi -show drun -replace -i"
|
||||||
|
"$mod, F, exec, ${getExe selectWindowScript}"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
#/usr/bin/env bash
|
|
||||||
# rofi -show window for Hyprland, basically
|
|
||||||
#
|
|
||||||
# Requires gojq and rofi to be on PATH.
|
|
||||||
|
|
||||||
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)"' |
|
|
||||||
grep -v "scratch_term" |
|
|
||||||
sed "s|$current_addr|focused ->|" |
|
|
||||||
sort -r |
|
|
||||||
rofi -dmenu -i -matching fuzzy)"
|
|
||||||
|
|
||||||
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…
Reference in a new issue