################################################################################
# i3 config
################################################################################

# Set mod key (Mod1=<Alt>, Mod4=<Super>)
set $super Mod4
set $alt Mod1
set $terminal alacritty
set $extraterminal terminator
set $shell /usr/bin/fish

# Set the timeout in milliseconds for notify-send
set $mynotify notify-send -t 3000

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

# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:Sarasa Mono SC Nerd 12
# font pango:Ubuntu, Ubuntu Nerd Font 12

# set default desktop layout (default is tiling)
# workspace_layout tabbed <stacking|tabbed>

# Configure border style <normal|1pixel|pixel xx|none|pixel>
default_border pixel 3
default_floating_border pixel 1

# Hide borders
hide_edge_borders none

# Switch to workspace with urgent window automatically
for_window [urgent=latest] focus

# Set inner/outer gaps
gaps inner 8
gaps outer -3

# Smart gaps (gaps used if only more than one container on the workspace)
# smart_gaps on

# Smart borders (draw borders around container only if it is not the only container on this workspace)
# on|no_gaps (on=always activate and no_gaps=only activate if the gap size to the edge of the screen is 0)
# smart_borders on

# # hide/unhide i3status bar
# bindsym $super+m bar mode toggle

################################################################################
# Theme colors (for windows)
################################################################################
# class                   border  backgr. text    indic.   child_border
  client.focused          #009185 #009185 #dbdcd5 #ff5555
  client.focused_inactive #2F3D44 #2F3D44 #dbdcd5 #454948
  client.unfocused        #2F3D44 #2F3D44 #009185 #454948
  client.urgent           #CB4B16 #CB4B16 #dbdcd5 #268BD2
  # client.urgent           #CB4B16 #FDF6E3 #AD69AF #268BD2
  client.placeholder      #000000 #0c0c0c #ffffff #000000
  client.background       #2B2C2B

################################################################################
# Keybindings
################################################################################
# Personal keybindings
# My dmenu scripts <CTRL + ALT> + KEY
bindsym Control+$alt+c exec ~/.myScripts/dmscripts/dm-edit-configs.sh
bindsym Control+$alt+p exec ~/.myScripts/dmscripts/dm-run-programs.sh
bindsym Control+$alt+s exec ~/.myScripts/dmscripts/dm-run-scripts.sh
bindsym Control+$alt+x exec ~/.myScripts/dmscripts/dm-system-exit.sh

# My applications <SUPER + ALT> + KEY
bindsym $super+$alt+r exec rofi run -show drun -show-icons
bindsym $alt+w exec rofi run -show window -show-icons
bindsym $super+$alt+d exec dmenu_run -i -l 10 -nb '#263238' -nf '#24d2af' -sb '#009185' -p 'Run: ' -fn 'Iosevka-17:normal'
bindsym Print exec flameshot gui
bindsym $super+$alt+w exec /usr/bin/firefox
bindsym $super+$alt+u exec qutebrowser
bindsym $super+$alt+e exec dolphin
bindsym $super+$alt+n exec thunar
bindsym $super+$alt+a exec $terminal -e $shell -c ranger
bindsym $super+$alt+v exec $terminal -e $shell -c ~/.config/vifm/scripts/vifmrun
bindsym $super+$alt+t exec ~/Programs/Telegram/Telegram -workdir ~/.local/share/TelegramDesktop/ -- %u
bindsym $super+$alt+p exec ~/Programs/PyCharm-Community/bin/pycharm.sh
bindsym $super+$alt+c exec code
bindsym $super+$alt+g exec goldendict
bindsym $super+$alt+m exec gvim
bindsym $super+$alt+s exec ~/Programs/SublimeText/sublime_text
bindsym $super+$alt+b exec brave
bindsym $super+Return exec $terminal
bindsym $super+$alt+Return exec $extraterminal
bindsym Control+Shift+Escape exec $terminal -e $shell -c htop

#  My applications as Root <SUPER + SHIFT + ALT> + KEY
bindsym $super+Shift+$alt+v exec ~/.myScripts/runVifmAsRoot.sh
bindsym $super+Shift+$alt+a exec ~/.myScripts/runRangerAsRoot.sh
bindsym $super+Shift+$alt+n exec ~/.myScripts/runThunarAsRoot.sh

# <SUPER> + <F1-F12>
# Screen brightness controls (extra)
bindsym $super+F3 exec ~/.myScripts/brightness_up.sh
bindsym $super+F2 exec ~/.myScripts/brightness_down.sh
# bindsym XF86MonBrightnessUp exec ~/.myScripts/brightness_up.sh
# bindsym XF86MonBrightnessDown exec ~/.myScripts/brightness_down.sh

