{{ ansible_managed | comment }}

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

{% set workspace_switcher = "exec fish -c \"i3-msg workspace (i3-msg -t get_workspaces |  jq --raw-output '.[]|select(.num == -1).name' | rofi -dmenu -p workspace )\"" %}
{% set on_focus_workspace = "exec --no-startup-id ~/bin/on-focus-workspace" %}

### Font
#font pango:DejaVu Sans Mono 12
#font pango:DejaVu Sans Mono, Terminus Bold Semi-Condensed 11
#font pango:Droid Sans Mono Dotted 12
#font pango:DroidSansMono 13
#font pango:Sans 13
#font pango:hermit 12
#font pango:Inconsolata 14
font pango:monospace 10
#font pango:SourceCodePro-SemiBold 11
#font pango:Source Code Pro for Powerline, FontAwesome Regular, Icons 9
#font pango:Terminus 14px
#font pango:UbuntuMono-regular 12



### Modifier Key
set $mod Mod4
set $plexmod Mod3

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


### key patterns
set $up l
set $down k
set $left j
set $right odiaeresis


### default/local mode

## special keys
bindsym XF86Sleep exec {{session_lock_command}}
bindsym XF86Mail exec {{mail_command}}
bindsym XF86HomePage exec {{default_browser}}
bindsym XF86Calculator exec {{calculator_command}}

## Special modes
bindsym $mod+less mode timer
bindsym $mod+s mode session
bindsym $mod+c mode clipboard
bindcode $mod+49 mode "remote"


## Applications
bindsym $mod+Return exec "{{default_terminal}}"
bindsym $mod+b exec "{{default_browser}}"
bindsym $mod+d exec rofi -show drun -show-icons
bindsym $mod+e exec rofi -show run
bindsym $mod+a mode "apps"
bindsym $mod+space exec "~/bin/on-space-shortcut"


## Workspaces
bindsym $mod+w {{workspace_switcher}}
{% for ws in i3_number_workspace_keymaps %}
bindsym $mod+{{ws.keysym}} workspace "{{ws.workspace}}"
{% endfor %}
# focus workspace
bindsym $mod+Prior workspace next
bindsym $mod+Next workspace prev
bindsym $mod+ssharp scratchpad show
bindsym $mod+g sticky toggle


## Layout
bindsym $mod+y mode "layout"
bindsym $mod+h split h
bindsym $mod+v split v

## Focus
bindsym $mod+Left focus left
bindsym $mod+$left focus left
bindsym $mod+Down focus down
bindsym $mod+$down focus down
bindsym $mod+Up focus up
bindsym $mod+$up focus up
bindsym $mod+Right focus right
bindsym $mod+$right focus right
bindsym $mod+p focus parent
# change focus between tiling / floating windows
bindsym $mod+Tab focus mode_toggle

## Window
# The middle button over a titlebar kills the window
bindsym --release button2 kill
# The middle button and a modifer over any part of the window kills the window
bindsym --whole-window $mod+button2 kill
bindsym $mod+BackSpace kill
bindsym $mod+q kill
bindsym $mod+f fullscreen
bindsym $mod+z floating toggle
bindsym $mod+m mode move
bindsym $mod+r mode resize
bindsym $mod+x exec xkill

# points
bindsym $mod+minus exec {{points_down_command}}
bindsym $mod+plus exec {{points_up_command}}
bindsym $mod+KP_Subtract exec {{points_down_command}}
bindsym $mod+KP_Add exec {{points_up_command}}

# free keys
# $mod+i
# $mod+j
# $mod+k
# $mod+l
# $mod+n
# $mod+o
# $mod+t
# $mod+u
# $mod+adiaeresis
# $mod+odiaeresis
# $mod+udiaeresis
# $mod+comma
# $mod+period
# $mod+numbersign
# $mod+Home
# $mod+End
# $mod+Pause
# $mod+Delete
# $mod+Insert
# $mod+Print
# $mod+Scroll_Lock

## unlearn
#exec {{points_down_command}}


