# vim:filetype=i3
# i3 config file (v4)
set $mod Mod4
set $editor st

# fake-outputs 1280x1440+0+0,1280x1440+1280+0

set $black       #212121
set $darkblack   #000000
set $red         #fb4934
set $darkred     #cc241d
set $green       #b8bb26
set $darkgreen   #98971a
set $yellow      #fabd2f
set $darkyellow  #d79921
set $blue        #83a598
set $darkblue    #458588
set $magenta     #d3869b
set $darkmagenta #b16286
set $cyan        #8ec07c
set $darkcyan    #689d6a
set $white       #ebdbb2
set $darkwhite   #a89984
# set $background  #000000
set $transparent #1d202100

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 $default_gaps_inner 10
set $default_gaps_outer 5
gaps inner $default_gaps_inner
gaps outer $default_gaps_outer

workspace $ws1 gaps inner 0
workspace $ws1 gaps outer 0
workspace $ws9 gaps inner 0
workspace $ws9 gaps outer 0
workspace $ws10 gaps inner 0
workspace $ws10 gaps outer 0

workspace_auto_back_and_forth yes
force_display_urgency_hint 0 ms
focus_on_window_activation urgent

floating_minimum_size -1 x -1
floating_maximum_size -1 x -1

font pango:monofur for powerline 14, FontAwesome 12

#                       BORDER      BACKGROUND  TEXT   INDICATOR   CHILD_BORDER
client.focused          $yellow     $yellow     $black $yellow     $yellow
client.unfocused        $black      $black      $white $black      $darkyellow
client.focused_inactive $black      $black      $white $black      $darkyellow
client.urgent           $darkred    $darkred    $black $darkred    $darkred
client.background       $black

floating_modifier $mod
bindsym $mod+Return exec $editor
bindsym $mod+Shift+Return exec $editor --name __scratchpad

bindsym $mod+q kill
bindsym $mod+p exec --no-startup-id rofi -show run

bindsym $mod+Left focus left
bindsym $mod+Right focus right
bindsym $mod+Up focus up
bindsym $mod+Down focus down

bindsym $mod+Shift+Left move left 35px
bindsym $mod+Shift+Down move down 35px
bindsym $mod+Shift+Up move up 35px
bindsym $mod+Shift+Right move right 35px

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

bindsym $mod+f fullscreen
bindsym $mod+g fullscreen global

bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

bindsym $mod+Shift+space floating toggle
bindsym $mod+space focus mode_toggle

bindsym $mod+a focus parent
bindsym $mod+Shift+a focus child

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 back_and_forth

bindsym $mod+Shift+minus move scratchpad
bindsym $mod+Shift+plus scratchpad show

bindsym $mod+Shift+s sticky toggle
# put YouTube into fullscreen and execute this for media mode
bindsym $mod+y fullscreen disable; floating enable; resize set 400 300; sticky enable; move window to position 1515 20

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 XF86AudioLowerVolume exec --no-startup-id $HOME/scripts/volume_control.py down 5
bindsym XF86AudioRaiseVolume exec --no-startup-id $HOME/scripts/volume_control.py up 5
bindsym XF86AudioMute exec --no-startup-id $HOME/scripts/volume_control.py toggle
bindsym $mod+Shift+v exec --no-startup-id "killall pavucontrol; $HOME/scripts/fullscreen_wrap.sh pavucontrol -t 1"

bindsym XF86MonBrightnessDown exec --no-startup-id ${HOME}/scripts/backlight.sh -dec 10
bindsym XF86MonBrightnessUp exec --no-startup-id ${HOME}/scripts/backlight.sh -inc 10

bindsym $mod+Shift+c reload
bindsym $mod+Shift+r restart

# screenshot
bindsym --release Print exec --no-startup-id "maim -p 0 -c 0.96,0.5,0.09 $HOME/See/screenshot-$(date +%Y-%m-%d_%H-%M-%S).png"
bindsym --release Shift+Print exec --no-startup-id "maim -s -p 0 -c 0.96,0.5,0.09 $HOME/See/screenshot-$(date +%Y-%m-%d_%H-%M-%S).png"

bindsym $mod+n exec --no-startup-id thunar

