Skip to content

Instantly share code, notes, and snippets.

@Keithsel
Created September 10, 2024 10:45
Show Gist options
  • Select an option

  • Save Keithsel/6b28d23fe24ac8f94533903a0abac700 to your computer and use it in GitHub Desktop.

Select an option

Save Keithsel/6b28d23fe24ac8f94533903a0abac700 to your computer and use it in GitHub Desktop.
#----------------
#-- Variables: --
#----------------
# Font
font pango:Fira Sans 12
# Logo key as mod
set $mod Mod4
# Home row direction keys, like vim
set $left h
set $down j
set $up k
set $right l
# Terminal
set $term footclient
# Launcher
set $launcher wofi --show drun
# Browser
set $browser zen-browser
# File manager
set $file_manager thunar
# Note taking
set $notes obsidian
# Pomodoro
set $pomodoro i3-gnome-pomodoro
# Background
set $background ~/Pictures/wallpaper.png
# Lock
set $lock swaylock --image $background
# Screenshot
set $screenshot 1 selected, 2 whole, 3 selected clipboard, 4 whole clipboard, 5 swappy
# Workspaces
set $dev "1: Dev"
set $web "2: Web"
set $office "3: Office"
set $media "4: Media"
set $knowledge "5: Knowledge"
set $chat "6: Chat"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $vm "10: VM"
#--------------------------
#-- Application Assign: --
#--------------------------
# Assign workspace
assign [app_id="zen-alpha"] $web
assign [class="Code"] $dev
assign [app_id="mpv"] $media
assign [class="vlc" instance="vlc"] $media
assign [class="obsidian" instance="obsidian"] $knowledge
assign [class="Armcord" instance="armcord"] $chat
assign [class="Signal" instance="signal"] $chat
assign [app_id="io.github.tdesktop_x64.TDesktop"] $chat
# Switch to the window after opening them
for_window [app_id="zen-alpha"] focus
for_window [class="Code"] focus
for_window [app_id="mpv"] focus
for_window [class="vlc" instance="vlc"] focus
for_window [class="obsidian" instance="obsidian"] focus
for_window [class="Armcord" instance="armcord"] focus
for_window [class="Signal" instance="signal"] focus
for_window [app_id="io.github.tdesktop_x64.TDesktop"] focus
# Floating
for_window [app_id="gnome-pomodoro"] floating enable, resize set width 10 ppt height 10 ppt
for_window [window_role="pop-up"] floating enable
for_window [window_role="bubble"] floating enable
for_window [window_role="task_dialog"] floating enable
for_window [window_role="Preferences"] floating enable
for_window [window_type="dialog"] floating enable
for_window [window_type="menu"] floating enable
for_window [window_role="About"] floating enable
for_window [title="File Operation Progress"] floating enable, border pixel 1, sticky enable, resize set width 40 ppt height 30 ppt
for_window [title="Extract"] floating enable, border pixel 1, sticky enable, resize set width 40 ppt height 30 ppt
for_window [app_id="floating_shell_portrait"] floating enable, border pixel 1, sticky enable, resize set width 30 ppt height 40 ppt
for_window [title="Picture in picture"] floating enable, sticky enable
# for_window [title="nmtui"] floating enable, resize set width 50 ppt height 70 ppt
# for_window [title="htop"] floating enable, resize set width 50 ppt height 70 ppt
for_window [title="Save File"] floating enable
for_window [app_id="zen-alpha" title="Firefox — Sharing Indicator"] kill
for_window [app_id="org.gnome.clocks"] floating enable, resize set width 10 ppt height 10 ppt
#floating tkinter apps
for_window [class="Tk"] floating enable, resize set width 30 ppt height 50 ppt
#-----------------
#-- Appearance: --
#-----------------
# Border
default_border none
default_floating_border none
# Gaps
gaps inner 5
# No focus wrapping
focus_wrapping no
# Title format for windows
for_window [shell="xdg_shell"] title_format "%title (%app_id)"
for_window [shell="x_wayland"] title_format "%class - %title"
#-------------------------
#-- Idle Configuration: --
#-------------------------
# Idle
exec swayidle -w\
timeout 1070 'swaylock-effects -e blur -s 10'\
timeout 770 'swaymsg "output * power off"' \
resume 'swaymsg "output * power on"' \
before-sleep exec $lock
#---------------------------
#-- Output Configuration: --
#---------------------------
# Output configuration
output * bg $background fill
#-------------------
#-- Key Bindings: --
#-------------------
# Reload config
bindsym $mod+Shift+r reload
# Start launcher
bindsym $mod+d exec $launcher
# Start terminal
bindsym $mod+Return exec $term
# Reload terminal
bindsym $mod+Shift+f exec "pkill -fx 'foot --server' && foot --server"
# Start browser
bindsym $mod+b exec $browser
# Start file manager
bindsym $mod+e exec $file_manager
# Start notes
bindsym $mod+n exec $notes
# Power menu
bindsym $mod+Shift+e exec wlogout
# Lock
bindsym $mod+Alt+l exec $lock
# Pomodoro
bindsym $mod+F9 exec $pomodoro start
bindsym $mod+F10 exec $pomodoro pause
bindsym $mod+F11 exec $pomodoro skip
bindsym $mod+F12 exec $pomodoro stop
#--------------------
#-- Moving Around: --
#--------------------
# Move focus (Vim style)
bindsym $mod+$left focus left
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right focus right
# Move window (Vim style)
bindsym $mod+Shift+$left move left
bindsym $mod+Shift+$down move down
bindsym $mod+Shift+$up move up
bindsym $mod+Shift+$right move right
# Move window (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 $dev
bindsym $mod+2 workspace $web
bindsym $mod+3 workspace $office
bindsym $mod+4 workspace $media
bindsym $mod+5 workspace $knowledge
bindsym $mod+6 workspace $chat
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
bindsym $mod+0 workspace $vm
# Switch to next/prev workspace
bindsym $mod+comma workspace prev
bindsym $mod+period workspace next
# Move to last visited workspace
bindsym Mod1+Tab workspace back_and_forth
# Move container to workspace
bindsym $mod+Shift+1 move container to workspace $dev
bindsym $mod+Shift+2 move container to workspace $web
bindsym $mod+Shift+3 move container to workspace $office
bindsym $mod+Shift+4 move container to workspace $media
bindsym $mod+Shift+5 move container to workspace $knowledge
bindsym $mod+Shift+6 move container to workspace $chat
bindsym $mod+Shift+7 move container to workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9
bindsym $mod+Shift+0 move container to workspace $vm
# Move to next/prev workspace
bindsym $mod+Shift+comma move container to prev
bindsym $mod+Shift+period move container to next
# Using the same workspace shortcut for moving to last visited workspace
workspace_auto_back_and_forth yes
#----------------------
#-- Layout Handling: --
#----------------------
# Default layout
workspace_layout tabbed
# Full screen
bindsym $mod+f fullscreen
# Close focused window
bindsym $mod+q kill
# Change split orientation
bindsym $mod+v splitv
bindsym $mod+Shift+v splith
# Switch layout style
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+t layout toggle split
# Toggle tiling/floating
bindsym $mod+Shift+space floating toggle
# Swap focus between tiling/floating areas
bindsym $mod+space focus mode_toggle
# Focus parent container
bindsym $mod+a focus parent
# Focus child container
bindsym $mod+Shift+a focus child
#------------------
#-- Scratch Pad: --
#------------------
# Scratchpad
bindsym $mod+Shift+minus move scratchpad
# Show/hide scratchpad
bindsym $mod+minus scratchpad show
# Always a terminal in the scratchpad
bindsym --to-code $mod+Tab exec (swaymsg "[app_id=dropdown] scratchpad show") || exec $term -a dropdown
for_window [app_id="dropdown"] floating enable, \
resize set 60 ppt 60 ppt, \
move position center, \
move to scratchpad, \
scratchpad show
#------------------
#-- Resize Mode: --
#------------------
# Resize mode
mode "resize" {
bindsym $left resize shrink width 10px or 10 ppt
bindsym $down resize grow height 10px or 10 ppt
bindsym $up resize shrink height 10px or 10 ppt
bindsym $right resize grow width 10px or 10 ppt
bindsym Left resize shrink width 10px or 10 ppt
bindsym Down resize grow height 10px or 10 ppt
bindsym Up resize shrink height 10px or 10 ppt
bindsym Right resize grow width 10px or 10 ppt
# Return to default mode
bindsym Escape mode "default"
bindsym Return mode "default"
}
# Enter resize mode
bindsym $mod+r mode "resize"
# Resize to default
bindsym $mod+Shift+Escape exec ~/.config/sway/scripts/reset_sizing.sh
#--------------------
#-- Volume Control --
#--------------------
bindsym --locked XF86AudioRaiseVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%+
bindsym --locked XF86AudioLowerVolume exec set-volume @DEFAULT_AUDIO_SINK@ 2%-
bindsym --locked XF86AudioMute exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
#--------------------
#-- Player Control --
#--------------------
bindsym XF86AudioPlay exec playerctl play
bindsym XF86AudioPause exec playerctl pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
#-----------------------
#-- Backlight Control --
#-----------------------
bindsym XF86MonBrightnessUp exec brightnessctl -c backlight set +5%
bindsym XF86MonBrightnessDown exec brightnessctl -c backlight set 5%-
#----------------
#-- Screenshot --
#----------------
mode "$screenshot" {
bindsym 1 exec 'grim -g "$(slurp)" ~/ps_$(date +"%Y%m%d%H%M%S").png', mode "default"
bindsym 2 exec 'grim ~/ps_$(date +"%Y%m%d%H%M%S").png', mode "default"
bindsym 3 exec 'grim -g "$(slurp)" - | wl-copy', mode "default"
bindsym 4 exec 'grim - | wl-copy', mode "default"
bindsym 5 exec 'grim -g "$(slurp)" - | swappy -f -', mode "default"
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $mod+Print mode "default"
}
bindsym $mod+Print mode "$screenshot"
#------------
#-- Waybar --
#------------
bar {
swaybar_command waybar
}
#-------------------------
#-- Misc Configuration: --
#-------------------------
exec --no-startup-id fcitx5 -d
exec_always --no-startup-id "pgrep -x gnome-polkit > /dev/null || /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1"
exec_always --no-startup-id "pgrep -fx 'foot --server' > /dev/null || foot --server"
include ~/.config/sway/config.d/*
include /etc/sway/config.d/*
# Floating modifier
floating_modifier $mod normal
# Open dotfiles folder in vscode
bindsym $mod+alt+c exec code ~/dotfiles
# Toggle cheatsheet
bindsym $mod+backslash exec ~/.config/sway/scripts/toggle_cheatsheet.sh
for_window [app_id="cheatsheet"] floating enable, \
resize set 45 ppt 50 ppt, \
move position center
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment