Initial Sway config

This commit is contained in:
Aleksey Samoilov 2023-04-29 15:02:58 +04:00
parent f9e5e4d3e1
commit d6ba56e5f4
17 changed files with 645 additions and 0 deletions

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
tileos-settings-sway (0.4~tileos) unstable; urgency=medium
* Initial Sway config
-- Aleksey Samoilov <samoilov.lex@gmail.com> Sat, 29 Apr 2023 15:00:52 +0400
tileos-settings-sway (0.3~tileos) unstable; urgency=medium
* Set Wayland specific environment variables

View file

@ -0,0 +1,9 @@
#
# Status Bar:
#
# Read `man 5 sway-bar` for more information about this section.
bar {
id default
swaybar_command /usr/share/sway/scripts/waybar.sh
position top
}

View file

@ -0,0 +1,59 @@
#don't show gaps if there's only one window on the desktop
smart_gaps on
# set floating mode for specific application
for_window [app_id="firefox" title="^Library$"] floating enable, border pixel 1, sticky enable
for_window [app_id="thunderbird" title=".*Reminder"] floating enable
for_window [app_id="floating_shell_portrait"] floating enable, border pixel 1, sticky enable, resize set width 30 ppt height 40 ppt
for_window [app_id="floating_shell"] floating enable, border pixel 1, sticky enable
for_window [app_id="" title="Picture in picture"] floating enable, sticky enable
for_window [app_id="" title="Picture-in-Picture"] floating enable, sticky enable
for_window [instance="around"] floating enable, sticky enable
for_window [app_id="xsensors"] floating enable
for_window [app_id = "qt5ct"] floating enable
for_window [app_id = "qt6ct"] floating enable
for_window [app_id="nm-connection-editor"] floating enable
for_window [app_id="pavucontrol"] floating enable
for_window [app_id="nwg-look"] floating enable
for_window [app_id="engrampa"] floating enable
for_window [app_id="software-properties-gtk"] floating enable
for_window [app_id="wdisplays"] floating enable
for_window [app_id="gpk-update-viewer"] floating enable
for_window [app_id="gpk-application"] floating enable
for_window [app_id="nwg-displays"] floating enable
for_window [class="calamares"] floating enable
for_window [app_id="sway-input-config"] floating enable
for_window [title="Save File"] floating enable
for_window [title="Firefox .*— Sharing Indicator"] floating enable, sticky enable, move to scratchpad
for_window [app_id="" title=".* is sharing your screen."] floating enable
# set floating mode for generated windows
for_window [window_role="pop-up"] floating enable
for_window [window_role="bubble"] floating enable
for_window [window_role="dialog"] floating enable
for_window [window_type="dialog"] floating enable
for_window [window_role = "task_dialog"] floating enable
for_window [window_type = "menu"] floating enable
for_window [window_role = "GtkFileChooserDialog"] resize set 600 400
for_window [window_role = "GtkFiileChooserDialog"] move position center
for_window [window_role="Preferences"] floating enable
for_window [title="(?:Open|Save) (?:File|Folder|As)"] floating enable;
for_window [title="(?:Open|Save) (?:File|Folder|As)"] resize set 600 400
# apply mark for Xwayland and wayland native browser windows
for_window [class="Chromium-browser"] mark Browser
for_window [class="Brave-browser"] mark Browser
for_window [class="firefox"] mark Browser
for_window [app_id="Chromium-browser"] mark Browser
for_window [app_id="brave-browser"] mark Browser
for_window [app_id="firefox"] mark Browser
# inhibit scrensaver for fullscreen browser windows
for_window [con_mark="Browser"] {
inhibit_idle fullscreen
}
# Don't allow applications to inhibit shortcuts, i.e. grab total control of the
# keyboard. Chrome currently abuses this by enabling it for all "--app=..."
# shortcuts.
seat * shortcuts_inhibitor disable

View file

@ -0,0 +1,9 @@
# Autostart settings. For values of these variables see /etc/sway/variables
# You can add your own applications or daemons here
exec {
$polkit_agent
}
exec_always {
$kanshi
}

View file

