# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!

# Mod key
# Alt key
set $mod Mod1
# Win key
set $modSecondary Mod4

exec_always --no-startup-id "~/.config/i3/startup.sh"
exec --no-startup-id "pulseaudio -D --disallow-exit --exit-idle-time=-1"
exec --no-startup-id "setxkbmap -layout cz"
exec --no-startup-id "sleep 3 && volumeicon"

for_window [class="(?i)Firefox" instance="Navigator" window_role="browser" window_type="normal"] move --no-auto-back-and-forth container to workspace 1, floating enable, resize set 1380px 1048px, move position center, move down 6px
bindsym --border button1 [class="(?i)Firefox"] nop
#bindsym --whole-window $mod+button3 [class="(?i)Firefox"] nop
bindsym $mod+Shift+r [class="(?i)Firefox" instance="Navigator" window_role="browser" window_type="normal"] move --no-auto-back-and-forth container to workspace 1, floating enable, resize set 1380px 1048px, move position center, move down 6px

for_window [title="Terminal_main_scratchpad"] floating enable, resize set 1100px 450px, move down 250px, border pixel 2
assign [class="jetbrains-phpstorm" window_type="normal"] 2
assign [class="Sublime_text" window_type="normal"] 3
for_window [title="Machine_Dev"] move workspace number 10

# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:monospace 8

# use these keys for focus, movement, and resize directions when reaching for
# the arrows is not convenient
set $up l
set $down h
set $left j
set $right k

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

# Alt-tab to switch last used workspaces
bindsym $mod+Tab workspace back_and_forth

# start a terminal
bindsym $mod+Return exec --no-startup-id "$TERMINAL"

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

# start dmenu (a program launcher)
# bindsym $mod+d exec --no-startup-id dmenu_run
# A more modern dmenu replacement is rofi:
# bindsym $mod+d exec rofi -modi drun,run -show drun
# There also is i3-dmenu-desktop which only displays applications shipping a
# .desktop file. It is a wrapper around dmenu, so you need that installed.
bindsym $mod+p exec --no-startup-id i3-dmenu-desktop

# Lock
bindsym $modSecondary+l exec --no-startup-id "i3lock --color=000000 --nofork --ignore-empty-password"

# change focus
bindsym $mod+$left focus left
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right focus right

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

# move focused window
# alternatively, you can use the cursor keys:
bindsym $modSecondary+Shift+Left move left
bindsym $modSecondary+Shift+Down move down
bindsym $modSecondary+Shift+Up move up
bindsym $modSecondary+Shift+Right move right

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

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

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

# change container layout (stacked, tabbed, toggle split)
bindsym $modSecondary+s layout stacking
bindsym $modSecondary+t layout tabbed
bindsym $modSecondary+e layout default
bindsym $modSecondary+Shift+h layout toggle split

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

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

# move the currently focused window to the scratchpad
bindsym $mod+Shift+p move scratchpad
# Show the next scratchpad window or hide the focused scratchpad window.
# If there are multiple scratchpad windows, this command cycles through them.
bindsym $mod+s exec --no-startup-id "~/.config/i3/scratchpad.sh &> /dev/null"
bindsym $mod+Shift+s [title="^(?!Terminal_main_scratchpad$)"] scratchpad show

# 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
bindsym $mod+8 workspace number $ws8
bindsym $mod+9 workspace number $ws9
bindsym $mod+0 workspace number $ws10

# 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
# 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'"

# Sreen brightness controls
bindsym Shift+XF86MonBrightnessUp exec --no-startup-id "light -A 15"
bindsym Shift+XF86MonBrightnessDown exec --no-startup-id "light -U 15"
bindsym XF86MonBrightnessUp exec --no-startup-id "light -A 1"
bindsym XF86MonBrightnessDown exec --no-startup-id "light -U 1"

# Special keys actions
bindsym XF86Sleep exec --no-startup-id "xset dpms force off"
bindsym XF86TouchpadToggle exec device=$(xinput list --name-only | grep TouchPad) && xinput list-props "$device" | grep -E 'Device Enabled \([0-9]+\):\s+1' && xinput disable "$device" || xinput enable "$device"

# 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 $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

        # 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 Return mode "default"
        bindsym Escape mode "default"
        bindsym $mod+r mode "default"
}
bindsym $mod+r mode "resize"

mode "simple_shortcut" {
  bindsym $mod+$modSecondary+Shift+p mode "default"
}
bindsym $mod+$modSecondary+Shift+p mode "simple_shortcut"

# Start i3bar to display a workspace bar
bar {
        status_command i3status
        position top
        workspace_min_width 30
        separator_symbol "  "

        # Take a screenshot by right clicking on the bar
        bindsym --release button3 exec --no-startup-id "umask 002 ; import /tmp/screen_$(date +%Y-%m-%d-%H-%M-%S).png"

        colors {
            background #000000
            separator  #000000
            statusline #6FAD9C

            focused_workspace  #000000 #206664 #FFFFFF
            active_workspace   #000000 #222222 #FFFFFF
            inactive_workspace #000000 #222222 #888888
            urgent_workspace   #000000 #900000 #FFFFFF
            binding_mode       #000000 #900000 #FFFFFF
        }
}

# class                 border  bground text    indicator child_border
client.focused          #5F676A #206064 #FFFFFF #5F676A   #5F676A
client.focused_inactive #5F676A #5F676A #FFFFFF #5F676A   #5F676A
