###############
#             #
# ██╗██████╗  #
# ██║╚════██╗ #
# ██║ █████╔╝ #
# ██║ ╚═══██╗ #
# ██║██████╔╝ #
# ╚═╝╚═════╝  #
#             #
###############

# Required packages:
# - i3-gaps
# - alacritty
# - rofi
# - rofi-calc
# - polybar (AUR)
# - dunst
# - picom
# - playerctl - for media keys

### Basic stuff ###

for_window [class="^.*"] border pixel 2
for_window [instance="floatme"] floating enable

for_window [instance="scratchpad.*"] move scratchpad
for_window [class="Spotify"] move scratchpad

gaps inner 4
smart_gaps on
smart_borders on
font pango:monospace 8
workspace_auto_back_and_forth yes
### Definitions ###

# Define workspace
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"

# Set mod key
set $mod Mod4 
set $altMod Control

### Colors ###
#class                 	 border  backgr. text    indicator 	child_border
client.focused           #ff9900 #ff9900 #ff9900 $indicator	$border
#client.focused_inactive #333333 #5f676a #ffffff #484e50   #5f676a
#client.unfocused        #333333 #222222 #888888 #292d2e   #222222
#client.urgent           #2f343a #900000 #ffffff #900000   #900000
#client.placeholder      #000000 #0c0c0c #ffffff #000000   #0c0c0c

#client.background       #ffffff

### i3 keybindings ###

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

# change focus
bindsym $mod+h 					focus left
bindsym $mod+j 					focus down
bindsym $mod+k 					focus up
bindsym $mod+l 					focus right
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+h 			move left
bindsym $mod+Shift+j			move down
bindsym $mod+Shift+k 			move up
bindsym $mod+Shift+l 			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

bindsym $mod+b 					split h
bindsym $mod+v 					split v

bindsym $mod+f 					fullscreen toggle

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

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

# toggle scratchpad
bindsym $mod+F1 [instance="scratchpad_f1"] scratchpad show
bindsym $mod+F2 [class="Spotify"] scratchpad show
bindsym $mod+F3 [instance="scratchpad_f3"] scratchpad show
bindsym $mod+F4 [instance="scratchpad_f4"] scratchpad show

# switch to workspace
bindsym $mod+1 					workspace $ws1
bindsym $mod+2 					workspace $ws2
bindsym $mod+3 					workspace $ws3
bindsym $mod+4 					workspace $ws4
bindsym $mod+5 					workspace $ws5
bindsym $mod+6 					workspace $ws6
bindsym $mod+7 					workspace $ws7
bindsym $mod+8 					workspace $ws8
bindsym $mod+9 					workspace $ws9
bindsym $mod+0 					workspace $ws10

bindsym $mod+Tab				workspace next
bindsym $mod+Shift+Tab			workspace prev

# move focused container to workspace
bindsym $altMod+Shift+1 			move container to workspace $ws1
bindsym $altMod+Shift+2 			move container to workspace $ws2
bindsym $altMod+Shift+3 			move container to workspace $ws3
bindsym $altMod+Shift+4 			move container to workspace $ws4
bindsym $altMod+Shift+5 			move container to workspace $ws5
bindsym $altMod+Shift+6 			move container to workspace $ws6
bindsym $altMod+Shift+7 			move container to workspace $ws7
bindsym $altMod+Shift+8 			move container to workspace $ws8
bindsym $altMod+Shift+9 			move container to workspace $ws9
bindsym $altMod+Shift+0 			move container to workspace $ws10

bindsym $mod+Shift+r 			restart

# resize window 
mode "resize" {
        bindsym h 				resize shrink width 5 px or 5 ppt
        bindsym j 				resize grow height 5 px or 5 ppt
        bindsym k 				resize shrink height 5 px or 5 ppt
        bindsym l 				resize grow width 5 px or 5 ppt
        bindsym Left 			resize shrink width 5 px or 5 ppt
        bindsym Down 			resize grow height 5 px or 5 ppt
        bindsym Up 				resize shrink height 5 px or 5 ppt
        bindsym Right 			resize grow width 5 px or 5 ppt

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

bindsym $mod+r 					mode "resize"

#bindsym $mod+p					gaps inner current plus 5
#bindsym $mod+Shift+p			gaps inner current minus 5

bindsym $mod+Shift+q 			exec --no-startup-id ~/.config/i3/killScript.sh

### misc keybindings ###

# bindsym $mod+l exec 			i3lock -i /usr/share/backgrounds/gnome/RainDrops.jpg
bindsym $mod+Return 			exec --no-startup-id alacritty
bindsym $mod+d exec 			rofi -show drun -show-icons

bindsym $mod+Shift+e 			exec rofi -show script -modi script:$HOME/.config/i3/pm.sh
bindsym $mod+s					exec $HOME/.config/rofi/rofi-quick-action.sh
bindsym $mod+Shift+s			exec rofi -modi blocks -show blocks -blocks-wrap /usr/share/rofi-blocks-search/ddg
bindsym $mod+a					exec --no-startup-id rofi -show calc -modi calc -no-show-match -no-sort
bindsym XF86MonBrightnessUp 	exec --no-startup-id light -A 5
bindsym XF86MonBrightnessDown 	exec --no-startup-id light -U 5

bindsym XF86AudioRaiseVolume	exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10%
bindsym XF86AudioLowerVolume	exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10%
bindsym XF86AudioMute 			exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle

bindsym XF86TouchpadToggle		exec --no-startup-id $HOME/.config/i3/touchpadToggle.sh

bindsym XF86AudioNext			exec --no-startup-id "playerctl --player=spotify,%any next"
bindsym XF86AudioPrev			exec --no-startup-id "playerctl --player=spotify,%any previous"
bindsym XF86AudioPlay			exec --no-startup-id "playerctl --player=spotify,%any play-pause"

bindsym $mod+m					exec --no-startup-id $XDG_DATA_HOME/scripts/toggle-mute.sh && polybar-msg hook mute-mic 1

bindsym $mod+Shift+w			exec --no-startup-id networkmanager_dmenu

### autostart ###

exec --no-startup-id			picom -b
exec --no-startup-id 			feh --bg-scale ~/.cache/last-bg
exec_always --no-startup-id 	$HOME/.config/polybar/launch.sh
#exec --no-startup-id 			pactl set-sink-mute 0 1
exec --no-startup-id			alacritty --class=scratchpad_f1
exec --no-startup-id			~/.config/i3/setupScreensaver.sh
exec --no-startup-id			amixer -q -D pulse set Capture cap
exec --no-startup-id			deadd-notification-center