@ -0,0 +1,6 @@
### Input configuration
#
# Keyboard layout
input type:keyboard {
xkb_layout us
}

View file

@ -0,0 +1,9 @@
### Input configuration
#
# You can get the names of your inputs by running: swaymsg -t get_inputs
# Read `man 5 sway-input` for more information about this section.
input type:touchpad {
dwt enabled
tap enabled
natural_scroll enabled
}

View file

@ -0,0 +1,8 @@
# Touchpad gestures. See "man 5 sway" for the details
# Allow switching between workspaces with left and right swipes (three fingers)
bindgesture swipe:right workspace prev
bindgesture swipe:left workspace next
# Allow toggling floating mode (and vice versa) for selected window
bindgesture swipe:down floating toggle

151
etc/sway/modes/default.conf Normal file
View file

@ -0,0 +1,151 @@
### Key bindings
#
# Basics:
#
## Launch // Terminal ##
$bindsym $mod+Return exec $term_cwd
$bindsym $mod+Shift+Return exec $term
## Action // Kill focused window ##
$bindsym $mod+Shift+q kill
## Launch // Launcher ##
$bindsym $mod+d exec $menu
## Launch // Clipboard ##
$bindsym $mod+Shift+p exec $clipboard
# 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
## Action // Reload Sway Configuration ##
$bindsym $mod+Shift+c reload
## Action // Exit Sway ##
$bindsym $mod+Shift+e exec nwg-bar -x
# Media keys
$bindsym --locked XF86AudioRaiseVolume exec $volume_up
$bindsym --locked XF86AudioLowerVolume exec $volume_down
$bindsym --locked XF86AudioMute exec $volume_mute
$bindsym --locked XF86AudioPlay exec playerctl play-pause
$bindsym --locked XF86AudioNext exec playerctl next
$bindsym --locked XF86AudioPrev exec playerctl previous
# Brightness control
$bindsym --locked XF86MonBrightnessUp exec $brightness_up
$bindsym --locked XF86MonBrightnessDown exec $brightness_down
# Other
$bindsym XF86Search exec $menu
$bindsym XF86PowerOff exec systemctl poweroff
$bindsym XF86TouchpadToggle input type:touchpad events toggle enabled disabled
$bindsym XF86ScreenSaver exec $lock
#
# Moving around:
#
## Navigation // Move focus // $mod + ↑ ↓ ← → ##
$bindsym $mod+$left focus left
$bindsym $mod+$down focus down
$bindsym $mod+$up focus up
$bindsym $mod+$right focus right
# Or use $mod+[up|down|left|right]
$bindsym $mod+Left focus left
$bindsym $mod+Down focus down
$bindsym $mod+Up focus up
$bindsym $mod+Right focus right
## Navigation // Move focused window // $mod + Shift + ↑ ↓ ← → ##
$bindsym $mod+Shift+$left move left
$bindsym $mod+Shift+$down move down
$bindsym $mod+Shift+$up move up
$bindsym $mod+Shift+$right move right
# Ditto, with arrow keys
$bindsym $mod+Shift+Left move left
$bindsym $mod+Shift+Down move down
$bindsym $mod+Shift+Up move up
$bindsym $mod+Shift+Right move right
## Navigation // List all open windows in last-recently-used order ##
$bindsym $mod+p exec env RUST_BACKTRACE=1 swayr switch-window &>> /tmp/swayr.log
## Navigation // Switch to the last recently used window ##
$bindsym Mod1+Tab exec env RUST_BACKTRACE=1 swayr switch-to-urgent-or-lru-window &>> /tmp/swayr.log
## Navigation // Switch to the last recently used workspace ##
$bindsym $mod+Tab workspace back_and_forth
#
# Workspaces:
#
## Navigation // Switch workspace // $mod + [number] ##
$bindsym $mod+1 workspace $ws1
$bindsym $mod+2 workspace $ws2
$bindsym $mod+3 workspace $ws3
$bindsym $mod+4 workspace $ws4
$bindsym $mod+5 workspace $ws5
$bindsym $mod+6 workspace $ws6
$bindsym $mod+7 workspace $ws7
$bindsym $mod+8 workspace $ws8
$bindsym $mod+9 workspace $ws9
$bindsym $mod+0 workspace $ws10
set $focus_ws [ $focus_after_move == 'true' ] && swaymsg workspace
## Action // Move focused window to workspace // $mod + Shift + [number] ##
$bindsym $mod+Shift+1 move container to workspace $ws1, exec $focus_ws $ws1
$bindsym $mod+Shift+2 move container to workspace $ws2, exec $focus_ws $ws2
$bindsym $mod+Shift+3 move container to workspace $ws3, exec $focus_ws $ws3
$bindsym $mod+Shift+4 move container to workspace $ws4, exec $focus_ws $ws4
$bindsym $mod+Shift+5 move container to workspace $ws5, exec $focus_ws $ws5
$bindsym $mod+Shift+6 move container to workspace $ws6, exec $focus_ws $ws6
$bindsym $mod+Shift+7 move container to workspace $ws7, exec $focus_ws $ws7
$bindsym $mod+Shift+8 move container to workspace $ws8, exec $focus_ws $ws8
$bindsym $mod+Shift+9 move container to workspace $ws9, exec $focus_ws $ws9
$bindsym $mod+Shift+0 move container to workspace $ws10, exec $focus_ws $ws10
## Launch // Open launcher in a new workspace ##
$bindsym $mod+Shift+d exec /usr/share/sway/scripts/first-empty-workspace.py --switch, exec $menu
## Navigation // Switch to a new workspace ##
$bindsym $mod+n exec /usr/share/sway/scripts/first-empty-workspace.py --switch
## Action // Move focused window to a new workspace ##
$bindsym $mod+Shift+n exec /usr/share/sway/scripts/first-empty-workspace.py --move
## Action // Move focused window to a new workspace and switch there ##
$bindsym $mod+Shift+m exec /usr/share/sway/scripts/first-empty-workspace.py --move --switch
#
# Layout stuff:
#
## Setting // Split windows horizontally ##
$bindsym $mod+b splith
## Setting // Split windows vertically ##
$bindsym $mod+v splitv
## Action // Switch to window stacking ##
$bindsym $mod+s layout stacking
## Action // Switch to window tabbing ##
$bindsym $mod+w layout tabbed
## Action // Toggle window splitting ##
$bindsym $mod+e layout toggle split
## Action // Toggle fullscreen ##
$bindsym $mod+f fullscreen
## Action // Toggle floating ##
$bindsym $mod+Shift+space floating toggle
## Navigation // Toggle focus between tiling and floating ##
$bindsym $mod+space focus mode_toggle
## Navigation // Swap focus to the parent window ##
$bindsym $mod+a focus parent
## Launch // Toggle Help ##
$bindsym $mod+question exec $help