set $mode_resize <span>        </span><span background='#fabd2f' foreground='#000000'> resize </span> <span foreground='#ebdbb2'>l</span>eft <span foreground='#ebdbb2'>r</span>ight <span foreground='#ebdbb2'>u</span>p <span foreground='#ebdbb2'>d</span>own
bindsym $mod+r mode "$mode_resize"
mode --pango_markup "$mode_resize" {
    bindsym Left resize shrink width 10 px or 1 ppt
    bindsym Down resize grow height 10 px or 1 ppt
    bindsym Up resize shrink height 10 px or 1 ppt
    bindsym Right resize grow width 10 px or 1 ppt

    bindsym Shift+Left resize shrink width 20 px or 5 ppt
    bindsym Shift+Down resize grow height 20 px or 5 ppt
    bindsym Shift+Up resize shrink height 20 px or 5 ppt
    bindsym Shift+Right resize grow width 20 px or 5 ppt

    bindsym s mode "default", exec --no-startup-id $HOME/scripts/slopsize.sh

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

set $mode_power <span>        </span><span background='#fabd2f' foreground='#000000'> power </span> <span foreground='#ebdbb2'>l</span>ock <span foreground='#ebdbb2'>e</span>xit <span foreground='#ebdbb2'>s</span>uspend <span foreground='#ebdbb2'>r</span>eboot <span foreground='#ebdbb2'>p</span>oweroff
mode --pango_markup "$mode_power" {
    bindsym l mode "default", exec --no-startup-id i3lock -c '000000' -i ${HOME}/See/lock.png -d
    bindsym e mode "default", exec --no-startup-id i3-msg exit
    bindsym s mode "default", exec --no-startup-id zzz
    bindsym h mode "default", exec --no-startup-id ZZZ
    bindsym r mode "default", exec --no-startup-id shutdown -r now
    bindsym p mode "default", exec --no-startup-id shutdown -P now

    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+l exec i3lock -c '000000' -i ${HOME}/See/lock.png -d
bindsym $mod+Control+l mode "$mode_power"
bindsym Mod1+Control+l mode "$mode_power"

set $mode_gaps <span>        </span><span background='#fabd2f' foreground='#000000'> gaps </span> <span foreground='#ebdbb2'>i</span>nner <span foreground='#ebdbb2'>o</span>uter <span foreground='#ebdbb2'>0 d</span>
set $mode_gaps_outer <span>        </span><span background='#fabd2f' foreground='#000000'> outer gaps </span> <span foreground='#ebdbb2'>+ - 0 d</span>
set $mode_gaps_inner <span>        </span><span background='#fabd2f' foreground='#000000'> inner gaps </span> <span foreground='#ebdbb2'>+ - 0 d</span>
bindsym $mod+Shift+g mode "$mode_gaps"

mode --pango_markup "$mode_gaps" {
    bindsym o      mode "$mode_gaps_outer"
    bindsym i      mode "$mode_gaps_inner"

    bindsym 0      mode "default", exec --no-startup-id i3-msg "gaps inner current set 0" && i3-msg "gaps outer current set 0"
    bindsym d      mode "default", exec --no-startup-id i3-msg "gaps inner current set $default_gaps_inner" && i3-msg "gaps outer current set $default_gaps_outer"

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

mode --pango_markup "$mode_gaps_inner" {
    bindsym plus  gaps inner current plus 5
    bindsym minus gaps inner current minus 5
    bindsym 0     mode "default", gaps inner current set 0
    bindsym d     mode "default", gaps inner current set $default_gaps_inner

    bindsym Shift+plus  gaps inner all plus 5
    bindsym Shift+minus gaps inner all minus 5
    bindsym Shift+0     mode "default", gaps inner all set 0
    bindsym Shift+d     mode "default", gaps inner all set $default_gaps_inner

    bindsym Return mode "default"
    bindsym Escape mode "default"
}
mode --pango_markup "$mode_gaps_outer" {
    bindsym plus  gaps outer current plus 5
    bindsym minus gaps outer current minus 5
    bindsym 0     mode "default", gaps outer current set 0
    bindsym d     mode "default", gaps outer current set $default_gaps_outer

    bindsym Shift+plus  gaps outer all plus 5
    bindsym Shift+minus gaps outer all minus 5
    bindsym Shift+0     mode "default", gaps outer all set 0
    bindsym Shift+d     mode "default", gaps outer all set $default_gaps_outer

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

set $mode_brightness <span>        </span><span background='#fabd2f' foreground='#000000'> brightness </span> <span foreground='#ebdbb2'>+</span> increase <span foreground='#ebdbb2'>-</span> decrease
bindsym $mod+Shift+b mode "$mode_brightness"
mode --pango_markup "$mode_brightness" {
    bindsym plus  exec --no-startup-id ${HOME}/src/scripts/backlight.sh -time 50 -inc 10
    bindsym minus exec --no-startup-id ${HOME}/src/scripts/backlight.sh -time 50 -dec 10
    bindsym Shift+plus  exec --no-startup-id ${HOME}/src/scripts/backlight.sh -time 50 -inc 1
    bindsym Shift+minus exec --no-startup-id ${HOME}/src/scripts/backlight.sh -time 50 -dec 1

    bindsym 0     mode "default", exec --no-startup-id ${HOME}/src/scripts/backlight.sh -time 50 -set 100
    bindsym 1     mode "default", exec --no-startup-id ${HOME}/src/scripts/backlight.sh -time 50 -set 10
    bindsym 2     mode "default", exec --no-startup-id ${HOME}/src/scripts/backlight.sh -time 50 -set 20
    bindsym 3     mode "default", exec --no-startup-id ${HOME}/src/scripts/backlight.sh -time 50 -set 30
    bindsym 4     mode "default", exec --no-startup-id ${HOME}/src/scripts/backlight.sh -time 50 -set 40
    bindsym 5     mode "default", exec --no-startup-id ${HOME}/src/scripts/backlight.sh -time 50 -set 50
    bindsym 6     mode "default", exec --no-startup-id ${HOME}/src/scripts/backlight.sh -time 50 -set 60
    bindsym 7     mode "default", exec --no-startup-id ${HOME}/src/scripts/backlight.sh -time 50 -set 70
    bindsym 8     mode "default", exec --no-startup-id ${HOME}/src/scripts/backlight.sh -time 50 -set 80
    bindsym 9     mode "default", exec --no-startup-id ${HOME}/src/scripts/backlight.sh -time 50 -set 90

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

# fix graphics glitch
new_window none

for_window [window_role="pop-up"] floating enable
for_window [window_role="bubble"] floating enable
for_window [window_role="task_dialog"] floating enable
for_window [window_role="Preferences"] floating enable

for_window [window_type="dialog"] floating enable
for_window [window_type="menu"] floating enable

for_window [class="(?i)gsimplecal"] floating enable, move position mouse
for_window [class="(?i)qemu-system"] floating enable
for_window [class="(?i)VirtualBox" title="(?i)Manager"] floating enable
for_window [class="(?i)blueman"] floating enable

for_window [instance="sun-awt-X11-XFramePeer"] floating enable
for_window [instance="__scratchpad"] floating enable
for_window [instance="__nmtui"] floating enable

for_window [class="(?i)pavucontrol"] floating enable, border normal, move position mouse

assign [class="(?i)chrome"]                       $ws1
assign [class="(?i)eclipse" window_type="splash"] $ws3
assign [class="(?i)eclipse" window_type="normal"] $ws3
assign [class="(?i)thunderbird"]                  $ws9

bar {
#    verbose yes
    status_command i3blocks
    i3bar_command i3bar -t
    position top
    font pango:Hack 16, FontAwesome 15
    strip_workspace_numbers yes
    separator_symbol "■"
    bindsym button4 nop
    bindsym button5 nop
    tray_output eDP1
    tray_output LVDS-0
    tray_padding 0
    height 40
    colors {
        statusline         $white
        background         $transparent
        separator          $yellow

#                          BORDER       BACKGROUND   TEXT
        focused_workspace  $transparent $transparent $yellow
        inactive_workspace $transparent $transparent $white
        active_workspace   $transparent $transparent $white
        urgent_workspace   $darkred     $darkred     $transparent
        binding_mode       $transparent $transparent $yellow
    }
}

# AUTOSTART

exec --no-startup-id compton -b
exec --no-startup-id dunst &
exec --no-startup-id blueman-applet &
exec --no-startup-id nm-applet &
exec --no-startup-id xedgewarp -b

exec_always --no-startup-id feh --bg-fill $HOME/.config/wallpapers/octocat.jpg