# [[file:../../Desktop.org::*General settings][General settings:1]]
set $mod Mod4
font pango:monospace 10

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

# Move cursor between monitors
mouse_warping output

# Apply XFCE Settings
# exec xfsettingsd
# exec xiccd

# Set screen layout
exec ~/bin/scripts/screen-layout

# Most needed keybindigs
# reload the configuration file
bindsym $mod+Shift+c reload

# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart

# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
# General settings:1 ends here

# [[file:../../Desktop.org::*Managing windows][Managing windows:1]]
bindsym $mod+Shift+q exec emacs-i3-integration kill
# Managing windows:1 ends here

# [[file:../../Desktop.org::*Managing windows][Managing windows:2]]
bindsym $mod+h exec emacs-i3-integration focus left
bindsym $mod+j exec emacs-i3-integration focus down
bindsym $mod+k exec emacs-i3-integration focus up
bindsym $mod+l exec emacs-i3-integration focus right

bindsym $mod+Left exec emacs-i3-integration focus left
bindsym $mod+Down exec emacs-i3-integration focus down
bindsym $mod+Up exec emacs-i3-integration focus up
bindsym $mod+Right exec emacs-i3-integration focus right
# Managing windows:2 ends here

# [[file:../../Desktop.org::*Managing windows][Managing windows:3]]
bindsym $mod+Shift+h exec emacs-i3-integration move left
bindsym $mod+Shift+j exec emacs-i3-integration move down
bindsym $mod+Shift+k exec emacs-i3-integration move up
bindsym $mod+Shift+l exec emacs-i3-integration move right

bindsym $mod+Shift+Left exec emacs-i3-integration move left
bindsym $mod+Shift+Down exec emacs-i3-integration move down
bindsym $mod+Shift+Up exec emacs-i3-integration move up
bindsym $mod+Shift+Right exec emacs-i3-integration move right
# Managing windows:3 ends here

# [[file:../../Desktop.org::*Managing windows][Managing windows:4]]
bindsym $mod+s exec emacs-i3-integration split h
bindsym $mod+v exec emacs-i3-integration split v
# Managing windows:4 ends here

# [[file:../../Desktop.org::*Managing windows][Managing windows:5]]
bindsym $mod+period exec i3-switch-tabs right
bindsym $mod+comma exec i3-switch-tabs left
# Managing windows:5 ends here

# [[file:../../Desktop.org::*Managing windows][Managing windows:6]]
# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
bindsym $mod+c fullscreen toggle global
# Managing windows:6 ends here

# [[file:../../Desktop.org::*Managing windows][Managing windows:7]]
bindsym $mod+w layout stacking
bindsym $mod+t layout tabbed
bindsym $mod+e exec emacs-i3-integration layout toggle split
# Managing windows:7 ends here

# [[file:../../Desktop.org::*Managing windows][Managing windows:8]]
bindsym $mod+Shift+f floating toggle
bindsym $mod+z focus mode_toggle
# Managing windows:8 ends here

# [[file:../../Desktop.org::*Managing windows][Managing windows:9]]
bindsym $mod+Tab move workspace to output right
bindsym $mod+q focus output right
# Managing windows:9 ends here

# [[file:../../Desktop.org::*Managing windows][Managing windows:10]]
bindsym $mod+a focus parent
bindsym $mod+Shift+A focus child
# Managing windows:10 ends here

# [[file:../../Desktop.org::*Managing windows][Managing windows:11]]
bindsym $mod+Shift+i sticky toggle
# Managing windows:11 ends here

# [[file:../../Desktop.org::*Managing windows][Managing windows:12]]
bindsym $mod+x floating enable; sticky enable; move position 1220 0; resize set width 700 px
# Managing windows:12 ends here

# [[file:../../Desktop.org::*Workspaces][Workspaces:1]]
set $w1 "1 🚀"
set $w2 "2 🌍"
set $w3 "3 💬"
set $w4 "4 🛠️️"
set $w7 "7 🛰️"
set $w8 "8 📝"
set $w9 "9 🎵"
set $w10 "10 📦"