View file

@ -0,0 +1,19 @@
set $mode_recording "<span foreground='$color10'></span> \
<span foreground='$color5'><b>Record</b></span> <span foreground='$color10'>(<b>r</b>)</span> \
<span foreground='$color5'>+ [<span foreground='$color10'><b>Shift</b></span> for ]</span>"
set $recorder /usr/share/sway/scripts/recorder.sh
mode --pango_markup $mode_recording {
$bindsym r exec $recorder, mode "default"
$bindsym Shift+r exec $recorder -a, mode "default"
# Return to default mode.
$bindsym Escape mode "default"
}
## Launch // Recording Mode ##
$bindsym $mod+Shift+r mode $mode_recording
## Launch // Stop Recording Mode ##
$bindsym $mod+Escape exec killall -s SIGINT wf-recorder

View file

@ -0,0 +1,31 @@
set $mode_resize "<span foreground='$color10'></span> \
<span foreground='$color5'><b>Resize</b></span> <span foreground='$color10'>(<b>↑ ↓ ← →</b>)</span> \
<span foreground='$color5'><b>Increase Gaps</b></span> <span foreground='$color10'>(<b>+</b>)</span> \
<span foreground='$color5'><b>Decrease Gaps</b></span> <span foreground='$color10'>(<b>-</b>)</span>"
mode --pango_markup $mode_resize {
# left will shrink the containers width
# right will grow the containers width
# up will shrink the containers height
# down will grow the containers height
$bindsym $left resize shrink width 10px
$bindsym $down resize grow height 10px
$bindsym $up resize shrink height 10px
$bindsym $right resize grow width 10px
# Ditto, with arrow keys
$bindsym Left resize shrink width 10px
$bindsym Down resize grow height 10px
$bindsym Up resize shrink height 10px
$bindsym Right resize grow width 10px
## Resize // Window Gaps // + - ##
$bindsym minus gaps inner current minus 5px
$bindsym plus gaps inner current plus 5px
# Return to default mode
$bindsym Return mode "default"
$bindsym Escape mode "default"
}
## Launch // Resize Mode ##
$bindsym $mod+r mode $mode_resize

