From 542fe9eb4bb1098b2d90660e23b319d84fdb568d Mon Sep 17 00:00:00 2001 From: Gabriel Ebner Date: Mon, 2 May 2022 18:55:32 +0200 Subject: [PATCH] sway: use rofi --- config/sway/config.m4 | 8 ++++---- my-rofi-pass | 6 +++++- rofi-windows | 21 +++++++++++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100755 rofi-windows diff --git a/config/sway/config.m4 b/config/sway/config.m4 index a0d45d3..52517e1 100644 --- a/config/sway/config.m4 +++ b/config/sway/config.m4 @@ -24,10 +24,10 @@ bindsym $mod+Return exec alacritty bindsym $mod+Shift+q kill -bindsym $mod+d exec wofi --show run -i -bindsym $mod+Tab exec ~/etc/wofi-windows -bindsym $mod+shift+Tab exec ~/etc/wofi-windows movehere -bindsym $mod+p exec ~/etc/wofi-pass +bindsym $mod+d exec rofi -show run +bindsym $mod+Tab exec ~/etc/rofi-windows +bindsym $mod+shift+Tab exec ~/etc/rofi-windows movehere +bindsym $mod+p exec ~/etc/my-rofi-pass define([dir_bind], [ bindsym $mod+$2 focus $1 diff --git a/my-rofi-pass b/my-rofi-pass index b2b52f6..dfc02b6 100755 --- a/my-rofi-pass +++ b/my-rofi-pass @@ -13,7 +13,11 @@ list_accounts_beginning_with_blank_page() { } do_type() { - echo -n "$1" | xdotool type --delay=12 --file=- + if [ -n "$WAYLAND_DISPLAY" ]; then + echo -n "$1" | wtype -s 100 -d 50 - + else + echo -n "$1" | xdotool type --delay=12 --file=- + fi } get_passwd() { diff --git a/rofi-windows b/rofi-windows new file mode 100755 index 0000000..dafff79 --- /dev/null +++ b/rofi-windows @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# Get available windows +windows=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?)|recurse(.floating_nodes[]?)|select(.type=="con"),select(.type=="floating_con")|(.id|tostring)+" "+.app_id+": "+.name') + +case "$1" in + movehere) + cmd="move workspace current" + prompt="move window here" + ;; + *) + cmd="focus" + prompt="go to window" + ;; +esac + +# Select window with rofi +selected=$(echo "$windows" | rofi -dmenu -p "$prompt" | awk '{print $1}') + +# Tell sway to frobnicate said window +swaymsg "[con_id=$selected]" $cmd