Sway config in multiple files

This commit is contained in:
Tibo De Peuter 2022-06-19 23:49:44 +02:00
parent 6925eb624d
commit 6a9f632787
5 changed files with 332 additions and 344 deletions

19
config/sway/autostart Normal file
View file

@ -0,0 +1,19 @@
#
# ~/.config/sway/autostart
# List of applications to autostart
#
# Idle script
exec_always "~/.scripts/idle.sh"
# Gamma and brightness
exec clight &> /dev/null
# Notification manager
exec dunst -verbosity crit
# Fix [Slow launch for some GTK apps](https://github.com/swaywm/sway/issues/5732)
exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK
# Fix JetBrain IDE's showing properly
exec wmname LG3D

168
config/sway/commands Normal file
View file

@ -0,0 +1,168 @@
#
# ~/.config/sway/commands
# Keybinds for sway
#
# Variables
set {
$alt Mod1
$flag Mod4
$term alacritty
}
# Focus
bindsym {
$flag+h focus left
$flag+j focus down
$flag+k focus up
$flag+l focus right
$flag+Left focus left
$flag+Down focus down
$flag+Up focus up
$flag+Right focus right
$flag+m focus mode_toggle
$flag+p focus parent
}
# Move windows
bindsym {
$flag+Shift+h move left
$flag+Shift+j move down
$flag+Shift+k move up
$flag+Shift+l move right
$flag+Shift+Left move left
$flag+Shift+Down move down
$flag+Shift+Up move up
$flag+Shift+Right move right
$flag+Next move scratchpad
$flag+Prior scratchpad show
}
# Layouts
bindsym {
$flag+w layout toggle split
$flag+x layout tabbed
$flag+c split h
$flag+v split v
$flag+f floating enable, border normal 1
$flag+Shift+f floating disable, border pixel 1
$alt+Next border pixel 1 # Show window title
$alt+Prior border normal 1 # Hide window title
$flag+s sticky toggle
}
# Workspaces
set {
$ws1 "1:1"
$ws2 "2:2"
$ws3 "3:3"
$ws4 "4:4"
$ws5 "5:5"
$ws6 "6:6"
$ws7 "7:7"
$ws8 "8:8"
$ws9 "9:9"
$ws10 "10:10"
$ws0 "0:¯\_(ツ)_/¯"
}
workspace $ws0 # Move to this workspace on startup
bindsym {
$flag+ampersand workspace $ws1
$flag+eacute workspace $ws2
$flag+quotedbl workspace $ws3
$flag+apostrophe workspace $ws4
$flag+parenleft workspace $ws5
$flag+section workspace $ws6
$flag+egrave workspace $ws7
$flag+exclam workspace $ws8
$flag+ccedilla workspace $ws9
$flag+agrave workspace $ws10
$flag+parenright workspace $ws0
$flag+Shift+ampersand move container to workspace $ws1, workspace $ws1
$flag+Shift+eacute move container to workspace $ws2, workspace $ws2
$flag+Shift+quotedbl move container to workspace $ws3, workspace $ws3
$flag+Shift+apostrophe move container to workspace $ws4, workspace $ws4
$flag+Shift+parenleft move container to workspace $ws5, workspace $ws5
$flag+Shift+section move container to workspace $ws6, workspace $ws6
$flag+Shift+egrave move container to workspace $ws7, workspace $ws7
$flag+Shift+exclam move container to workspace $ws8, workspace $ws8
$flag+Shift+ccedilla move container to workspace $ws9, workspace $ws9
$flag+Shift+agrave move container to workspace $ws10, workspace $ws10
$flag+Shift+parenright move container to workspace $ws0, workspace $ws0
$flag+Control+h focus output 'eDP-1'
$flag+Control+j workspace prev_on_output
$flag+Control+k workspace next_on_output
$flag+Control+l focus output 'HDMI-A-1'
$flag+Control+Down focus output 'eDP-1'
$flag+Control+Right workspace prev_on_output
$flag+Control+Left workspace next_on_output
$flag+Control+Up focus output 'HDMI-A-1'
$flag+Control+Shift+h \
move container to output 'eDP-1', focus output 'eDP-1'
$flag+Control+Shift+j \
move container to workspace prev_on_output, workspace prev_on_output
$flag+Control+Shift+k \
move container to workspace next_on_output, workspace next_on_output
$flag+Control+Shift+l \
move container to output 'HDMI-A-1', focus output 'HDMI-A-1'
$flag+Control+Shift+Down \
move container to output 'eDP-1', focus output 'eDP-1'
$flag+Control+Shift+Left \
move container to workspace prev_on_output, workspace prev_on_output
$flag+Control+Shift+Right \
move container to workspace next_on_output, workspace next_on_output
$flag+Control+Shift+Up \
move container to output 'HDMI-A-1', focus output 'HDMI-A-1'
}
# System
bindsym --locked {
# Brightness
XF86MonBrightnessDown exec brightnessctl -e s 5%- && $notify -b
XF86MonBrightnessUp exec brightnessctl -e s +5% && $notify -b
# Volume control
XF86AudioRaiseVolume exec pulsemixer --change-volume +2 --max-volume 100 && $notify -v
XF86AudioLowerVolume exec pulsemixer --change-volume -2 && $notify -v
XF86AudioMute exec pulsemixer --toggle-mute && $notify -v
XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle
# Media control
F7 exec playerctl play-pause
Shift+XF86AudioLowerVolume exec playerctl previous
Shift+XF86AudioRaiseVolume exec playerctl next
}
# Special commands
set $fzf ~/.scripts/fzf-jump
bindsym {
# Reload sway
$alt+Shift+r reload
# Dialog to exit sway
$alt+Shift+e exec swaynag -t warning -m 'Do you really want to exit sway?' \
-B 'Yes, exit sway' 'swaymsg exit'
$flag+q kill # Kill focused window
$flag+Return exec $term # Start a terminal
$flag+Delete exec swaylock # Lockscreen
# Start application launcher
$alt+space exec $term --title 'FZF-Jump' -e $fzf/launcher.sh
# Window switcher
$alt+Tab exec $term --title 'FZF-Jump' -e $fzf/standalone.sh $fzf/modules/windows.sh $fzf/modules/workspaces.sh
}