View file

@ -0,0 +1,11 @@
#
# Scratchpad:
#
# Sway has a "scratchpad", which is a bag of holding for windows.
# You can send windows there and get them back later.
## Action // Move window to scratchpad ##
$bindsym $mod+Shift+minus move scratchpad
## Action // Toggle scratchpad ##
$bindsym $mod+minus scratchpad show

View file

@ -0,0 +1,21 @@
set $mode_screenshot "<span foreground='$color10'></span> \
<span foreground='$color5'><b>Pick</b></span> <span foreground='$color10'>(<b>p</b>)</span> \
<span foreground='$color5'><b>Output</b></span> <span foreground='$color10'>(<b>o</b>)</span> \
<span foreground='$color5'><b>Active</b></span> <span foreground='$color10'>(<b>a</b>)</span>"
mode --pango_markup $mode_screenshot {
# output = currently active output
$bindsym o mode "default", exec $screenshot_screen
# pick the region to screenshot
$bindsym p mode "default", exec $screenshot_selection
# screenshot of active window
$bindsym a mode "default", exec $screenshot_active
# Return to default mode.
$bindsym Escape mode "default"
}
## Launch // Screenshot Mode ##
$bindsym Print mode $mode_screenshot

View file

@ -0,0 +1,10 @@
### Output configuration
#
# Default wallpaper (handled with Azote)
exec ~/.azotebg
#
# Example configuration:
#
# output HDMI-A-1 resolution 1920x1080 position 1920,0
#
# You can get the names of your outputs by running: swaymsg -t get_outputs

89
etc/sway/variables Normal file
View file

@ -0,0 +1,89 @@
### Variables
#
# 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 foot
set $term_cwd $term -D "$(/usr/share/sway/scripts/swaycwd.sh 2>/dev/null || echo $HOME)"
set $term_server foot --server
set $term_float footclient -a floating_shell
# Your preferred application launcher
set $menu fuzzel
# Add --to-code to bindsym, support for non-latin layouts
set $bindsym bindsym --to-code
# Pulseaudo command
set $pulseaudio $term_float pulsemixer
# calendar application
set $calendar $term_float calcurse
# workspace names
set $ws1 number 1
set $ws2 number 2
set $ws3 number 3
set $ws4 number 4
set $ws5 number 5
set $ws6 number 6
set $ws7 number 7
set $ws8 number 8
set $ws9 number 9
set $ws10 number 10
# screenshot
set $grimshot /usr/bin/grimshot
set $pipe_output $grimshot save output -
set $pipe_selection $grimshot save window -
set $pipe_active $grimshot save active -
set $notify_paste bash -c '[[ $(wl-paste -l) == "image/png" ]] && notify-send "Screenshot copied to clipboard"'
set $swappy swappy -f -
set $screenshot_screen $pipe_output | $swappy && $notify_paste
set $screenshot_selection $pipe_selection | $swappy && $notify_paste
set $screenshot_active $pipe_active | $swappy && $notify_paste
# PolicyKit agent
set $polkit_agent /usr/bin/mate-polkit
# Autotiling script
set $autotiling '[ -x "$(command -v autotiling)" ] && autotiling -w 1 3 5 7 9'
# restart kanshi https://github.com/emersion/kanshi/issues/43#issuecomment-531679213
set $kanshi '[ -x "$(command -v kanshi)" ] && pkill kanshi; exec kanshi'
# Dex autostart daemon
set $dex_autostart '[ -x "$(command -v dex)" ] && gdbus wait --session org.kde.StatusNotifierWatcher && dex --autostart'
# Start PCmanFM as a daemon
set $pcmanfm_daemon '[ -x "$(command -v pcmanfm)" ] && pcmanfm -d'
# Power notifications daemon
set $poweralertd '[ -x "$(command -v poweralertd)" ] && pkill poweralertd; poweralertd -s -i "line power" &'
# Clipboard manager
set $cliphist_store '[ -x "$(command -v wl-paste)" ] && [ -x "$(command -v cliphist)" ] && wl-paste --watch cliphist store'
set $cliphist_watch '[ -x "$(command -v wl-paste)" ] && [ -x "$(command -v cliphist)" ] && wl-paste --watch pkill -RTMIN+9 waybar'
# Start nwg-drawer as a daemon
set $nwg_drawer_daemon '[ -x "$(command -v nwg-drawer)" ] && nwg-drawer -r'
# SPICE agent
set $spice_vdagent '[ -x "$(command -v spice-vdagent)" ] && spice-vdagent'
# Start playerctl as daemon
set $watch_playerctl '[ -x "$(command -v playerctl)" ] && pkill playerctl; playerctl -a metadata --format \'{{status}} {{title}}\' --follow | while read line; do pkill -RTMIN+5 waybar; done'
# Start Calcurse calendar as a daemon
set $calendar_daemon 'calcurse --daemon'
# Notifications from Swappy
set $swappy_notify '[ -x "$(command -v swappy)" ] && /usr/share/sway/scripts/screenshot-notify.sh'

View file

@ -0,0 +1,173 @@
{
"layer": "top",
"position": "top",
"height": 30,
"modules-left": ["custom/menu", "sway/workspaces", "sway/window"],
"modules-center": ["custom/wf-recorder", "sway/mode"],
"modules-right": [
"custom/playerctl",
"idle_inhibitor",
"custom/dnd",
"sway/language",
"cpu",
"memory",
"battery",
"network",
"pulseaudio",
"clock",
"custom/power",
"tray"
],
"sway/workspaces": {
"disable-scroll": true,
"all-outputs": true
},
"sway/language": {
"format": " {}",
"min-length": 5,
"tooltip": false,
"on-click": "swaymsg input $(swaymsg -t get_inputs --raw | jq '[.[] | select(.type == \"keyboard\")][0] | .identifier') xkb_switch_layout next"
},
"custom/menu": {
"format": "",
"on-click": "exec nwg-drawer",
"tooltip": false
},
"sway/mode": {
"format": "<span style=\"italic\">{}</span>",
"tooltip": false
},
"sway/window": {
"format": "{}",
"max-length": 50,
"tooltip": true
},
"idle_inhibitor": {
"format": "{icon}",
"format-icons": {
"activated": "",
"deactivated": ""
},
"tooltip": true,
"tooltip-format-activated": "power-saving disabled",
"tooltip-format-deactivated": "power-saving enabled"
},
"pulseaudio": {
"format": "{icon} {volume}% {format_source}",
"format-bluetooth": "{icon} {volume}%",
"format-muted": " {format_source}",
"format-source": "  {volume}%",
"format-source-muted": "",
"format-icons": {
"headphone": "",
"headset": "",
"default": ["", "", ""]
},
"tooltip-format": "{icon} {volume}% {format_source}",
"on-click": "swaymsg exec \\$pulseaudio",
"on-click-middle": "swaymsg exec \\$volume_mute",
"on-click-right": "swaymsg exec pavucontrol",
"on-scroll-up": "swaymsg exec \\$volume_up",
"on-scroll-down": "swaymsg exec \\$volume_down"
},
"battery": {
"format": "{icon} {capacity}%",
"format-icons": ["", "", "", "", ""]
},
"network": {
"format-wifi": " ({signalStrength}%)",
"format-ethernet": "",
"format-disconnected": "",
"tooltip-format": "{ifname} ({essid}): {ipaddr}",
"on-click": "swaymsg exec \\$term_float nmtui"
},
"clock": {
"format": "{:%e %b %H:%M}",
"tooltip": true,
"tooltip-format": "{:%d.%m.%Y %H:%M}",
"interval": 5,
"on-click": "swaymsg exec \\$calendar"
},
"cpu": {
"interval": 5,
"format": " {usage}%",
"states": {
"warning": 70,
"critical": 90
},
"on-click": "swaymsg exec \\$term_float htop"
},
"memory": {
"interval": 30,
"format": " {}%",
"states": {
"warning": 70,
"critical": 90
},
"on-click": "swaymsg exec \\$term_float htop"
},
"custom/wf-recorder": {
"interval": "once",
"return-type": "json",
"format": "{}",
"tooltip-format": "{tooltip}",
"exec": "echo '{\"class\": \"recording\",\"text\":\"\",\"tooltip\":\"press $mod+Esc to stop recording\"}'",
"exec-if": "pgrep wf-recorder",
"on-click": "killall -s SIGINT wf-recorder",
"signal": 8
},
"custom/playerctl": {
"interval": "once",
"tooltip": true,
"return-type": "json",
"format": "{icon}",
"format-icons": {
"Playing": "",
"Paused": ""
},
"exec": "playerctl metadata --format '{\"alt\": \"{{status}}\", \"tooltip\": \"{{playerName}}: {{markup_escape(title)}} - {{markup_escape(artist)}}\" }'",
"on-click": "playerctl play-pause; pkill -RTMIN+5 waybar",
"on-click-right": "playerctl next; pkill -RTMIN+5 waybar",
"on-scroll-up": "playerctl position 10+; pkill -RTMIN+5 waybar",
"on-scroll-down": "playerctl position 10-; pkill -RTMIN+5 waybar",
"signal": 5
},
"custom/power": {
"format": "",
"on-click": "nwg-bar -x"
},
"custom/dnd": {
"interval": "once",
"return-type": "json",
"format": "{}{icon}",
"format-icons": {
"default": "",
"dnd": ""
},
"on-click": "makoctl mode | grep 'do-not-disturb' && makoctl mode -r do-not-disturb || makoctl mode -a do-not-disturb; pkill -RTMIN+11 waybar",
"exec": "printf '{\"alt\":\"%s\",\"tooltip\":\"Notification mode: %s\"}' $(makoctl mode | grep -q 'do-not-disturb' && echo dnd || echo default) $(makoctl mode | tail -1)",
"signal": 11
},
"tray": {
"icon-size": 21,
"spacing": 10
}
}