# Volume controls for more than 100%
bindsym $super+F7 exec pactl set-sink-mute @DEFAULT_SINK@ toggle
bindsym $super+F8 exec ~/.myScripts/volume_down.sh
bindsym $super+F9 exec ~/.myScripts/volume_up.sh

# <ALT> + <F1-F12>
bindsym $alt+F4 exec ~/Programs/ByeBye/ByeBye

# Hotkeys i3
# Change focus between windows (containers)
bindsym $super+h focus left
bindsym $super+j focus down
bindsym $super+k focus up
bindsym $super+l focus right

# Navigate workspaces next / previous
bindsym $super+Right workspace next
bindsym $super+Left workspace prev

# Move focused window (container)
bindsym $super+Shift+h move left
bindsym $super+Shift+j move down
bindsym $super+Shift+k move up
bindsym $super+Shift+l move right

# Alternatively, you can use the cursor keys:
bindsym $super+Shift+Left move left
bindsym $super+Shift+Down move down
bindsym $super+Shift+Up move up
bindsym $super+Shift+Right move right

# Shrink/Grow the window's width/height
bindsym $super+Ctrl+h resize shrink width 5 px or 5 ppt
bindsym $super+Ctrl+j resize grow height 5 px or 5 ppt
bindsym $super+Ctrl+k resize shrink height 5 px or 5 ppt
bindsym $super+Ctrl+l resize grow width 5 px or 5 ppt

# Same bindings, but for the arrow keys
bindsym $super+Ctrl+Left resize shrink width 5 px or 5 ppt
bindsym $super+Ctrl+Down resize grow height 5 px or 5 ppt
bindsym $super+Ctrl+Up resize shrink height 5 px or 5 ppt
bindsym $super+Ctrl+Right resize grow width 5 px or 5 ppt

# Workspace back and forth (with/without active container)
bindsym $super+Escape workspace back_and_forth
# Workspace_auto_back_and_forth yes
# bindsym $super+Shift+b move container to workspace back_and_forth; workspace back_and_forth

# Fullscreen mode for the focused window (container)
bindsym $super+f fullscreen toggle

# Toggle tiling / floating
bindsym $super+Shift+f floating toggle

# Split in horizontal or vertical orientation
bindsym $super+s split toggle
# bindsym $super+g split v;exec $mynotify 'tile horizontally'
# bindsym $super+v split h;exec $mynotify 'tile vertically'

# Change container layout (stacked, tabbed, toggle split)
bindsym $super+a layout stacking
bindsym $super+b layout tabbed
bindsym $super+t layout toggle split
# bindsym $super+Shift+w layout stacking
# bindsym $super+Shift+t layout tabbed
# bindsym $super+Shift+e layout toggle split

# Change focus between tiling / floating windows
bindsym $alt+Tab focus mode_toggle
# bindsym $super+space focus mode_toggle

# Move the currently focused window to the scratchpad (minimize)
bindsym $alt+n move scratchpad

# Show minimized window (container)
# # Show the next scratchpad window or hide the focused scratchpad window.
# # If there are multiple scratchpad windows, this command cycles through them.
bindsym $super+Control+n scratchpad show

# # focus the parent container
# bindsym $super+Shift+p focus parent

# # focus the child container
# bindsym $super+Shift+i focus child

################################################################################
# Key modes
################################################################################
# Set shut down, restart and locking features
bindsym $super+0 mode "$supere_system"
set $supere_system (l)ock, (e)xit, switch_(u)ser, (s)uspend, (h)ibernate, (r)eboot, (Shift+s)hutdown
mode "$supere_system" {
    bindsym l exec --no-startup-id i3exit lock, mode "default"
    bindsym s exec --no-startup-id i3exit suspend, mode "default"
    bindsym u exec --no-startup-id i3exit switch_user, mode "default"
    bindsym e exec --no-startup-id i3exit logout, mode "default"
    bindsym h exec --no-startup-id i3exit hibernate, mode "default"
    bindsym r exec --no-startup-id i3exit reboot, mode "default"
    bindsym Shift+s exec --no-startup-id i3exit shutdown, mode "default"

    # Exit system mode: "Enter" or "Escape"
    bindsym Return mode "default"
    bindsym Escape mode "default"
    bindsym $super+0 mode "default"
}

# Dmenu mode
bindsym $alt+m mode "Dmenu"
mode "Dmenu" {
        # These bindings trigger as soon as you enter the Dmenu mode
        bindsym c exec ~/.myScripts/dmscripts/dm-edit-configs.sh
        bindsym p exec ~/.myScripts/dmscripts/dm-run-programs.sh
        bindsym s exec ~/.myScripts/dmscripts/dm-run-scripts.sh
        bindsym x exec ~/.myScripts/dmscripts/dm-system-exit.sh

        # back to normal: Enter or Escape or $super+r
        bindsym Return mode "default"
        bindsym Escape mode "default"
        bindsym $alt+m mode "default"
}

