feat: switch from rofi to wofi
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# vi: ft=conf
|
||||
|
||||
# Default config for sway
|
||||
#
|
||||
# Copy this to ~/.config/sway/config and edit it to your liking.
|
||||
@@ -8,19 +10,27 @@
|
||||
#
|
||||
# Logo key. Use Mod1 for Alt.
|
||||
set $mod Mod4
|
||||
|
||||
# Home row direction keys, like vim
|
||||
set $left h
|
||||
set $down j
|
||||
set $up k
|
||||
set $right l
|
||||
# Your preferred terminal emulator
|
||||
set $term alacritty
|
||||
|
||||
set $menu "rofi -combi-modi window,drun,ssh,run -show combi -show-icons"
|
||||
set $powermenu "rofi -show p -modi p:~/.dotfiles/configs/rofi/rofi-power-menu -lines 6"
|
||||
# Some menus
|
||||
set $wofi_scripts ~/.config/wofi
|
||||
set $quickmenu wofi --show drun
|
||||
|
||||
# Screenshot section
|
||||
set $screenclip slurp | grim -g - ~/Pictures/Screenshots/scrn-$(date +"%Y-%m-%d-%H-%M-%S").png
|
||||
set $screenshot grim ~/Pictures/screenshots/scrn-$(date +"%Y-%m-%d-%H-%M-%S").png
|
||||
set $windowshot swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | $screenclip
|
||||
|
||||
# Default Programs
|
||||
set $term alacritty
|
||||
set $explorer nautilus
|
||||
set $config_editor ~/.config/sway/config_editor.sh
|
||||
set $settings gnome-control-center
|
||||
set $toggle_layout ~/.config/sway/toggle_layout.sh
|
||||
set $toggle_gaps ~/.config/sway/toggle_gaps.sh
|
||||
@@ -80,13 +90,15 @@ output * bg `find ~/.customization/background -type f | shuf -n 1` fill
|
||||
#
|
||||
# Basics:
|
||||
#
|
||||
bindsym $mod+q exec $powermenu
|
||||
bindsym $mod+d exec $quickmenu
|
||||
bindsym $mod+q kill
|
||||
bindsym $mod+Shift+q exec $wofi_scripts/wofi-power-menu.sh
|
||||
bindsym $mod+Return exec $term
|
||||
bindsym $mod+Shift+q kill
|
||||
bindsym $mod+d exec $menu
|
||||
bindsym $mod+e exec nautilus
|
||||
|
||||
# Drag and resize floating windows with mouse right/left drag
|
||||
bindsym $mod+e exec $explorer
|
||||
bindsym $mod+Comma exec $settings
|
||||
bindsym $mod+Shift+Comma exec $config_editor
|
||||
|
||||
# Drag and resize floating windows with mouse right/left drag
|
||||
floating_modifier $mod normal
|
||||
|
||||
# Reload the configuration file
|
||||
@@ -181,7 +193,6 @@ output * bg `find ~/.customization/background -type f | shuf -n 1` fill
|
||||
# Switch the current container between different layout styles
|
||||
bindsym $mod+w exec $toggle_layout
|
||||
bindsym $mod+g exec $toggle_gaps
|
||||
bindsym $mod+Comma exec $settings
|
||||
|
||||
# Make the current focus fullscreen
|
||||
bindsym $mod+f fullscreen
|
||||
@@ -204,7 +215,7 @@ output * bg `find ~/.customization/background -type f | shuf -n 1` fill
|
||||
bindsym $mod+s exec $screenshot
|
||||
|
||||
|
||||
bindsym Alt+Tab exec rofi -show window -modi window
|
||||
bindsym $mod+Tab exec $wofi_scripts/sway-select-window.sh
|
||||
#
|
||||
# Scratchpad:
|
||||
#
|
||||
|
2
configs/sway/config_editor.sh
Executable file
2
configs/sway/config_editor.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/zsh
|
||||
alacritty -e zsh -c "/home/jim/.asdf/shims/nvim ~/.dotfiles"
|
@@ -1,161 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Swytch is a script providing a window switcher for sway using rofi, awk and jq.
|
||||
# The script is based on:
|
||||
# https://www.reddit.com/r/swaywm/comments/aolf3u/quick_script_for_rofi_alttabbing_window_switcher/
|
||||
# Copyright (C) 2019 Björn Sonnenschein
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
# todo: first, query all existing workspaces from sway and build color dict, so that
|
||||
# all workspaces always get the same color, even if no windows at some workspace in between exists.
|
||||
|
||||
# obtain command to execute with swaymsg for selected window
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
command_=focus
|
||||
else
|
||||
command_=$1
|
||||
fi
|
||||
|
||||
|
||||
# Obtain the avaliable windows' workspaces, names and IDs as strings
|
||||
mapfile -t windows < <(
|
||||
swaymsg -t get_tree | jq -r '[
|
||||
recurse(.nodes[]?)
|
||||
|recurse(.floating_nodes[]?)
|
||||
|select(.type=="workspace")
|
||||
| . as $workspace | recurse(.nodes[]?)
|
||||
|select(.type=="con" and .name!=null)
|
||||
|{workspace: $workspace.name, name: .name, id: .id, focused: .focused, app_id: .app_id, class: .window_properties.class}]
|
||||
|sort_by(.workspace, .name)[]
|
||||
|.workspace + if .focused then "* " else " " end + if .app_id then .app_id else .class end + " - " + .name + " " + (.id|tostring)'
|
||||
)
|
||||
|
||||
# Obtain window list index of last active window
|
||||
# todo
|
||||
index_window_last_active=0
|
||||
for index_window in "${!windows[@]}"
|
||||
do
|
||||
window="${windows[$index_window]}"
|
||||
# obtain index of the active window
|
||||
if [ "${window:1:1}" == "*" ]
|
||||
then
|
||||
index_window_last_active=$(($index_window))
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# get window list to display
|
||||
windows_separators=()
|
||||
colors=(blue green orange red magenta)
|
||||
workspace_previous=''
|
||||
index_workspace_active=0
|
||||
num_separators=0
|
||||
index_color=0
|
||||
bold=-1
|
||||
for index_window in "${!windows[@]}"
|
||||
do
|
||||
window="${windows[$index_window]}"
|
||||
# todo: consider arbitraty workspace name length by separating by space instead of simply taking first argument.
|
||||
workspace=${window:0:1}
|
||||
# obtain index of the active window
|
||||
if [ "${window:1:1}" == "*" ]
|
||||
then
|
||||
index_workspace_active=$(($index_window))
|
||||
fi
|
||||
|
||||
# if window has different workspace than previous, use next color. Cycle through colors
|
||||
if [ "$workspace" != "$workspace_previous" ] && [ ! -z "$workspace_previous" ]
|
||||
then
|
||||
index_color=$index_color+1
|
||||
fi
|
||||
|
||||
if (($index_color == ${#colors[@]}))
|
||||
then
|
||||
index_color=0
|
||||
fi
|
||||
if (( $bold == 1))
|
||||
then
|
||||
windows_separators+=("<b><span foreground=\"${colors[$index_color]}\">[${workspace}]</span>${window:1}</b>")
|
||||
else
|
||||
windows_separators+=("<span foreground=\"${colors[$index_color]}\">[${workspace}]</span>${window:1}")
|
||||
fi
|
||||
workspace_previous=$workspace
|
||||
done
|
||||
|
||||
# TODO: this breaks when using i3. Comment out for now. Should only execute if running sway.
|
||||
# Select window with rofi, obtaining ID of selected window
|
||||
#screen_pos=$(swaymsg -t get_outputs \
|
||||
# | jq -r \
|
||||
# '.[] | select(.focused).rect | "\(.width)x\(.height)\\+\(.x)\\+\(.y)"')
|
||||
|
||||
# ripgrep
|
||||
#xwayland_output=$(xrandr | rg -oP "[A-Z]+[0-9]+(?= [a-z]+ $screen_pos)")
|
||||
|
||||
#monitor_id=$(rofi --help | rg $xwayland_output -B1 \
|
||||
# | sed -sr '/ID/!d;s/[^:]*:\s([0-9])/\1/')
|
||||
|
||||
|
||||
# Select window with rofi, obtaining ID of selected window
|
||||
# TODO: Use multiple columns while inserting appropriate empty lines
|
||||
# and adjusting line number accordingly in order to visually
|
||||
# separate the list by workspace
|
||||
|
||||
if [ -z "$monitor_id" ]
|
||||
then
|
||||
idx_selected=$printf '%s\n' "${windows_separators[@]}" | rofi -dmenu -i -p "$command_" -a "$index_workspace_active" -format i -selected-row "$index_window_last_active" -no-custom -s -width 80 -lines 30 -markup-rows)
|
||||
else
|
||||
idx_selected=$(printf '%s\n' "${windows_separators[@]}" | rofi -monitor $monitor_id -dmenu -i -p "$command_" -a "$index_workspace_active" -format i -selected-row "$index_window_last_active" -no-custom -s -width 80 -lines 30 -markup-rows)
|
||||
fi
|
||||
|
||||
# if no entry selected (e.g. user exitted with escape), end
|
||||
if [ -z "$idx_selected" ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
selected=${windows[$idx_selected]}
|
||||
id_selected=$(echo $selected | awk '{print $NF}')
|
||||
workspace_selected=${selected:0:1}
|
||||
|
||||
|
||||
### unmaximize all maximized windows on the workspace of the selected window
|
||||
# Obtain the avaliable windows' workspaces, names and IDs as strings
|
||||
mapfile -t ids_windows_maximized < <(
|
||||
swaymsg -t get_tree | jq -r '[
|
||||
recurse(.nodes[]?)
|
||||
|recurse(.floating_nodes[]?)
|
||||
|select(.type=="workspace")
|
||||
| . as $workspace | recurse(.nodes[]?)
|
||||
|select(.type=="con" and .name!=null and .fullscreen_mode==1 and $workspace.name=="'"$workspace_selected"'")
|
||||
|{workspace: $workspace.name, name: .name, id: .id, focused: .focused, app_id: .app_id}]
|
||||
|sort_by(.workspace, .name)[]
|
||||
|(.id|tostring)'
|
||||
)
|
||||
|
||||
# unmaximize the maximized windows that are not the selected one
|
||||
for id_window_maximized in "${ids_windows_maximized[@]}"
|
||||
do
|
||||
if [ "$id_window_maximized" != "$id_selected" ]
|
||||
then
|
||||
swaymsg "[con_id=$id_window_maximized] fullscreen disable"
|
||||
fi
|
||||
done
|
||||
|
||||
# Tell sway to focus said window
|
||||
if [ ! -z "$id_selected" ]
|
||||
then
|
||||
swaymsg "[con_id=$id_selected] $command_"
|
||||
fi(
|
Reference in New Issue
Block a user