# Oreodave i3 setup
# Please see https://i3wm.org/docs/userguide.html for a complete reference!

set $mod Mod4
set $lock lock
set $bg background
set $transparent #00000000
font pango:Waree 9

# Some necessary attributes
focus_follows_mouse no

# Scratchpad
bindsym $mod+Shift+minus move scratchpad
bindsym $mod+minus scratchpad show
bindsym $mod+slash exec qutebrowser

# Gaps and border
gaps outer 5
gaps inner 15
for_window [class="^.*"] border pixel 5

# Volume binds
set $refresh_i3status killall -SIGUSR1 i3status
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
bindsym XF86AudioMicMute     exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCe@ toggle && $refresh_i3status

## m and n are the + and - volume buttons
bindsym $mod+m exec --no-startup-id pactl set-sink-volume 0 +5% && $refresh_i3status
bindsym $mod+n exec --no-startup-id pactl set-sink-volume 0 -5% && $refresh_i3status

# Music binds
bindsym $mod+8 exec --no-startup-id mpc toggle
bindsym $mod+9 exec --no-startup-id mpc prev
bindsym $mod+0 exec --no-startup-id mpc next

# Brightness binds
bindsym XF86MonBrightnessUp   exec --no-startup-id xbacklight +15
bindsym XF86MonBrightnessDown exec --no-startup-id xbacklight -15

## b and v are the + and - brightness buttons
bindsym $mod+b exec --no-startup-id xbacklight +5
bindsym $mod+v exec --no-startup-id xbacklight -5

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

# Screenshot
bindsym F10 exec scrot -u '%Y%m%d_%H%M%S.png' -e 'mv $f ~/Pictures/'  -c

# start a terminal or editor
bindsym $mod+Return exec kitty
bindsym $mod+Shift+Return exec emacsclient -s MAIN -c

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

# Input commands
bindsym $mod+a exec dmenu_run
bindsym $mod+space exec i3-input -F "%s" -P "i3 Command: "

# lock bind and rename bind
bindsym $mod+Ctrl+l exec $lock
bindsym $mod+Ctrl+r exec i3-input -F "rename workspace to %s" -P "New name: "
bindsym $mod+Ctrl+d exec $bg

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

# alternatively, you can use the cursor 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

# split orientation settings
bindsym $mod+Ctrl+z split v
bindsym $mod+Ctrl+x split h
bindsym $mod+Ctrl+c split t

# 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+t layout tabbed
bindsym $mod+e layout toggle split

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

# 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"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"

# 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

# 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

# reload the configuration file
bindsym $mod+Shift+c reload
bindsym $mod+Shift+r restart
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'"

# resize
mode "resize" {
        bindsym h resize shrink width 10 px or 10 ppt
        bindsym j resize grow height 10 px or 10 ppt
        bindsym k resize shrink height 10 px or 10 ppt
        bindsym l resize grow width 10 px or 10 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"

# Aesthetics
client.focused              #4c7899 #3a3a3a #ffffff #2e9ef4 #13ad2c
client.focused_inactive     #333333 #5f676a #ffffff #2e9ef4 #13ad2c

# bar {
#         status_command py3status -c ~/.config/i3/i3status.conf
#         position top
#         workspace_buttons yes
#         font pango:Arial 9.5
#         colors {
#             focused_workspace  $transparent $transparent $darkwhite
#             inactive_workspace $transparent $transparent $white
#             active_workspace   $transparent $transparent $white
#             urgent_workspace   $darkred     $darkred     $transparent
#             binding_mode       $darkred     $darkred     $transparent
#         }
# }

exec $HOME/.local/bin/start_picom
exec --no-startup-id $bg
exec --no-startup-id xss-lock --transfer-sleep-lock -- $lock
exec --no-startup-id nm-applet
exec --no-startup-id blueman-applet
exec_always sh $HOME/.config/polybar/launch.sh
