feat: some more history
This commit is contained in:
@@ -19,6 +19,12 @@ set $term alacritty
|
||||
# Note: pass the final command to swaymsg so that the resulting window can be opened
|
||||
# on the original workspace that the command was run on.
|
||||
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"
|
||||
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
|
||||
set $toggle_layout ~/.config/sway/toggle_layout.sh
|
||||
|
||||
|
||||
# Input configuration
|
||||
input * {
|
||||
@@ -35,7 +41,7 @@ default_border none
|
||||
### Output configuration
|
||||
#
|
||||
# Default wallpaper (more resolutions are available in @datadir@/backgrounds/sway/)
|
||||
#output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
|
||||
output * bg `find ~/.customization/background -type f | shuf -n 1` fill
|
||||
#
|
||||
# Example configuration:
|
||||
#
|
||||
@@ -74,27 +80,29 @@ default_border none
|
||||
#
|
||||
# Basics:
|
||||
#
|
||||
# Start a terminal
|
||||
bindsym $mod+q exec $powermenu
|
||||
bindsym $mod+Return exec $term
|
||||
|
||||
# Kill focused window
|
||||
bindsym $mod+Shift+q kill
|
||||
|
||||
# Start your launcher
|
||||
bindsym $mod+d exec $menu
|
||||
|
||||
# Drag floating windows by holding down $mod and left mouse button.
|
||||
# Resize them with right mouse button + $mod.
|
||||
# Despite the name, also works for non-floating windows.
|
||||
# Change normal to inverse to use left mouse button for resizing and right
|
||||
# mouse button for dragging.
|
||||
floating_modifier $mod normal
|
||||
bindsym $mod+e exec nautilus
|
||||
|
||||
# Drag and resize floating windows with mouse right/left drag
|
||||
floating_modifier $mod normal
|
||||
|
||||
# Reload the configuration file
|
||||
bindsym $mod+Shift+c reload
|
||||
|
||||
# Exit sway (logs you out of your Wayland session)
|
||||
bindsym $mod+Shift+e 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'
|
||||
# Multimedia Audio Keys
|
||||
bindsym XF86AudioMute exec "pactl list sinks | grep -q Mute:.no && pactl set-sink-mute 0 1 || pactl set-sink-mute 0 0"
|
||||
bindsym XF86AudioLowerVolume exec "pactl -- set-sink-volume 0 -10%"
|
||||
bindsym XF86AudioRaiseVolume exec "pactl -- set-sink-volume 0 +10%"
|
||||
|
||||
#Increase brightness
|
||||
bindsym XF86MonBrightnessUp exec brightnessctl -d intel_backlight set +10
|
||||
bindsym XF86MonBrightnessDown exec brightnessctl -d intel_backlight set 10-
|
||||
|
||||
# Exit sway (logs you out of your Wayland session)
|
||||
bindsym $mod+Shift+e exec swaynag -t warning -m 'Do you really want to exit your Wayland session?' -B 'Yes, exit sway' 'swaymsg exit'
|
||||
#
|
||||
# Moving around:
|
||||
#
|
||||
@@ -123,11 +131,16 @@ default_border none
|
||||
# Workspaces:
|
||||
#
|
||||
|
||||
set $ws1 " Code"
|
||||
set $ws2 " Browser"
|
||||
set $ws3 " Music"
|
||||
set $ws4 " Chat"
|
||||
|
||||
# Switch to workspace
|
||||
bindsym $mod+1 workspace number 1
|
||||
bindsym $mod+2 workspace number 2
|
||||
bindsym $mod+3 workspace number 3
|
||||
bindsym $mod+4 workspace number 4
|
||||
bindsym $mod+1 workspace $ws1
|
||||
bindsym $mod+2 workspace $ws2
|
||||
bindsym $mod+3 workspace $ws3
|
||||
bindsym $mod+4 workspace $ws4
|
||||
bindsym $mod+5 workspace number 5
|
||||
bindsym $mod+6 workspace number 6
|
||||
bindsym $mod+7 workspace number 7
|
||||
@@ -147,6 +160,11 @@ default_border none
|
||||
bindsym $mod+Shift+0 move container to workspace number 10
|
||||
# Note: workspaces can have any name you want, not just numbers.
|
||||
# We just use 1-10 as the default.
|
||||
|
||||
assign [class="Firefox"] $ws2
|
||||
assign [class="Chromium"] $ws2
|
||||
assign [class="Google-chrome-beta"] $ws2
|
||||
assign [class="google-chrome"] ""
|
||||
#
|
||||
# Layout stuff:
|
||||
#
|
||||
@@ -157,9 +175,7 @@ default_border none
|
||||
bindsym $mod+v splitv
|
||||
|
||||
# Switch the current container between different layout styles
|
||||
bindsym $mod+s layout stacking
|
||||
bindsym $mod+w layout tabbed
|
||||
bindsym $mod+e layout toggle split
|
||||
bindsym $mod+w exec $toggle_layout
|
||||
|
||||
# Make the current focus fullscreen
|
||||
bindsym $mod+f fullscreen
|
||||
@@ -172,6 +188,17 @@ default_border none
|
||||
|
||||
# Move focus to the parent container
|
||||
bindsym $mod+a focus parent
|
||||
|
||||
# Screenshots
|
||||
# -- Area Screenshot
|
||||
bindsym $mod+Shift+s exec $screenclip
|
||||
# -- Select Window
|
||||
bindsym $mod+Control+s exec $windowshot
|
||||
# -- Entire Screen
|
||||
bindsym $mod+s exec $screenshot
|
||||
|
||||
|
||||
bindsym Alt+Tab exec rofi -show window -modi window
|
||||
#
|
||||
# Scratchpad:
|
||||
#
|
||||
|
161
configs/sway/swytcher.sh
Executable file
161
configs/sway/swytcher.sh
Executable file
@@ -0,0 +1,161 @@
|
||||
#!/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(
|
26
configs/sway/toggle_layout.sh
Executable file
26
configs/sway/toggle_layout.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
WORKSPACE=$(swaymsg -t get_workspaces --raw | jq '.[] | select(.focused == true)')
|
||||
|
||||
WORKSPACE_ID=$(echo $WORKSPACE | jq ".name")
|
||||
WORKSPACE_MODE=$(echo $WORKSPACE | jq ".layout");
|
||||
|
||||
MODE_SPLITH='"splith"'
|
||||
MODE_SPLITV='"splitv"'
|
||||
MODE_TABBED='"tabbed"'
|
||||
MODE_STACKED='"stacked"'
|
||||
|
||||
echo $WORKSPACE_MODE
|
||||
|
||||
if [ $WORKSPACE_MODE = $MODE_SPLITH ]; then
|
||||
swaymsg "workspace $WORKSPACE_ID; layout splitv"
|
||||
elif [ $WORKSPACE_MODE = $MODE_SPLITV ]; then
|
||||
swaymsg "workspace $WORKSPACE_ID; layout tabbed"
|
||||
elif [ $WORKSPACE_MODE = $MODE_TABBED ]; then
|
||||
swaymsg "workspace $WORKSPACE_ID; layout stacking"
|
||||
elif [ $WORKSPACE_MODE = $MODE_STACKED ]; then
|
||||
swaymsg "workspace $WORKSPACE_ID; layout splith"
|
||||
fi
|
||||
|
||||
echo $WORKSPACE_ID;
|
||||
|
Reference in New Issue
Block a user