Add gestures for switching windows with rofi
This commit is contained in:
parent
d570e288e7
commit
cad56ad12f
3 changed files with 49 additions and 1 deletions
|
@ -1,7 +1,17 @@
|
||||||
{ pkgs, config, lib, ... }:
|
{ pkgs, config, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
discord = pkgs.armcord;
|
discord = pkgs.armcord.overrideAttrs (attrs: {
|
||||||
|
postInstall = ''
|
||||||
|
# Wrap the startup command
|
||||||
|
makeWrapper $out/opt/ArmCord/armcord $out/bin/armcord \
|
||||||
|
"''${gappsWrapperArgs[@]}" \
|
||||||
|
--prefix XDG_DATA_DIRS : "${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}/" \
|
||||||
|
--add-flags "--ozone-platform=wayland --enable-features=UseOzonePlatform --enable-features=WebRTCPipeWireCapturer" \
|
||||||
|
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath attrs.buildInputs}" \
|
||||||
|
--suffix PATH : ${lib.makeBinPath [ pkgs.xdg-utils ]}
|
||||||
|
'';
|
||||||
|
});
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
|
|
@ -203,6 +203,7 @@ in
|
||||||
"exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'";
|
"exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'";
|
||||||
# Launcher
|
# Launcher
|
||||||
"${mod}+space" = "exec rofi -show drun";
|
"${mod}+space" = "exec rofi -show drun";
|
||||||
|
"${mod}+tab" = "exec ${./rofi-window.py}";
|
||||||
} // {
|
} // {
|
||||||
## Splits
|
## Splits
|
||||||
"${mod}+v" = "split v";
|
"${mod}+v" = "split v";
|
||||||
|
@ -325,6 +326,11 @@ in
|
||||||
(if cfg.enableLaptopBars then ''
|
(if cfg.enableLaptopBars then ''
|
||||||
# Lock screen on lid close
|
# Lock screen on lid close
|
||||||
bindswitch lid:off exec ${cfg.lockCmd}
|
bindswitch lid:off exec ${cfg.lockCmd}
|
||||||
|
|
||||||
|
# Gesture bindings
|
||||||
|
bindgesture swipe:3:right workspace prev
|
||||||
|
bindgesture swipe:3:left workspace next
|
||||||
|
bindgesture swipe:3:up exec ${./rofi-window.py}
|
||||||
'' else "") + ''
|
'' else "") + ''
|
||||||
## swayfx stuff
|
## swayfx stuff
|
||||||
# Rounded corners
|
# Rounded corners
|
||||||
|
|
32
home/modules/programs/my-sway/rofi-window.py
Executable file
32
home/modules/programs/my-sway/rofi-window.py
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
import json
|
||||||
|
|
||||||
|
treeP = subprocess.run(["swaymsg", "-t", "get_tree"], stdout=subprocess.PIPE, text=True, check=True)
|
||||||
|
|
||||||
|
tree = json.loads(treeP.stdout)
|
||||||
|
|
||||||
|
def get_instance(node):
|
||||||
|
if 'app_id' in node and node['app_id'] != None:
|
||||||
|
return node['app_id']
|
||||||
|
elif 'window_properties' in node:
|
||||||
|
return node['window_properties']['class']
|
||||||
|
return "??"
|
||||||
|
|
||||||
|
def get_apps(node):
|
||||||
|
if 'pid' in node:
|
||||||
|
return [("[%s] %s"%(get_instance(node), node['name']), node['pid'])]
|
||||||
|
else:
|
||||||
|
return (app for n in node['nodes'] for app in get_apps(n))
|
||||||
|
|
||||||
|
apps = dict(get_apps(tree))
|
||||||
|
|
||||||
|
keys = '\n'.join(apps.keys())
|
||||||
|
|
||||||
|
rofi = subprocess.run(["rofi", "-dmenu", "-i", "-p", "Switch to Window"], stdout=subprocess.PIPE, text=True, check=True, input=keys)
|
||||||
|
|
||||||
|
selected = rofi.stdout.strip()
|
||||||
|
|
||||||
|
if selected in apps:
|
||||||
|
subprocess.run(["swaymsg", "[pid = %d]" % apps[selected], "focus"], check=True)
|
Loading…
Add table
Reference in a new issue