add sway config

This commit is contained in:
Jonas H
2026-02-27 22:35:06 +01:00
parent 5c56d99d6f
commit 977e839eb7
7 changed files with 293 additions and 0 deletions

154
sway/.config/sway/config Normal file
View File

@@ -0,0 +1,154 @@
exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
exec_always /home/jonas/.pyenv/shims/autotiling -l 2
exec_always eww daemon && (eww open bar0 || true) && (eww open bar1 || true)
exec_always mako
exec swayidle -w \
timeout 900 '~/.local/bin/smart-dim.sh' \
resume 'brightnessctl -r'
exec sh -c 'sleep 1 && timeout 0.05 speaker-test -t sine -f 800 >/dev/null 2>&1 & sleep 0.2 && wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.2'
mouse_warping container
focus_on_window_activation focus
include /home/jonas/.config/sway/windowrules
include /home/jonas/.config/sway/look
include /home/jonas/.config/sway/monitors
include /home/jonas/.config/sway/input
### Variables
set $mod Mod4
set $alt Mod1
# Home row direction keys, like vim
set $left h
set $down j
set $up k
set $right l
set $term wezterm
set $menu fuzzel
set $browser firefox
### Key bindings
# Basics:
bindsym $mod+Return exec $term
bindsym $mod+Shift+Return exec ~/.config/sway/scripts/smart-term.sh
bindsym $mod+q kill
bindsym $mod+space exec "pkill fuzzel || fuzzel"
bindsym $mod+b exec $browser
bindsym $mod+Shift+g exec ~/.config/sway/scripts/gif-record.sh
# mouse button for dragging.
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'
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
# Move the focused window with the same, but add 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
# Workspaces:
# Switch to workspace
bindsym $mod+1 workspace number 1
bindsym $mod+a workspace number 1
bindsym $mod+2 workspace number 2
bindsym $mod+s workspace number 2
bindsym $mod+3 workspace number 3
bindsym $mod+d workspace number 3
bindsym $mod+4 workspace number 4
bindsym $mod+z workspace number 4
bindsym $mod+5 workspace number 5
bindsym $mod+x workspace number 5
bindsym $mod+6 workspace number 6
bindsym $mod+7 workspace number 7
bindsym $mod+8 workspace number 8
bindsym $mod+9 workspace number 9
bindsym $mod+0 workspace number 10
# Move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number 1
bindsym $mod+Shift+a move container to workspace number 1
bindsym $mod+Shift+2 move container to workspace number 2
bindsym $mod+Shift+s move container to workspace number 2
bindsym $mod+Shift+3 move container to workspace number 3
bindsym $mod+Shift+d move container to workspace number 3
bindsym $mod+Shift+4 move container to workspace number 4
bindsym $mod+Shift+z move container to workspace number 4
bindsym $mod+Shift+5 move container to workspace number 5
bindsym $mod+Shift+x move container to workspace number 5
bindsym $mod+Shift+6 move container to workspace number 6
bindsym $mod+Shift+7 move container to workspace number 7
bindsym $mod+Shift+8 move container to workspace number 8
bindsym $mod+Shift+9 move container to workspace number 9
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.
#
# Layout stuff:
# bindsym $mod+s layout stacking
# bindsym $mod+w layout tabbed
bindsym $mod+t toggle split
bindsym $mod+f fullscreen
bindsym $mod+Shift+space floating toggle
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 50px
bindsym $down resize grow height 50px
bindsym $up resize shrink height 50px
bindsym $right resize grow width 50px
# Ditto, with arrow keys
bindsym Left resize shrink width 50px
bindsym Down resize grow height 50px
bindsym Up resize shrink height 50px
bindsym Right resize grow width 50px
# Return to default mode
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"
#
# Utilities:
#
# Special keys to adjust volume via PulseAudio
bindsym --locked XF86AudioMute exec pactl set-sink-mute \@DEFAULT_SINK@ toggle
bindsym --locked XF86AudioLowerVolume exec pactl set-sink-volume \@DEFAULT_SINK@ -5%
bindsym --locked XF86AudioRaiseVolume exec pactl set-sink-volume \@DEFAULT_SINK@ +5%
bindsym --locked XF86AudioMicMute exec pactl set-source-mute \@DEFAULT_SOURCE@ toggle
# Special keys to adjust brightness via brightnessctl
bindsym --locked XF86MonBrightnessDown exec brightnessctl set 1%-
bindsym --locked XF86MonBrightnessUp exec brightnessctl set 1%+
bindsym --locked Shift+XF86MonBrightnessUp exec brightnessctl --device=kbd_backlight set 1%+
bindsym --locked Shift+XF86MonBrightnessDown exec brightnessctl --device=kbd_backlight set 1%-
include /etc/sway/config.d/*

14
sway/.config/sway/input Normal file
View File

@@ -0,0 +1,14 @@
input * {
xkb_layout dk_mac_fixed
xkb_options lv3:lalt_switch
pointer_accel 0
}
input "type:touchpad" {
natural_scroll disabled
tap disabled
click_method clickfinger
scroll_factor 0.4
dwt disabled
}

21
sway/.config/sway/look Normal file
View File

@@ -0,0 +1,21 @@
include /home/jonas/.config/colors
default_border pixel 2
default_floating_border none
titlebar_padding 1
gaps inner 5
gaps outer 8
# Focused window border
client.focused $border $border $border $border $border
# Unfocused window border
client.focused_inactive $bg_inactive $bg_inactive $bg_inactive $bg_inactive $bg_inactive
client.unfocused $bg_inactive $bg_inactive $bg_inactive $bg_inactive $bg_inactive
client.urgent $urgent $urgent $urgent $urgent $urgent
client.placeholder $bg_inactive $bg_inactive $bg_inactive $bg_inactive $bg_inactive
#swayfx
corner_radius 5
default_dim_inactive 0.15

View File

@@ -0,0 +1,14 @@
set $res_x 3024
set $res_y 1890
set $scale 1.5
output eDP-1 resolution $res_xx$res_y position 0,1445 scale $scale
output HDMI-A-1 position 0,0 scale 1.5
output DVI-I-2 position -2560,0 scale 1.5
output DVI-I-1 position -5120,0 scale 1.5
# You can get the names of your outputs by running: swaymsg -t get_outputs

View File

@@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Log file for debugging
LogFile=/tmp/gif-record.log
exec 2>>$LogFile
# If an instance of wf-recorder is running under this user kill it with SIGINT and exit
pkill --euid "$USER" --signal SIGINT wf-recorder && notify-send "GIF Recording" "Recording stopped, processing..." && exit
# Define paths
DefaultSaveDir=$HOME'/Videos'
TmpPathPrefix='/tmp/gif-record'
TmpRecordPath=$TmpPathPrefix'-cap.mp4'
TmpPalettePath=$TmpPathPrefix'-palette.png'
# Trap for cleanup on exit
OnExit() {
[[ -f $TmpRecordPath ]] && rm -f "$TmpRecordPath"
[[ -f $TmpPalettePath ]] && rm -f "$TmpPalettePath"
}
trap OnExit EXIT
# Set umask so tmp files are only acessible to the user
umask 177
# Get selection and honor escape key
Coords=$(slurp) || exit
notify-send "GIF Recording" "Recording started. Press $mod+Shift+G to stop."
# Capture video using slup for screen area
# timeout and exit after 10 minutes as user has almost certainly forgotten it's running
timeout 600 wf-recorder -g "$Coords" -f "$TmpRecordPath" || { notify-send "GIF Recording" "Recording failed"; exit; }
# Get the filename from the user and honor cancel
SavePath=$( zenity \
--file-selection \
--save \
--confirm-overwrite \
--file-filter=*.gif \
--filename="$DefaultSaveDir"'/.gif' \
) || exit
# Append .gif to the SavePath if it's missing
[[ $SavePath =~ \.gif$ ]] || SavePath+='.gif'
# Produce a pallete from the video file
ffmpeg -i "$TmpRecordPath" -filter_complex "palettegen=stats_mode=full" "$TmpPalettePath" -y || { notify-send "GIF Recording" "Palette generation failed"; exit; }
# Return umask to default
umask 022
# Use pallete to produce a gif from the video file
ffmpeg -i "$TmpRecordPath" -i "$TmpPalettePath" -filter_complex "paletteuse=dither=sierra2_4a" "$SavePath" -y || { notify-send "GIF Recording" "GIF conversion failed"; exit; }
notify-send "GIF Recording" "GIF saved to $SavePath"

View File

@@ -0,0 +1,25 @@
#!/bin/bash
# Opens a new terminal, using the current terminal's working directory if focused window is a terminal
# Get focused window info from Sway
focused_info=$(swaymsg -t get_tree | jq -r '.. | select(.focused? == true) | {app_id: .app_id, name: .name}')
app_id=$(echo "$focused_info" | jq -r '.app_id')
window_name=$(echo "$focused_info" | jq -r '.name')
if [ "$app_id" = "org.wezfurlong.wezterm" ]; then
# Match the Sway window title with wezterm's window_title to get the correct pane's cwd
cwd=$(wezterm cli list --format json 2>/dev/null | jq -r --arg title "$window_name" '.[] | select(.window_title == $title) | .cwd' | head -n 1)
if [ -n "$cwd" ] && [ "$cwd" != "null" ]; then
# Remove file:// prefix and hostname (format: file://hostname/path)
cwd=$(echo "$cwd" | sed 's|^file://[^/]*/|/|')
if [ -d "$cwd" ]; then
wezterm start --cwd "$cwd" &
exit 0
fi
fi
fi
# Fallback: open terminal in home directory
wezterm &

View File

@@ -0,0 +1,9 @@
for_window [app_id="hooknloop"] floating enable
for_window [app_id="lego-build"] floating enable
for_window [instance="LEGO_Brain"] floating enable
for_window [app_id="lego_brain"] floating enable
for_window [app_id="snow_trail"] floating enable
for_window [instance="sameboy"] floating enable
for_window [class="feh"] floating enable
for_window [app_id="mpv"] floating enable
for_window [class="snow_trail_sdl"] floating enable