################################################################################
# Mouse bindings
################################################################################
# Super+RBClick (close window)
bindsym --whole-window $super+button2 kill

# win+right button toggles floating
# bindsym $super+button3 floating toggle

################################################################################
# Workspaces
# Define names for default workspaces
# We use variables to avoid repeating the names in multiple places
################################################################################
# "1  ", "2  ", "3  ", "4  ", "5  ", "6  ", "7  ", "8  ", "9  "
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  "

# Switch to workspace
bindsym $super+1 workspace number $ws1
bindsym $super+2 workspace number $ws2
bindsym $super+3 workspace number $ws3
bindsym $super+4 workspace number $ws4
bindsym $super+5 workspace number $ws5
bindsym $super+6 workspace number $ws6
bindsym $super+7 workspace number $ws7
bindsym $super+8 workspace number $ws8
bindsym $super+9 workspace number $ws9

# Move focused container to workspace and follow it
bindsym $super+Shift+1 move container to workspace number $ws1; workspace $ws1
bindsym $super+Shift+2 move container to workspace number $ws2; workspace $ws2
bindsym $super+Shift+3 move container to workspace number $ws3; workspace $ws3
bindsym $super+Shift+4 move container to workspace number $ws4; workspace $ws4
bindsym $super+Shift+5 move container to workspace number $ws5; workspace $ws5
bindsym $super+Shift+6 move container to workspace number $ws6; workspace $ws6
bindsym $super+Shift+7 move container to workspace number $ws7; workspace $ws7
bindsym $super+Shift+8 move container to workspace number $ws8; workspace $ws8
bindsym $super+Shift+9 move container to workspace number $ws9; workspace $ws9

# Kill focused window
# bindsym $super+Shift+q kill
bindsym $super+Shift+c kill
bindsym $super+Shift+x --release exec xkill

# Reload the configuration file
bindsym $super+Shift+r reload
# Restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $super+Shift+Control+r restart
# exit i3 (logs you out of your X session)
bindsym $super+Shift+q 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'"

################################################################################
# Open applications on specific workspaces
################################################################################
# assign [class="dolphin"] $ws3
assign [class="VirtualBox Manager"] $ws5
assign [class="TelegramDesktop"] $ws6
assign [class="viber"] $ws6
assign [class="Gimp-2.10"] $ws7
assign [class="thunderbird"] $ws9

################################################################################
# Open specific applications in floating mode
################################################################################
for_window [class="xfce4-appfinder"] floating enable border pixel 1
for_window [title="Терминатор Параметры"] floating enable border pixel 1
for_window [title="Terminator Preferences"] floating enable border pixel 1
for_window [class="Gdebi-gtk"] floating enable
for_window [class="power-manager"] floating enable
for_window [class="Galculator"] floating enable border pixel 1
for_window [title="Калькулятор"] floating enable border pixel 1
for_window [class="Pavucontrol"] floating enable border pixel 1
for_window [class="BookletForEpsonXP-100"] floating enable border pixel 1
for_window [class="Deadbeef"] floating enable border pixel 1
for_window [class="Gcolor*"] floating enable border pixel 1
for_window [class="Lxappearance"] floating enable sticky enable border pixel 1
for_window [class="Nitrogen"] floating enable sticky enable border pixel 1
for_window [class="qt5ct"] floating enable sticky enable border pixel 1
for_window [class="Volumeicon"] floating enable border pixel 1
for_window [title="File Transfer*"] floating enable
for_window [title="i3_help"] floating enable sticky enable border normal
for_window [class="Lightdm-gtk-greeter-settings"] floating enable
for_window [class="Simple-scan"] floating enable border normal
for_window [class="(?i)System-config-printer.py"] floating enable border normal
# for_window [class="(?i)virtualbox"] floating enable border normal
# for_window [class="(?i)virtualbox"] fullscreen enable
# for_window [class="Manjaro Settings Manager"] floating enable border normal

