## variables ##

# Logo key. Use Mod1 for Alt.
set $mod Mod4
set $left h
set $down j
set $up k
set $right l
set $term foot
set $menu "rofi -modi drun,run -show drun"
set $locker "swaylock -f -i ~/.config/sway/lockscreen.png --indicator-radius 100"

## output configuration ##

# default wallpaper
output * bg ~/.config/sway/wallpaper.png fill

## sway session ##

# lock sway session after closing laptop lid
bindswitch --locked lid:toggle exec $locker && systemctl sleep

## input configuration ##

input type:touchpad {
  dwt enabled
  tap enabled
  natural_scroll disabled
  middle_emulation enabled
}

input type:keyboard {
  xkb_layout "pl"
}

## basic key bindings ##

# start a terminal
bindsym $mod+Return exec $term

# kill focused window
bindsym $mod+Shift+q kill

# start your launcher
bindsym $mod+d exec $menu

# rofi-pass
bindsym $mod+p exec ~/.local/bin/rofi-pass

# drop-down terminal
# bindsym $mod+b exec foot

# 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

# shortcut for locking screen
bindsym $mod+x exec $locker

# reload the configuration file
bindsym $mod+Shift+r reload

# exit sway (logs you out of your Wayland session)
set $mode_system (l)ock, l(o)gout, (s)uspend, (h)ibernate, (r)eboot, shu(t)down
mode "$mode_system" {
    bindsym l exec --no-startup-id $locker, mode "default"
    bindsym o exec --no-startup-id i3-msg exit, mode "default"
    bindsym s exec --no-startup-id $locker && systemctl suspend, mode "default"
    bindsym r exec --no-startup-id systemctl reboot, mode "default"
    bindsym h exec --no-startup-id systemctl hibernate, mode "default"
    bindsym t exec --no-startup-id systemctl poweroff -i, mode "default"

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+Shift+e mode "$mode_system"

# 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@ -1%
bindsym --locked XF86AudioRaiseVolume exec pactl set-sink-volume \@DEFAULT_SINK@ +1%
bindsym --locked XF86AudioMicMute exec pactl set-source-mute \@DEFAULT_SOURCE@ toggle

# special keys to adjust brightness via brightnessctl
bindsym --locked XF86MonBrightnessDown exec brightnessctl set 5%-
bindsym --locked XF86MonBrightnessUp exec brightnessctl set 5%+

# special key to take a screenshot with grim
bindsym Print exec grim

## moving around ##

# move your focus around
bindsym $mod+$left focus left
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right focus 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
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 ##

# define workspaces
set $ws1 "1: "
set $ws2 "2: "
set $ws3 "3: "
set $ws4 "4: "
set $ws5 "5: "
set $ws6 "6: Libreoffice"
set $ws7 "7: Wirtualki"
set $ws8 "8: Torrenty"
set $ws9 "9: Soulseek"
set $ws10 "10: Seamonkey"
set $wsF1 "11"
set $wsF2 "12"
set $wsF3 "13"
set $wsF4 "14"
set $wsF5 "15"
set $wsF6 "16"
set $wsF7 "17"
set $wsF8 "18"
set $wsF9 "19: Tor Browser"
set $wsF10 "20: "
set $wsF11 "21: KeePass"
set $wsF12 "22: Inne"

# switch to workspace
bindsym $mod+1 workspace number $ws1
bindsym $mod+2 workspace number $ws2
bindsym $mod+3 workspace number $ws3
bindsym $mod+4 workspace number $ws4
bindsym $mod+5 workspace number $ws5
bindsym $mod+6 workspace number $ws6
bindsym $mod+7 workspace number $ws7
bindsym $mod+8 workspace number $ws8
bindsym $mod+9 workspace number $ws9
bindsym $mod+0 workspace number $ws10
bindsym $mod+F1 workspace number $wsF1
bindsym $mod+F2 workspace number $wsF2
bindsym $mod+F3 workspace number $wsF3
bindsym $mod+F4 workspace number $wsF4
bindsym $mod+F5 workspace number $wsF5
bindsym $mod+F6 workspace number $wsF6
bindsym $mod+F7 workspace number $wsF7
bindsym $mod+F8 workspace number $wsF8
bindsym $mod+F9 workspace number $wsF9
bindsym $mod+F10 workspace number $wsF10
bindsym $mod+F11 workspace number $wsF11
bindsym $mod+F12 workspace number $wsF12

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number $ws1
bindsym $mod+Shift+2 move container to workspace number $ws2
bindsym $mod+Shift+3 move container to workspace number $ws3
bindsym $mod+Shift+4 move container to workspace number $ws4
bindsym $mod+Shift+5 move container to workspace number $ws5
bindsym $mod+Shift+6 move container to workspace number $ws6
bindsym $mod+Shift+7 move container to workspace number $ws7
bindsym $mod+Shift+8 move container to workspace number $ws8
bindsym $mod+Shift+9 move container to workspace number $ws9
bindsym $mod+Shift+0 move container to workspace number $ws10
bindsym $mod+Shift+F1 move container to workspace number $wsF1
bindsym $mod+Shift+F2 move container to workspace number $wsF2
bindsym $mod+Shift+F3 move container to workspace number $wsF3
bindsym $mod+Shift+F4 move container to workspace number $wsF4
bindsym $mod+Shift+F5 move container to workspace number $wsF5
bindsym $mod+Shift+F6 move container to workspace number $wsF6
bindsym $mod+Shift+F7 move container to workspace number $wsF7
bindsym $mod+Shift+F8 move container to workspace number $wsF8
bindsym $mod+Shift+F9 move container to workspace number $wsF9
bindsym $mod+Shift+F10 move container to workspace number $wsF10
bindsym $mod+Shift+F11 move container to workspace number $wsF11
bindsym $mod+Shift+F12 move container to workspace number $wsF12

# window assignments
assign [app_id="[Ff]irefox"] $ws2
assign [app_id="[Ii]ce[Ww]easel"] $ws2
assign [app_id="[Aa]browser"] $ws2
assign [app_id="[Ll]ibre[Ww]olf"] $ws2
assign [app_id="[Cc]hromium"] $ws3
assign [app_id="[Tt]hunderbird"] $ws4
assign [class="[Ee]macs"] $ws5
assign [app_id="[Ll]ibreoffice.*"] $ws6
assign [app_id="[Vv]irt.*[Mm]anager"] $ws7
assign [app_id="[Vv]irt.*[Vv]iewer"] $ws7
assign [app_id="[Qq]emu"] $ws7
assign [app_id="q[Bb]ittorrent"] $ws8
assign [app_id="[Nn]icotine"] $ws9
assign [class="[Ss]ea[Mm]onkey"] $ws10
assign [app_id="[Tt]or.*[Bb]rowser"] $wsF9
assign [app_id="[Kk]iwix"] $wsF10
assign [app_id="[Kk]ee[Pp]ass"] $wsF11
assign [app_id="[Mm]ullvad.*"] $wsF12
assign [app_id="[Gg]alaxy.*[Bb]uds.*[Cc]lient"] $wsF12
assign [app_id="qutebrowser"] $wsF12
assign [app_id="[Tt]hunar"] $wsF12
assign [app_id="[Ll]uakit"] $wsF12
for_window [app_id="[Tt]or\s*[Bb]rowser"] floating enable, border normal
for_window [app_id="[Ff]lame[Ss]hot"] floating enable, border normal
for_window [class="[Pp]inentry"] floating enable, border normal

## layout ##

# set default workspace layout
workspace_layout tabbed

# changing layout
bindsym $mod+Control+h splith
bindsym $mod+Control+v splitv
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# make the current focus fullscreen
bindsym $mod+f fullscreen

# toggle the current focus between tiling and floating mode
bindsym $mod+Shift+space floating toggle

# swap focus between the tiling area and the floating area
bindsym $mod+space focus mode_toggle

# move focus to the parent container
bindsym $mod+a focus parent

## scratchpad ##

# move the currently focused window to the scratchpad
bindsym $mod+Shift+minus move scratchpad

# show the next scratchpad window or hide the focused scratchpad window.
# if there are multiple scratchpad windows, this command cycles through them.
bindsym $mod+minus scratchpad show

## resizing containers ##

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

    # return to default mode
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"

## hide title bar ##
font pango:Iosevka,Font Awesome 7 Free,Font Awesome 7 Brands 11
titlebar_border_thickness 0
titlebar_padding 0
hide_edge_borders --smart-titles both

## status bar ##
bar {
    position top
    status_command i3blocks -c ~/.config/i3blocks/i3blocks.conf
    font pango:Iosevka,Font Awesome 7 Free,Font Awesome 7 Brands 13

    colors {
        statusline #ffffff
        background #00000099
        separator #000000

        focused_workspace  #34003f #6e0284 #ffffff
        #active_workspace   #333333 #5f676a #ffffff
        inactive_workspace #220028 #35013f #888888
        urgent_workspace   #470801 #630000 #ffffff
        #binding_mode       #2f343a #900000 #ffffff
    }
}

## color scheme for windows ##
#                       border          background      text            indicator (a line which shows where the next window will be placed)
client.focused          #0b4701         #044f00         #ffffff         #0b4701
client.unfocused        #072d00         #023000         #969696         #072d00
client.focused_inactive #072d00         #023000         #969696         #072d00
client.urgent           #630000         #630000         #ffffff         #630000

## don't follow focus with mouse ##
focus_follows_mouse no

## run pure wayland session ##
# xwayland disable

## autostart ##
exec chromium
exec iceweasel
exec thunderbird
workspace number $ws1
exec foot

include /etc/sway/config.d/*