View file

@ -1,368 +1,49 @@
#
# .config/sway/config
#
# Personal config for sway
# Requires noto-fonts-cjk
#
# =========
# Autostart
# =========
# Import other config files
include {
autostart
commands
modes
style
}
# Input
input type:keyboard {
xkb_layout "be"
xkb_layout "be"
}
input 2:7:SynPS/2_Synaptics_TouchPad {
natural_scroll enabled
scroll_factor 0.6
middle_emulation enabled
tap enabled
natural_scroll enabled
scroll_factor 0.6
middle_emulation enabled
tap enabled
}
# Set background to whatever file is named bg at the moment
seat seat0 hide_cursor when-typing enable
# Output
output * {
bg "~/Pictures/wallpapers/bg.*" fill
}
output 'Dell Inc. DELL P2214H 29C2937M4YTL' {
# Vertical monitor
transform 270
transform 270
}
# Hide the cursor when typing
seat seat0 {
hide_cursor when-typing enable
}
exec_always "~/.scripts/idle.sh"
# Notification manager
exec dunst -verbosity crit
# Set warm colours at night
exec clight &> /dev/null
xwayland disable
# I will keep using xwayland because it allows backwards compatibilty for a ton of apps that I use
# on a daily basis. It can be expensive on the memory sometimes but argh.
# Focus
focus_follows_mouse no
# =========
# Variables
# =========
set $alt Mod1
set $winkey Mod4
set $term alacritty
set $notify exec "~/.scripts/notify.sh"
# ================
# Window shortcuts
# ================
# Change focus
bindsym $winkey+Left focus left
bindsym $winkey+Down focus down
bindsym $winkey+Up focus up
bindsym $winkey+Right focus right
# Alternative keys
bindsym $winkey+h focus left
bindsym $winkey+j focus down
bindsym $winkey+k focus up
bindsym $winkey+l focus right
# Move focused window
bindsym $winkey+Shift+Left move left
bindsym $winkey+Shift+Down move down
bindsym $winkey+Shift+Up move up
bindsym $winkey+Shift+Right move right
# Alternative keys
bindsym $winkey+Shift+h move left
bindsym $winkey+Shift+j move down
bindsym $winkey+Shift+k move up
bindsym $winkey+Shift+l move right
# Layouts
bindsym $winkey+w layout toggle split
bindsym $winkey+x layout tabbed
bindsym $winkey+c split h
bindsym $winkey+v split v
bindsym $winkey+a focus parent
bindsym $winkey+b focus mode_toggle
bindsym $winkey+f floating enable, border normal 2
bindsym $winkey+Shift+f floating disable, border pixel 2
bindsym $winkey+p sticky toggle
bindsym $winkey+Next move scratchpad
bindsym $winkey+Prior scratchpad show
# Resize window menu
mode "resize" {
bindsym l resize grow width 10 px or 10 ppt
bindsym k resize grow height 10 px or 10 ppt
bindsym h resize shrink width 10 px or 10 ppt
bindsym j resize shrink height 10 px or 10 ppt
bindsym Shift+l resize grow width 50 px or 50 ppt
bindsym Shift+k resize grow height 50 px or 50 ppt
bindsym Shift+h resize shrink width 50 px or 50 ppt
bindsym Shift+j resize shrink height 50 px or 50 ppt
# Alternative keys
bindsym Up resize grow height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize shrink height 10 px or 10 ppt
bindsym Shift+Up resize grow height 50 px or 50 ppt
bindsym Shift+Right resize grow width 50 px or 50 ppt
bindsym Shift+Left resize shrink width 50 px or 50 ppt
bindsym Shift+Down resize shrink height 50 px or 50 ppt
# Window movement
bindsym $winkey+h move left
bindsym $winkey+j move down
bindsym $winkey+l move right
bindsym $winkey+k move up
# Alternative keys
bindsym $winkey+Left move left
bindsym $winkey+Down move down
bindsym $winkey+Right move right
bindsym $winkey+Up move up
# Go back
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $winkey+r mode "default"
}
bindsym $winkey+r mode "resize"
# ==========
# Workspaces
# ==========
set $ws0 0:¯\_(ツ)_/¯
# Move to this workspace on startup
workspace $ws0
# Define names for default workspaces for which we configure key bindings later on.
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"
# switch to workspace
bindsym $winkey+ampersand workspace number $ws1
bindsym $winkey+eacute workspace number $ws2
bindsym $winkey+quotedbl workspace number $ws3
bindsym $winkey+apostrophe workspace number $ws4
bindsym $winkey+parenleft workspace number $ws5
bindsym $winkey+section workspace number $ws6
bindsym $winkey+egrave workspace number $ws7
bindsym $winkey+exclam workspace number $ws8
bindsym $winkey+ccedilla workspace number $ws9
bindsym $winkey+agrave workspace number $ws10
bindsym $winkey+parenright workspace $ws0
bindsym $winkey+Control+Right workspace next_on_output
bindsym $winkey+Control+Left workspace prev_on_output
bindsym $winkey+Control+Up focus output 'HDMI-A-1'
bindsym $winkey+Control+Down focus output 'eDP-1'
# Alternative keys
bindsym $winkey+Control+j workspace next_on_output
bindsym $winkey+Control+k workspace prev_on_output
bindsym $winkey+Control+l focus output 'HDMI-A-1'
bindsym $winkey+Control+h focus output 'eDP-1'
# move focused container to workspace
bindsym $winkey+Shift+ampersand move container to workspace number $ws1; \
workspace number $ws1
bindsym $winkey+Shift+eacute move container to workspace number $ws2; \
workspace number $ws2
bindsym $winkey+Shift+quotedbl move container to workspace number $ws3; \
workspace number $ws3
bindsym $winkey+Shift+apostrophe move container to workspace number $ws4; \
workspace number $ws4
bindsym $winkey+Shift+5 move container to workspace number $ws5; \
workspace number $ws5
bindsym $winkey+Shift+section move container to workspace number $ws6; \
workspace number $ws6
bindsym $winkey+Shift+egrave move container to workspace number $ws7; \
workspace number $ws7
bindsym $winkey+Shift+exclam move container to workspace number $ws8; \
workspace number $ws8
bindsym $winkey+Shift+ccedilla move container to workspace number $ws9; \
workspace number $ws9
bindsym $winkey+Shift+agrave move container to workspace number $ws10; \
workspace number $ws10
bindsym $winkey+Shift+parenright move container to workspace $ws0; \
workspace $ws0
bindsym $winkey+Control+Shift+Right move container to workspace next; workspace next
bindsym $winkey+Control+Shift+Left move container to workspace prev; workspace prev
bindsym $winkey+Control+Shift+Up move container to output 'HDMI-A-1'; focus output 'HDMI-A-1'
bindsym $winkey+Control+Shift+Down move container to output 'eDP-1'; focus output 'eDP-1'
# Alternative keys
bindsym $winkey+Control+Shift+j move container to workspace next_on_output; \
workspace next_on_output
bindsym $winkey+Control+Shift+k move container to workspace prev_on_output; \
workspace prev_on_output
bindsym $winkey+Control+Shift+l move container to output 'HDMI-A-1'; \
focus output 'HDMI-A-1'
bindsym $winkey+Control+Shift+h move container to output 'eDP-1'; \
focus output 'eDP-1'
# ==============
# System Control
# ==============
bindsym $alt+Shift+r reload
bindsym $alt+Shift+e exec swaynag -t warning -m 'Do you really want to exit sway?' -B 'Yes, exit sway' 'swaymsg exit'
# Kill focused window
bindsym $winkey+q kill
# Start a terminal
bindsym $winkey+Return exec alacritty
set $fzfj-source ~/.scripts/fzf-jump
# Start application launcher
bindsym $alt+space exec alacritty --title 'FZF-Jump' -e $fzfj-source/launcher.sh
bindsym $alt+Tab exec alacritty --title 'FZF-Jump' -e $fzfj-source/standalone.sh $fzfj-source/modules/windows.sh $fzfj-source/modules/workspaces.sh
# Brightness
bindsym --locked XF86MonBrightnessDown exec brightnessctl -e s 5%- && $notify -b
bindsym --locked XF86MonBrightnessUp exec brightnessctl -e s +5% && $notify -b
# Media control
bindsym F7 exec --no-startup-id playerctl play-pause
bindsym Shift+XF86AudioLowerVolume exec --no-startup-id playerctl previous
bindsym Shift+XF86AudioRaiseVolume exec --no-startup-id playerctl next
# Volume control
bindsym XF86AudioRaiseVolume exec --no-startup-id pulsemixer --change-volume +2 --max-volume 100 && $notify -v
bindsym XF86AudioLowerVolume exec --no-startup-id pulsemixer --change-volume -2 && $notify -v
bindsym XF86AudioMute exec --no-startup-id pulsemixer --toggle-mute && $notify -v
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle
# Lockscreen
bindsym $winkey+Delete exec --no-startup-id swaylock
# =====
# Modes
# =====
# System actions
set $mode_system System (l)ock, (s)leep, (h)ibernate, (r)eboot, (Shift+s)hutdown
mode "$mode_system" {
bindsym l exec --no-startup-id swaylock; mode "default"
bindsym s exec --no-startup-id systemctl suspend; mode "default"
bindsym h exec --no-startup-id systemctl hibernate; mode "default"
bindsym r exec --no-startup-id systemctl reboot; mode "default"
bindsym Shift+s exec --no-startup-id systemctl poweroff -i; mode "default"
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym Control+$alt+Delete mode "$mode_system"
# Screenshots
set $mode_screenshot Screenshot of (a)rea, current (w)indow, (s)creen - Shift to save
set $save_format Pictures/Screenshots/$(date +%F)-$(date +%T).png
mode "$mode_screenshot" {
bindsym a exec grimshot copy area; mode "default"
bindsym w exec grimshot --notify copy active; mode "default"
bindsym s exec grimshot --notify copy screen; mode "default"
bindsym Shift+a exec grimshot --notify save area $save_format; mode "default"
bindsym Shift+w exec grimshot --notify save active $save_format; mode "default"
bindsym Shift+s exec grimshot --notify save screen $save_format; mode "default"
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym Print mode "$mode_screenshot"
# Some preferences
set $mode_preferences Toggle (s)unset, (n)otifications, (f)ocus
mode "$mode_preferences" {
bindsym s exec "~/.scripts/wlsunset.sh"; mode "default"
bindsym n exec "~/.scripts/dnd.sh"; mode "default"
bindsym f exec "dunstctl set-paused toggle"; mode "default"
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $alt+end mode "$mode_preferences"
# =======
# Styling
# =======
# Decrease the height of the window bar thing.
font pango:monospace 1
bar {
swaybar_command /usr/bin/waybar
mode hide
}
default_border pixel 2
default_floating_border normal 2
hide_edge_borders both
smart_borders on
# Toggle Show title
bindsym $alt+Next border pixel 2
bindsym $alt+Prior border normal 2
# Mimic no titles
# Classi border backgr text indic. hild_border
client.focused #000000 #00897b #00897b #00897b #000000
client.focused_inactive #000000 #222222 #222222 #222222 #000000
client.unfocused #000000 #222222 #222222 #222222 #000000
client.urgent #ff0000 #ff0000 #ff0000 #ff0000 #ff0000
exec gsettings set org.gnome.desktop.interface icon-theme 'Win11-black'
exec gsettings set org.gnome.desktop.interface gtk-theme 'Nordic'
# =====================
# Window configurations
# =====================
# Window rules
for_window [window_role="pop-up"] floating enable
for_window [window_role="task_dialog"] floating enable
for_window [class="Qalculate-gtk"] floating enable
for_window [class="Caprine"] floating enable; border normal 2
# Homewritten software testing in IntelliJ
for_window [class="be.ugent"] floating enable
for_window [title="^FZF-Jump$"] floating enable; border pixel 0; resize set 600 350
# =====
# FIXES
# =====
# [Slow launch for some GTK apps](https://github.com/swaywm/sway/issues/5732)
exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK
# Fix JetBrain IDE's showing properly
exec wmname LG3D
for_window [class="Qalculate"] floating enable
for_window [class="Caprine"] floating enable, border normal 2
for_window [class="be.ugent"] floating enable # IntelliJ Java programs
for_window [title="^FZF-Jump$"] floating enable, border pixel 0, resize set 600 350

93
config/sway/modes Normal file
View file

@ -0,0 +1,93 @@
#
# ~/.config/sway/modes
# Modes for sway
#
set {
$alt Mod1
$flag Mod4
}
# Resizing
bindsym $flag+r mode "resize"
mode "resize" bindsym {
l resize grow width 10 px or 10 ppt
k resize grow height 10 px or 10 ppt
h resize shrink width 10 px or 10 ppt
j resize shrink height 10 px or 10 ppt
Shift+l resize grow width 50 px or 50 ppt
Shift+k resize grow height 50 px or 50 ppt
Shift+h resize shrink width 50 px or 50 ppt
Shift+j resize shrink height 50 px or 50 ppt
Right resize grow width 10 px or 10 ppt
Up resize grow height 10 px or 10 ppt
Left resize shrink width 10 px or 10 ppt
Down resize shrink height 10 px or 10 ppt
Shift+Right resize grow width 50 px or 50 ppt
Shift+Up resize grow height 50 px or 50 ppt
Shift+Left resize shrink width 50 px or 50 ppt
Shift+Down resize shrink height 50 px or 50 ppt
$flag+h move left
$flag+j move down
$flag+k move up
$flag+l move right
$flag+Left move left
$flag+Down move down
$flag+Up move up
$flag+Right move right
Return mode "default"
Escape mode "default"
$flag+r mode "default"
}
# System actions
set $mode_system System (l)ock, (s)leep, (h)ibernate, (r)eboot, (Shift+s)hutdown
bindsym Control+$alt+Delete mode "$mode_system"
mode "$mode_system" bindsym {
l exec swaylock && mode "default"
s exec systemctl suspend && mode "default"
h exec systemctl hibernate && mode "default"
r exec systemctl reboot && mode "default"
Shift+s exec systemctl poweroff -i && mode "default"
Return mode "default"
Escape mode "default"
Control+$alt+Delete mode "default"
}
# Screenshots
set $mode_screenshot Screenshot of (a)rea, current (w)indow, (s)creen - Shift to save
set $save_format Pictures/Screenshots/$(date +%F)-$(date +%T).png
bindsym Print mode "$mode_screenshot"
mode "$mode_screenshot" bindsym {
a exec grimshot copy area && mode "default"
w exec grimshot --notify copy active && mode "default"
s exec grimshot --notify copy screen && mode "default"
Print exec grimshot --notify save screen $save_format && mode "default" # Super fast screens!
Shift+a exec grimshot --notify save area $save_format && mode "default"
Shift+w exec grimshot --notify save active $save_format && mode "default"
Shift+s exec grimshot --notify save screen $save_format && mode "default"
Return mode "default"
Escape mode "default"
}
# Some preferences
set $mode_preferences Toggle (s)unset, (n)otifications, (f)ocus
bindsym $alt+end mode "$mode_preferences"
mode "$mode_preferences" bindsym {
s exec "~/.scripts/wlsunset.sh" && mode "default"
n exec "~/.scripts/dnd.sh" && mode "default"
f exec "dunstctl set-paused toggle" && mode "default"
Return mode "default"
Escape mode "default"
$alt+end mode "default"
}

27
config/sway/style Normal file
View file

@ -0,0 +1,27 @@
#
# ~/.config/sway/style
# Styling for sway
#
# Decrease the height of the window bar thing.
font pango:monospace 1
bar {
swaybar_command /usr/bin/waybar
mode hide
}
default_border pixel 1
default_floating_border normal 1
hide_edge_borders both
smart_borders on
# Mimic no titles
# border backgr. text indic. child_border
client.focused #000000 #00897b #00897b #00897b #000000
client.focused_inactive #000000 #222222 #222222 #222222 #000000
client.unfocused #000000 #222222 #222222 #222222 #000000
client.urgent #ff0000 #ff0000 #ff0000 #ff0000 #ff0000
exec gsettings set org.gnome.desktop.interface icon-theme 'IcoSystem'
exec gsettings set org.gnome.desktop.interface gtk-theme 'Nordic'