################################################################################
# Autostart applications
################################################################################
exec_always --no-startup-id $HOME/.config/polybar/launch.sh
exec --no-startup-id setxkbmap -layout us,ru -option grp:caps_toggle &
# exec_always --no-startup-id $HOME/.config/i3/alternating_layouts.py &
# # exec --no-startup-id /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 &  # for Debian
exec --no-startup-id /usr/lib/xfce4/notifyd/xfce4-notifyd &
# exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &  # for Arch
exec --no-startup-id /usr/libexec/xfce-polkit &  # for Void
exec --no-startup-id xrdb $HOME/.Xresources &
exec --no-startup-id nitrogen --restore; sleep 1; picom --config $HOME/.config/picom/picom.conf &
exec --no-startup-id volumeicon &
exec --no-startup-id nm-applet &
exec --no-startup-id xfce4-power-manager &
exec --no-startup-id xfce4-clipman &
exec --no-startup-id conky -c $HOME/.myScripts/conky/conkyrc &
exec --no-startup-id /usr/bin/python /usr/bin/udiskie &
exec --no-startup-id xiccd &
exec --no-startup-id python /usr/bin/redshift-gtk &
exec --no-startup-id ~/Programs/CheckInternetConnection/CheckInternetConnection &
exec --no-startup-id ~/Programs/AppImageApplications/BreakTimer.AppImage &
exec --no-startup-id birdtray &
# exec --no-startup-id sleep 10
# exec --no-startup-id xmodmap -e "keycode 135 = Super_R" &  # Map the menu button to right super

# ################################################################################
# # Sound-section - DO NOT EDIT if you wish to automatically upgrade Alsa
# # -> Pulseaudio later!
# ################################################################################
# bindsym $super+Ctrl+m exec $myTerm -e 'alsamixer'
# # #exec --no-startup-id pulseaudio
# # #exec --no-startup-id pa-applet
# # bindsym $super+Ctrl+m exec pavucontrol
# ################################################################################

# # Start i3bar to display a workspace bar (plus the system information i3status if available)
# bar {
    # # # status_command i3blocks
    # # # i3bar_command i3bar
    # # # status_command i3status
    # # status_command python3 ~/.config/i3pystatus/config.py
    # # # # i3pystatus -c ~/.config/i3pystatus/config.py
    # position top
    # workspace_buttons yes
    # # height 25
    # # # separator_symbol ":|:"
# #
# # ## please set your primary output first. Example: 'xrandr --output eDP1 --primary'
    # # # tray_output primary
    # # # tray_output eDP1
# #
    # # bindsym button4 nop
    # # bindsym button5 nop
# # #   font xft:URWGothic-Book 11
    # # # font pango:Ubuntu, Sarasa Mono SC Nerd, FontAwesome, Icons 11
    # font pango:Ubuntu, Ubuntu Nerd Font 11
    # # font xft:Ubuntu, FontAwesome, Icons 11
# #
    # # strip_workspace_numbers no
    # # strip_workspace_name no
    # # # workspace_min_width 30
# #
    # colors {
        # background #263238
        # statusline #dbdcd5
        # separator  #dbdcd5
#
# #                           border  backgr. text
        # focused_workspace  #009185 #009185 #dbdcd5
        # active_workspace   #263238 #263238 #dbdcd5
        # inactive_workspace #263238 #263238 #dbdcd5
        # binding_mode       #ffbb00 #ffbb00 #070800
        # urgent_workspace   #cc241d #cc241d #dbdcd5
#
# # default colors
        # # background #222D31
        # # statusline #F9FAF9
        # # separator  #454947
# #
# # #                           border  backgr. text
        # # focused_workspace  #F9FAF9 #16a085 #292F34
        # # active_workspace   #595B5B #353836 #FDF6E3
        # # inactive_workspace #595B5B #222D31 #EEE8D5
        # # binding_mode       #16a085 #2C2C2C #F9FAF9
        # # urgent_workspace   #16a085 #FDF6E3 #E5201D
#
# # Materia Manjaro colors
        # # background = #263238
        # # foreground = #dbdcd5
        # # alert = #cc241d
        # # volume-min = #a3be8c
        # # volume-med = #ebcb8b
        # # volume-max = #bf616a
        # # current_screen_tab = "#585E72"
        # # group_names = "#dbdcd5"
        # # line_color_curr_tab = "#009185"
        # # line_color_other_tab = "#8d62a9"
        # # even_widgets = "#6182b8"
        # # window_name = "#24d2af"
        # # cpu = #e2a0a5
        # # memory = "#ffb62c"
        # # net_speed_up = "#24d2af"
        # # net_speed_down = "#91b859"
        # # layout_widget = "#ffffff"
        # # keyboard = "#39adb5"
        # # date_time = "#6182b8"
        # # ; date_time = "#f2b06a"
        # # sys_tray = "#404555"
        # # ; updates = "#e2e0a5"
        # # updates = "#ffcb6b"
        # # weather = "#eb7bef"
        # # ; weather = "#ec30f3"
        # # ; weather = "#e2e0a5"
        # # chord = "#d79921"
    # }
# }