View file

@ -0,0 +1,19 @@
#!/bin/sh
# Author: Caleb Stewart
# URL: https://github.com/calebstewart/swaycwd.git
# Description: print the CWD of the currently focused window in swaywm
# Grab the window/display tree
TREE=$(swaymsg -t get_tree)
# Find the focused node
TREE_PATH=$(echo "$TREE" | gron | grep "focused = true" | sed 's/.focused.*$/.pid/g;s/^json//g')
# Find the PID of the process
PID=$(echo "$TREE" | jq "$TREE_PATH")
# how far down does the rabbit hole go? D:
while pgrep -P "$PID" >/dev/null; do
PID=$(pgrep -P "$PID" | tail -n1)
done
# Show the current working directory
readlink -e "/proc/$PID/cwd"

View file

@ -0,0 +1,15 @@
#!/bin/sh
# wrapper script for waybar with args, see https://github.com/swaywm/sway/issues/5724
USER_CONFIG_PATH=$HOME/.config/waybar/config.jsonc
USER_STYLE_PATH=$HOME/.config/waybar/style.css
if [ -f "$USER_CONFIG_PATH" ]; then
USER_CONFIG=$USER_CONFIG_PATH
fi
if [ -f "$USER_STYLE_PATH" ]; then
USER_STYLE=$USER_STYLE_PATH
fi
waybar -c "${USER_CONFIG:-"/etc/xdg/xdg-tileos/waybar/config.jsonc"}" -s "${USER_STYLE:-"/etc/xdg/xdg-tileos/waybar/style.css"}" &