set $mod2 Mod4
set $mod Mod1

# hide title bar
new_window none

#font pango:monospace 10
font pango:Inconsolata\\-g for Powerline 8
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

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

# start a file manager
bindsym $mod+Shift+Return exec --no-startup-id nautilus

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

# start dmenu (a program launcher)
#bindsym $mod+d exec dmenu_run -nb '#002b36' -nf '#839496' -sb '#073642' -sf '#cb4b16'
bindsym $mod+d exec rofi -show combi
#bindsym $mod+d exec rofi combi -combi-modes "window,run,ssh" -modes combi


# lock the screen
bindsym Mod4+l exec i3lock -c 111111

# change focus
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right
# mimic alt-tab functionality
bindsym $mod+Tab focus right

# focus does not follow mouse
focus_follows_mouse no

# switch between 2 recent workspaces quickly on pressing $mod+{workspaceselect}
workspace_auto_back_and_forth yes

# convenient binding for doing this
bindsym $mod+z workspace back_and_forth

# move windows back and forth and follow them
# comment out after ; to not follow window
bindsym $mod+Shift+z move container to workspace back_and_forth; workspace back_and_forth

# focus a window wherever it is
bindsym $mod+Shift+b [class="Firefox"] focus
bindsym $mod+Shift+i [class="Terminal" title="weechat"] focus
# alternatively, you can use the cursor keys:
# could even use marks but thats for another day

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 in horizontal orientation
bindsym $mod+semicolon split h

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

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

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

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

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

# focus the parent container
bindsym $mod+a focus parent

# focus the child container
#bindsym $mod+d focus child

bindsym $mod+x [urgent=latest] focus

# monitor names - laptop dock
# set $ext1 DP2
# set $ext1 DP-2
# set $int1 LVDS1
# set $int1 LVDS1

# general
set $ext1 DP-4
set $ext2 HDMI-0

# browser workspace preferes external monitor
#workspace $ws1 output $ext1
#workspace $ws2 output $ext1
#workspace $ws3 output $ext1
#workspace $ws4 output $ext1
#workspace $ws5 output $ext1
#workspace $ws6 output $ext1
#workspace $ws7 output $ext1
#workspace $ws8 output $ext1
#workspace $ws9 output $ext2
#workspace $ws10 output $ext2


# workspace names
set $ws1 1: www
set $ws2 2: mail
set $ws3 3: irc
set $ws4 4: term
set $ws5 5: server
set $ws6 6: steam
set $ws7 7: music
set $ws8 8: file

# set a specific configuration on startup
# exec --no-startup-id  ~/bin/home_single.sh

# 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 9
bindsym $mod+0 workspace 10


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

# Move the current workspace to the next output
# (effectively toggles when you only have two outputs)
bindsym $mod+o move workspace to output right

# Put this window on the presentation output.
bindsym $mod+p move container to output $ext1

# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# 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'"

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

        # 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
        bindsym Return mode "default"
        bindsym Escape mode "default"
}

bindsym $mod+r mode "resize"

# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
        #font pango:monospace 8
        font pango:pango:Inconsolata\\-g for Powerline 9
        separator_symbol " || "
        status_command i3status --config ~/.i3/status.conf
        position top
        workspace_buttons yes
        # tray_output none
        colors {
             separator #66322f
             background #002b36
             statusline #268bd2
             focused_workspace #fdf6e399 #002b3699 #fdf6e3
             active_workspace #fdf6e3 #6c71c499 #fdf6e3
             inactive_workspace #586e75 #93a1a199 #002b36
             urgent_workspace #d33682 #d3368299 #fdf6e3
        }
}

# start setting before any other settings
# disable screen saver and power savings
exec --no-startup-id xset s off -dpms
exec --no-startup-id xautolock -time 10 -locker i3lock -c 000000
exec --no-startup-id xset +fp $HOME/.fonts  
exec --no-startup-id xset fp rehash
exec --no-startup-id compton --backend glx --vsync opengl-swc
exec --no-startup-id dropbox start
exec_always --no-startup-id xrdb -merge ~/.Xresources
exec --no-startup-id nm-applet
exec --no-startup-id  /opt/piavpn/bin/pia-client

# set a particular desktop background
#exec_always --no-startup-id feh --bg-scale ~/onedrive/stuff/wallpapers/solarized-dark/solarized-wallpaper-kernel.png 

exec --no-startup-id udiskie --tray
#exec --no-startup-id redshift-gtk -l xxxxxxxxxxxxxx  #where xxxxxxxx=lat:long
#of your location
#exec --no-startup-id unclutter
exec --no-startup-id blueman-tray

# Pulse Audio controls second pair works on arch
#bindsym XF86AudioMute exec amixer set Master 1+ toggle # mute sound
bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle

bindsym XF86AudioMicMute exec amixer set Capture toggle # mute mic
# increase volume
#bindsym XF86AudioRaiseVolume exec amixer -q set Master 5%+ unmute
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%

# # decrease volume
#bindsym XF86AudioLowerVolume exec amixer -q set Master 5%- unmute
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%


# Screen brightness controls
bindsym XF86MonBrightnessUp exec brightnessctl set +25% # increase screen brightness
bindsym XF86MonBrightnessDown exec brightnessctl set 25%- # decrease screen brightness

exec --no-startup-id dbus-update-activation-environment --all
exec --no-startup-id /usr/bin/gnome-keyring-daemon --start --components=ssh,secrets,gpg

# Keybindings to start applications
bindsym $mod+b exec --no-startup-id firefox

# Screenshots !use scrot for lightweight alternative
bindsym Print exec gnome-screenshot

# Make the currently focused window a scratchpad
bindsym $mod+Shift+minus move scratchpad

# Show the first scratchpad window ! comment out if on older i3
bindsym $mod+minus scratchpad show
smart_borders on
gaps inner 4 px
gaps outer 2 px

# choose xrandr displaymode
set $username mango
set $mode_display Display mode (t) triple, (d) dual, (m) monitor, (l) laptop
mode "$mode_display" {
    bindsym t exec --no-startup-id  /home/$username/bin/.display triple, mode "default"
    bindsym d exec --no-startup-id  /home/$username/bin/.display dual, mode "default"
    bindsym m exec --no-startup-id  /home/$username/bin/.display monitor, mode "default"
    bindsym l exec --no-startup-id  /home/$username/bin/.display side-monitor, mode "default"

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
}

bindsym $mod+I mode "$mode_display"
