# i3 config file

# startup
exec --no-startup-id /usr/bin/dunst
exec --no-startup-id /usr/bin/picom -b
exec --no-startup-id /usr/bin/ibus-daemon -rx

focus_follows_mouse yes
for_window [class=^.*] border none

set $mod Mod4

# font used for i3bar.
font pango:Noto Sans Mono Bold 12

# lock screen
exec --no-startup-id xss-lock --transfer-sleep-lock -- xsecurelock

# to manage the network
exec --no-startup-id nm-applet

# to refresh the status bar
set $refresh_i3status killall -SIGUSR1 i3status

# bindings
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +360 && $refresh_i3status; \
        exec --no-startup-id notify-send "Volume +1%"
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -360 && $refresh_i3status; \
        exec --no-startup-id notify-send "Volumn -1%"
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status; \
        exec --no-startup-id notify-send "Mute toggle"
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status; \
        exec --no-startup-id notify-send "Mute toggle"
bindsym XF86MonBrightnessUp exec --no-startup-id light -A 10; \
        exec --no-startup-id notify-send "Brightness +10%"
bindsym XF86MonBrightnessDown exec --no-startup-id light -U 10; \
        exec --no-startup-id notify-send "Brightness -10%"

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

# start a terminal
bindsym $mod+Return exec alacritty

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

# start dmenu (a program launcher)
bindsym $mod+d exec --no-startup-id dmenu_run -l 8 -fn 'Cantarell-16' -sb "#009999" -sf "#99ffff"

# change focus
bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+l focus up
bindsym $mod+semicolon focus right

# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# move focused window
bindsym $mod+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+semicolon 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

# split in horizontal orientation
bindsym $mod+h split h

# split in vertical orientation
bindsym $mod+v split v

# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

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

# Define names for default workspaces for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"

# 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

# 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

# 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+u restart

# power action
set $System (E)xit-i3 (R)eboot (S)hutdown (Esc)ape-dialog

mode "$System" {
    bindsym e exec --no-startup-id i3-nagbar -f "pango:Cantarell 12" -t warning -m "Confirm exit-i3?" -B "Yes" "i3-msg exit"
    bindsym r exec --no-startup-id i3-nagbar -f "pango:Cantarell 12" -t warning -m "Confirm reboot?" -B "Yes" "systemctl reboot"
    bindsym s exec --no-startup-id i3-nagbar -f "pango:Cantarell 12" -t warning -m "Confirm shutdown?" -B "Yes" "systemctl poweroff"
    bindsym Escape mode "default"
}
bindsym $mod+q mode "$System"

# resize window (you can also use the mouse for that)
mode "Resize" {
    # These bindings trigger as soon as you enter the resize mode

    # Pressing left will shrink the window’s width.
    # Pressing right will grow the window’s width.
    # Pressing up will shrink the window’s height.
    # Pressing down will grow the window’s height.
    bindsym j resize shrink width 10 px or 10 ppt
    bindsym k resize grow height 10 px or 10 ppt
    bindsym l resize shrink height 10 px or 10 ppt
    bindsym semicolon resize grow width 10 px or 10 ppt

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

    # back to normal: Enter or Escape or $mod+r
    bindsym Escape mode "default"
}
bindsym $mod+r mode "Resize"

# i3bar
bar {
    i3bar_command i3bar --transparency
    status_command i3status

    position top
    tray_padding 0

    separator_symbol "`"

    colors {
        background #00000000
        statusline #004599
        separator #000000

        urgent_workspace #ffffff #000000 #ffffff
    }
}