bindsym $mod+1 workspace $w1
bindsym $mod+2 workspace $w2
bindsym $mod+3 workspace $w3
bindsym $mod+4 workspace $w4
bindsym $mod+5 workspace 5
bindsym $mod+6 workspace 6
bindsym $mod+7 workspace $w7
bindsym $mod+8 workspace $w8
bindsym $mod+9 workspace $w9
bindsym $mod+0 workspace $w10

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $w1
bindsym $mod+Shift+2 move container to workspace $w2
bindsym $mod+Shift+3 move container to workspace $w3
bindsym $mod+Shift+4 move container to workspace $w4
bindsym $mod+Shift+5 move container to workspace 5
bindsym $mod+Shift+6 move container to workspace 6
bindsym $mod+Shift+7 move container to workspace $w7
bindsym $mod+Shift+8 move container to workspace $w8
bindsym $mod+Shift+9 move container to workspace $w9
bindsym $mod+Shift+0 move container to workspace $w10
# Workspaces:1 ends here

# [[file:../../Desktop.org::*Rules][Rules:1]]
assign [class="Emacs"] $w1
assign [class="qutebrowser"] $w2
assign [class="firefox"] $w2
assign [class="VK"] $w3
assign [class="Slack"] $w3
assign [class="discord"] $w3
assign [class="TelegramDesktop"] $w3
assign [class="Postman"] $w4
assign [class="Chromium-browse"] $w4
assign [class="chromium"] $w4
assign [class="google-chrome"] $w4
assign [title="Vue Developer Tools"] $w4
assign [class="Google Play Music Desktop Player"] $w9
assign [class="jetbrains-datagrip"] $w4
assign [class="zoom"] $w7
assign [class="skype"] $w7
assign [class="Mailspring"] $w8
assign [class="Thunderbird"] $w8
assign [class="Joplin"] $w8
assign [class="keepassxc"] $w10

for_window [title="VirtScreen"] floating enable

for_window [title="ncmpcpp.*"] move to workspace $w9
for_window [title="newsboat.*"] move to workspace $w9
for_window [title=".*run_wego"] move to workspace $w9
for_window [class="cinnamon-settings*"] floating enable
for_window [title="Picture-in-Picture"] sticky enable
for_window [window_role="GtkFileChooserDialog"] resize set width 1000 px height 800 px
for_window [window_role="GtkFileChooserDialog"] move position center
# Rules:1 ends here

# [[file:../../Desktop.org::*i3 config][i3 config:1]]
# Scratchpad
for_window [instance="dropdown_*"] floating enable
for_window [instance="dropdown_*"] move scratchpad
for_window [instance="dropdown_*"] sticky enable
for_window [instance="dropdown_*"] scratchpad show
for_window [instance="dropdown_*"] move position center

bindsym $mod+u exec ~/bin/scripts/dropdown
# i3 config:1 ends here

# [[file:../../Desktop.org::*Gaps & borders][Gaps & borders:1]]
# Borders
# for_window [class=".*"] border pixel 0
default_border pixel 3
hide_edge_borders both

# Gaps
set $default_inner 10
set $default_outer 0

gaps inner $default_inner
gaps outer $default_outer

smart_gaps on
# Gaps & borders:1 ends here

# [[file:../../Desktop.org::*Keybindings][Keybindings:1]]
mode "inner gaps" {
    bindsym plus gaps inner current plus 5
    bindsym minus gaps inner current minus 5
    bindsym Shift+plus gaps inner all plus 5
    bindsym Shift+minus gaps inner all minus 5
    bindsym 0 gaps inner current set 0
    bindsym Shift+0 gaps inner all set 0

    bindsym r gaps inner current set $default_inner
    bindsym Shift+r gaps inner all set $default_inner

    bindsym Return mode "default"
    bindsym Escape mode "default"
}