## stuff that is available in default and remote mode
{% macro overall() %}

  {% if home_profile == "desktop" %}
    bindsym $plexmod+space exec ~/bin/on-space-shortcut
    bindsym $plexmod+BackSpace kill
    bindsym $plexmod+Tab {{workspace_switcher}}

    {% for ws in i3_number_workspace_keymaps %}
    bindsym $plexmod+{{ws.keysym}} workspace "{{ws.workspace}}"
    {% endfor %}
    {% for ws in i3_letter_workspace_keymaps %}
    bindsym $plexmod+{{ws.keysym}} workspace "{{ws.workspace}}"
    {% endfor %}
    # focus workspace
    bindsym $plexmod+Prior workspace next
    bindsym $plexmod+Next workspace prev
  {% endif %}

  # focus output
  bindsym $plexmod+Shift+p focus output primary
  bindsym $plexmod+Shift+o exec fish -c "i3-msg focus output ( i3-msg -t get_outputs | jq --raw-output '.[]|select(.active == true).name' | rofi -dmenu -p 'focus output' )"
  bindsym $plexmod+Left focus output left
  bindsym $plexmod+Down focus output down
  bindsym $plexmod+Up focus output up
  bindsym $plexmod+Right focus output right

  # Special modes
  bindcode $plexmod+49 mode "session"
  bindsym $plexmod+less mode timer
{% endmacro %}
{{ overall() }}


### remote mode
mode "remote" {

  bindcode $mod+9 mode "default"
  bindsym XF86Sleep exec {{session_lock_command}}

  # The middle button over a titlebar kills the window
  bindsym --release button2 kill

  {{ overall() }}

}



### Applications mode
mode "apps" {
{% for a in application_shortcuts | dict2items %}
  bindsym {{a.key}} exec {{a.value}}; mode "default"
{% endfor %}
  bindsym Escape mode "default"
}



### Session
mode "session" {
  bindsym q exit
  bindsym r reload; exec --no-startup-id ~/.xsession.reload.fish; mode "default"; {{on_focus_workspace}}
  bindsym R reload; exec --no-startup-id ~/.xsession.reload.fish; mode "default"; {{on_focus_workspace}}
  bindsym s exec --no-startup-id {{system_suspend_command}}; mode "default"; {{on_focus_workspace}}
  bindcode 49 exec --no-startup-id {{session_lock_command}}; mode "default"; {{on_focus_workspace}}
  bindsym e exec --no-startup-id {{session_enable_screensaver_command}}; mode "default"; {{on_focus_workspace}}
  bindsym d exec --no-startup-id {{session_disable_screensaver_command}}; mode "default"; {{on_focus_workspace}}
  bindsym b exec --no-startup-id xsetroot -solid black; mode "default"; {{on_focus_workspace}}
  bindsym Shift+R exec --no-startup-id {{system_reboot_command}}; mode "default"; {{on_focus_workspace}}
  bindsym Shift+P exec --no-startup-id {{system_poweroff_command}}; mode "default"; {{on_focus_workspace}}

  # back to normal: Escape
  bindsym Escape mode "default"; {{on_focus_workspace}}
}


### Timer
mode "timer" {
  bindsym a exec "~/bin/timer select_activity"; mode "default"; {{on_focus_workspace}}
  bindsym e exec "~/bin/timer end_activity"; mode "default"; {{on_focus_workspace}}
  bindsym u exec "~/bin/timer uniklinik"; mode "default"; {{on_focus_workspace}}

  # back to normal: Escape
  bindsym Escape mode "default"; {{on_focus_workspace}}
}

### Clipboard
mode "clipboard" {
  # back to normal: Escape
  bindsym Escape mode "default"
}


### Layout
# set default layout to tabbed
workspace_layout tabbed

mode "layout" {
  bindsym s layout stacking; mode "default";
  bindsym t layout tabbed; mode "default";
  bindsym e layout toggle split; mode "default";
  bindsym h layout splith; mode "default"
  bindsym v layout splitv; mode "default"

  bindsym b mode bar

  # back to normal: Escape
  bindsym Escape mode "default"
}

mode "bar" {
  bindsym h bar mode hide; mode "default"
  bindsym d bar mode dock; mode "default"

  # back to normal: Escape
  bindsym Escape mode "default"
}

### Move mode
mode "move" {

  # move window
  bindsym Left move left
  bindsym $left move left
  bindsym Down move down
  bindsym $down move down
  bindsym Up move up
  bindsym $up move up
  bindsym Right move right
  bindsym $right move right

  # move window to workspace
{% for ws in i3_number_workspace_keymaps %}
  bindsym {{ws.keysym}} move container to workspace "{{ws.workspace}}"; mode "default"
{% endfor %}
  bindsym w exec fish -c "i3-msg move container to workspace (i3-msg -t get_workspaces |  jq --raw-output '.[]|select(.num == -1).name' | rofi -dmenu -p 'move to workspace' )"; mode "default"
  bindsym ssharp move scratchpad

  # move workspace to output
  bindsym Shift+Left move workspace to output left
  bindsym Shift+$left move workspace to output left
  bindsym Shift+Down move workspace to output down
  bindsym Shift+$down move workspace to output down
  bindsym Shift+Up move workspace to output up
  bindsym Shift+$up move workspace to output up
  bindsym Shift+Right move workspace to output right
  bindsym Shift+$right move workspace to output right

  bindsym o exec fish -c "i3-msg move workspace to output ( i3-msg -t get_outputs | jq --raw-output '.[]|select(.active == true).name' | rofi -dmenu -p 'move workspace to output' )"; mode "default"
  bindsym p move workspace to output primary; mode "default"

  # back to normal: Escape
  bindsym Escape mode "default"
}