mode "outer gaps" {
    bindsym plus gaps outer current plus 5
    bindsym minus gaps outer current minus 5
    bindsym Shift+plus gaps outer all plus 5
    bindsym Shift+minus gaps outer all minus 5
    bindsym 0 gaps outer current set 0
    bindsym Shift+0 gaps outer all set 0

    bindsym r gaps outer current set $default_outer
    bindsym Shift+r gaps outer all set $default_outer

    bindsym Return mode "default"
    bindsym Escape mode "default"
}

bindsym $mod+g mode "inner gaps"
bindsym $mod+Shift+g mode "outer gaps"
# Keybindings:1 ends here

# [[file:../../Desktop.org::*Move & resize windows][Move & resize windows:2]]
mode "resize" {

    bindsym h exec emacs-i3-integration resize shrink width 10 px or 10 ppt
    bindsym j exec emacs-i3-integration resize grow height 10 px or 10 ppt
    bindsym k exec emacs-i3-integration resize shrink height 10 px or 10 ppt
    bindsym l exec emacs-i3-integration resize grow width 10 px or 10 ppt

    bindsym Shift+h exec emacs-i3-integration resize shrink width 100 px or 100 ppt
    bindsym Shift+j exec emacs-i3-integration resize grow height 100 px or 100 ppt
    bindsym Shift+k exec emacs-i3-integration resize shrink height 100 px or 100 ppt
    bindsym Shift+l exec emacs-i3-integration resize grow width 100 px or 100 ppt

    # same bindings, but for the arrow keys
    bindsym Left  exec emacs-i3-integration resize shrink width 10 px or 10 ppt
    bindsym Down  exec emacs-i3-integration resize grow height 10 px or 10 ppt
    bindsym Up    exec emacs-i3-integration resize shrink height 10 px or 10 ppt
    bindsym Right exec emacs-i3-integration resize grow width 10 px or 10 ppt

    bindsym Shift+Left  exec emacs-i3-integration resize shrink width 100 px or 100 ppt
    bindsym Shift+Down  exec emacs-i3-integration resize grow height 100 px or 100 ppt
    bindsym Shift+Up    exec emacs-i3-integration resize shrink height 100 px or 100 ppt
    bindsym Shift+Right exec emacs-i3-integration resize grow width 100 px or 100 ppt

    bindsym equal exec i3-emacs-balance-windows

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
}

bindsym $mod+r mode "resize"

mode "move" {
    bindsym $mod+Tab focus right

    bindsym Left  move left
    bindsym Down  move down
    bindsym Up    move up
    bindsym Right move right

    bindsym h     move left
    bindsym j     move down
    bindsym k     move up
    bindsym l     move right

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
}

bindsym $mod+m mode "move" focus floating
# Move & resize windows:2 ends here

# [[file:../../Desktop.org::*Integration with rofi][Integration with rofi:1]]
bindsym $mod+p exec "rofi -modi 'drun,run' -show drun"
bindsym $mod+b exec --no-startup-id rofi-buku-mine
bindsym $mod+minus exec rofi-pass
bindsym $mod+equal exec rofimoji

bindsym $mod+apostrophe mode "rofi"

mode "rofi" {
    bindsym d exec "rofi -modi 'drun,run' -show drun"
    bindsym m exec rofi-man; mode default
    bindsym b exec rofi-buku-mine; mode default
    bindsym k exec rofi-pass; mode default
    bindsym Escape mode "default"
}
# Integration with rofi:1 ends here

# [[file:../../Desktop.org::*Apps][Apps:1]]
# Launch apps
# start a terminal at workspace 1
bindsym $mod+Return exec "i3-msg 'workspace 1 🚀; exec alacritty'"

bindsym $mod+i exec "copyq menu"
bindsym $mod+Shift+x exec "i3lock -f -i /home/pavel/Pictures/lock-wallpaper.png"

bindsym $mod+semicolon mode "apps"

mode "apps" {
    bindsym Escape mode "default"
    bindsym b exec firefox; mode default
    bindsym v exec vk; mode default
    bindsym s exec slack-wrapper; mode default;
    bindsym d exec "flatpak run com.discordapp.Discord"; mode default;
    bindsym m exec "alacritty -e ncmpcpp"; mode default
    bindsym c exec "copyq toggle"; mode default
    bindsym k exec "keepassxc"; mode default
    # bindsym e exec mailspring; mode default
    bindsym a exec emacs; mode default
    bindsym n exec "alacritty -e newsboat"; mode default
    bindsym w exec "alacritty /home/pavel/bin/scripts/run_wego"; mode default
    # bindsym a exec emacsclient -c; mode default
    # bindsym Shift+a exec emacs; mode default
}
# Apps:1 ends here

# [[file:../../Desktop.org::*Media controls & brightness][Media controls & brightness:1]]
# Pulse Audio controls
bindsym XF86AudioRaiseVolume exec --no-startup-id "ponymix increase 5 --max-volume 150"
bindsym XF86AudioLowerVolume exec --no-startup-id "ponymix decrease 5 --max-volume 150"
bindsym XF86AudioMute exec --no-startup-id "ponymix toggle"

exec --no-startup-id xmodmap -e 'keycode 135 = Super_R' && xset -r 135
bindsym $mod+F2 exec --no-startup-id "ponymix increase 5"
bindsym $mod+F3 exec --no-startup-id "ponymix decrease 5"

# Media player controls
bindsym XF86AudioPlay exec mpc toggle
bindsym XF86AudioPause exec mpc pause
bindsym XF86AudioNext exec mpc next
bindsym XF86AudioPrev exec mpc prev

# Screen brightness
bindsym XF86MonBrightnessUp exec light -A 5
bindsym XF86MonBrightnessDown exec light -U 5
# Media controls & brightness:1 ends here

# [[file:../../Desktop.org::*Screenshots][Screenshots:1]]
# Screenshots
bindsym --release Print exec "flameshot gui"
bindsym --release Shift+Print exec "xfce4-screenshooter"
# Screenshots:1 ends here

# [[file:../../Desktop.org::*Colors][Colors:1]]
exec xrdb -merge $HOME/.Xresources

# Colors
set_from_resource $bg-color            background
set_from_resource $active-color        color4
set_from_resource $inactive-bg-color   color8
set_from_resource $text-color          foreground
set_from_resource $inactive-text-color color7
set_from_resource $urgent-bg-color     color1
set_from_resource $urgent-text-color   color0

# window colors
#                       border              background         text                 indicator       child border
client.focused          $active-color       $bg-color          $text-color          $bg-color       $active-color
client.unfocused        $bg-color           $inactive-bg-color $inactive-text-color $bg-color       $bg-color
client.focused_inactive $active-color       $inactive-bg-color $inactive-text-color $bg-color       $bg-color
client.urgent           $urgent-bg-color    $urgent-bg-color   $urgent-text-color   $bg-color       $urgent-bg-color
# Colors:1 ends here

# [[file:../../Desktop.org::*Keyboard Layout][Keyboard Layout:3]]
# Layout
exec_always --no-startup-id set_layout
bindsym $mod+slash exec toggle_layout
# Keyboard Layout:3 ends here

# [[file:../../Desktop.org::*Autostart][Autostart:1]]
# Polybar
exec_always --no-startup-id "bash /home/pavel/bin/polybar.sh"

# Wallpaper
exec_always "feh --bg-fill ~/Pictures/wallpaper.jpg"

# Picom
exec picom

# Keynav
exec keynav

# Applets
exec --no-startup-id nm-applet
# exec --no-startup-id /usr/bin/blueman-applet

exec shepherd
exec dunst
exec copyq
exec "xmodmap ~/.Xmodmap"
# exec "xrdb -merge ~/.Xresources"
# exec "bash ~/bin/autostart.sh"
# Autostart:1 ends here