### Resize window mode
# 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.
  bindsym Left resize shrink width 10 px or 10 ppt
  bindsym $left    resize shrink width 10 px or 10 ppt
  # Pressing down will grow the window’s height.
  bindsym Down resize grow height 10 px or 10 ppt
  bindsym $down    resize grow height 10 px or 10 ppt
  # Pressing up will shrink the window’s height.
  bindsym Up resize shrink height 10 px or 10 ppt
  bindsym $up  resize shrink height 10 px or 10 ppt
  # Pressing right will grow the window’s width.
  bindsym Right      resize grow width 10 px or 10 ppt
  bindsym $right resize grow width 10 px or 10 ppt

  bindsym 1 resize set 10 ppt 10 ppt; mode "default"
  bindsym 2 resize set 20 ppt 20 ppt; mode "default"
  bindsym 3 resize set 30 ppt 30 ppt; mode "default"
  bindsym 4 resize set 40 ppt 40 ppt; mode "default"
  bindsym 5 resize set 50 ppt 50 ppt; mode "default"
  bindsym 6 resize set 60 ppt 60 ppt; mode "default"
  bindsym 7 resize set 70 ppt 70 ppt; mode "default"
  bindsym 8 resize set 80 ppt 80 ppt; mode "default"
  bindsym 9 resize set 90 ppt 90 ppt; mode "default"
  bindsym 0 resize set 100 ppt 100 ppt; mode "default"

  bindsym v resize set 640 480; mode "default"
  bindsym y resize set 870 628; mode "default"

  # back to normal: Escape
  bindsym Escape mode "default"
}



### Bar
bar {
{% if i3_hide_bar %}
  mode hide
  hidden_state hide
  modifier $mod
{% endif %}

  position top

  strip_workspace_numbers yes

  tray_output primary

  status_command i3blocks

  colors {
    background #000000
    statusline #ffffff
    separator #666666

    # <colorclass> <border> <background> <text>
    focused_workspace  {{home_base_color_hue|hsv2rgb(50,60)}} {{home_base_color_hue|hsv2rgb(66,47)}} #ffffff
    active_workspace   #333333 #696969 #ffffff
    inactive_workspace #333333 #222222 #888888
    urgent_workspace   #2f343a #900000 #ffffff
    binding_mode       #2f343a #900000 #ffffff
  }
}



### Design

# class     border  backgr. text    indicator child_border
client.focused    {{home_base_color_hue|hsv2rgb(50,60)}} {{home_base_color_hue|hsv2rgb(66,47)}} #ffffff {{home_base_color_hue|hsv2rgb(81,91)}}   {{home_base_color_hue|hsv2rgb(66,47)}}
client.focused_inactive #333333 #6A6A6A #ffffff #505050   #6A6A6A
client.unfocused  #333333 #222222 #888888 #2E2E2E   #222222
client.urgent     #2f343a #900000 #ffffff #900000   #900000
client.placeholder      #000000 #0c0c0c #ffffff #000000   #0c0c0c

client.background       #ffffff

default_border normal
hide_edge_borders both

default_floating_border normal

### general settings

focus_on_window_activation urgent



### Application specific rule

for_window [class="^(?:Tiger)?V[Nn][Cc] ?[Vv]iewer$"] border none
for_window [window_role="^About$"] floating enable
for_window [class="^Pavu"] floating enable
for_window [class="^Paman$"] floating enable
for_window [class="^Blueman"] floating enable
for_window [class="^URxvt$" title="^tmux-workspace$"] border none

### assign apps to workspaces
assign [class="^netzdrive$"] → netzdrive
assign [class="^TelegramDesktop$"] → tg
assign [class="^Signal$"] → signal
assign [class="^Element$"] → matrix
assign [class="^thunderbird$"] → mail
# vncviewer workspaces
{% for workspace in workspaces|dict2items|json_query("[?value.type=='vncviewer'].key") %}
{% set ws = workspaces[workspace] %}
assign [class="^(?:Tiger)?V[Nn][Cc] ?[Vv]iewer$" title="^{{ws.host}}:{{ws.display|default(home_vncserver_display_number)}}"] → {{workspace}}
{% endfor %}

### Autostart.display|default(home_vncserver_display_number)

#exec "{{default_terminal}}"

exec --no-startup-id "~/bin/i3-watchers"
