diff --git a/config b/config index 2b5f4ad..3e88f31 100644 --- a/config +++ b/config @@ -12,10 +12,13 @@ set $mod Mod4 set $mod2 Mod1 +set $right DVI-D-0 +set $left DVI-I-1 + # Font for window titles. Will also be used by the bar unless a different font # is used in the bar {} block below. ISO 10646 = Unicode #font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 -font pango:DejaVu Sans Mono 10 +font pango:DejaVu Sans Mono 11 # The font above is very space-efficient, that is, it looks good, sharp and # clear in small sizes. However, if you need a lot of unicode glyphs or # right-to-left text rendering, you should instead use pango for rendering and @@ -27,7 +30,7 @@ floating_modifier $mod # start a terminal # bindsym $mod+Return exec i3-sensible-terminal -bindsym $mod+Return exec sakura +bindsym $mod+Return exec alacritty -e fish # keepassxc bindsym $mod+k exec keepmenu @@ -40,7 +43,7 @@ bindsym $mod+$mod2+w exec --no-startup-id rofi -show window bindsym $mod+d exec --no-startup-id rofi -show run bindsym $mod+$mod2+d exec --no-startup-id rofi -show drun bindsym $mod+$mod2+l exec --no-startup-id systemctl suspend -bindsym $mod+l exec --no-startup-id i3lock -c 000000 +# bindsym $mod+l exec --no-startup-id i3lock -c 000000 # bindsym $mod+$mod2+d exec dmenu_run # bindsym $mod+d exec --no-startup-id i3-dmenu-desktop # bindsym $mod+d exec --no-startup-id xfce4-popup-whiskermenu @@ -112,15 +115,13 @@ bindsym $mod+a focus parent workspace_layout tabbed # program specific workspaces -assign [class="Steam"] number 2 +assign [class="Steam"] number 10 #assign [class="Firefox"] 2 #assign [class="Thunderbird"] 1 assign [class="Pidgin"] number 2 assign [class="Mumble"] number 2 -set $left eDP1 -set $right HDMI2 # workspace to monitor mapping workspace 1 output $left @@ -135,8 +136,10 @@ workspace 9 output $left workspace 10 output $right # workspace cycling -bindsym $mod+Tab workspace next -bindsym $mod+$mod2+Tab workspace prev +# bindsym $mod+Tab workspace next +# bindsym $mod+$mod2+Tab workspace prev +bindsym $mod+Tab [con_mark=_prevFocus0] focus +bindsym $mod+$mod2+Tab [con_mark=_prevFocus2] focus # switch to workspace bindsym $mod+1 workspace number 1 @@ -325,5 +328,6 @@ mode "num" { # exec_always --no-startup-id ~/.config/polybar/autoname_workspaces.py --norenumber_workspaces --icon_list_format mathematician exec_always --no-startup-id autoname_workspaces -i superscript exec_always --no-startup-id ~/.config/polybar/launch.sh -#exec xrandr --output DVI-D-0 --auto --right-of DVI-I-1 +exec --no-startup-id ~/.config/i3/focus +# exec xrandr --output DVI-I-1 --auto --right-of DVI-D-0 exec picom --config ~/.config/picom.config diff --git a/focus b/focus new file mode 100755 index 0000000..3c56696 --- /dev/null +++ b/focus @@ -0,0 +1,79 @@ +#!/bin/bash + +# epochMillis: print the amount of millis since epoch time on the std output stream. +epochMillis(){ + echo $(($(date +%s%N)/1000000)) +} + +# queue: array holding the focused window ids in order, the most recent focus is on index 0. +queue=( ) +queueLimit=8 + +# pushOnQueue: insert a window id on index 0 of the queue. This function also removes the given id if was already present, the queue is an ordered set. +# arg 1: window id to insert. +pushOnQueue(){ + if [ "$1" = "0x0" ] + then + return + fi + newQueue=( "$1" ) + for i in "${queue[@]}" + do + if [ "$1" = "$i" ] + then + continue + fi + newQueue=( ${newQueue[@]:0} "$i" ) + done + queue=( "${newQueue[@]:0:$queueLimit}" ) +} + +# markQueue: put i3 marks using the window ids stored on the queue. The windows are marked using "_prevFocusX" where X is a integer corresponding with the index of the element on the queue. The previously focused window (the most recent) is marked using "_prevFocus0". This function also cleans the queue from windows that can't be marked (e.g. windows that have been closed). +markQueue(){ + queueCopy=( "${queue[@]}" ) + queue=( ) + j=0 + for i in "${queueCopy[@]}" + do + i3-msg "unmark _prevFocus$j" 1>/dev/null 2>&1 + if i3-msg "[id=$i] mark --add _prevFocus$j" 2>/dev/null | grep -i "\"success\":true" 1>/dev/null 2>&1 + then + queue=( ${queue[@]:0} "$i" ) + j=$(($j + 1)) + fi + done +} + +lastTime=$(epochMillis) +# permanence: period in millis used to determine if a window is worthy to be saved on the queue. This enables i3 window fast navigation without saving unworthy window ids. +permanence=1000 + +# main loop: read activated window ids continuously. +xprop -root -spy _NET_ACTIVE_WINDOW | +while read line +do + + currentTime=$(epochMillis) + period=$(($currentTime-$lastTime)) + lastTime=$currentTime + + # previousFocus: window id of the previously focused (activated) window. + previousFocus=$currentFocus + # currentFocus: window id of the window that has just being activated. + currentFocus=$(echo "$line" | awk -F' ' '{printf $NF}') + + # push the previousFocus id to the queue if the time spent on the previous window was greater than permanence. Check also to allow fast switching between two windows. + if [ $period -gt $permanence -o "$currentFocus" = "${queue[0]}" ] + then + pushOnQueue "$previousFocus" + fi + + # if the currentFocus is marked as the previous window (_prevFocus0 or queue[0]) then swap the first two elements on the queue to allow switching. + if [ "${queue[0]}" = "$currentFocus" ] + then + queue=( ${queue[1]} ${queue[0]} ${queue[@]:2} ) + fi + + markQueue + +done diff --git a/sequence.default b/sequence.default new file mode 100644 index 0000000..20ebf12 --- /dev/null +++ b/sequence.default @@ -0,0 +1 @@ +]4;0;rgb:0000/0000/0000\]4;1;rgb:cdcd/0000/0000\]4;2;rgb:0000/cdcd/0000\]4;3;rgb:cdcd/cdcd/0000\]4;4;rgb:1e1d/9090/ffff\]4;5;rgb:cdcd/0000/cdcd\]4;6;rgb:0000/cdcd/cdcd\]4;7;rgb:e5e4/e5e4/e5e4\]4;8;rgb:4c4b/4c4b/4c4b\]4;9;rgb:ffff/0000/0000\]4;10;rgb:0000/ffff/0000\]4;11;rgb:ffff/ffff/0000\]4;12;rgb:4646/8282/b4b3\]4;13;rgb:ffff/0000/ffff\]4;14;rgb:0000/ffff/ffff\]4;15;rgb:ffff/ffff/ffff\]10;rgb:c0c0/c0c0/c0c0\]11;rgb:0000/0000/0000\]12;rgb:c0c0/c0c0/c0c0\]13;rgb:ffff/ffff/ffff\]17;rgb:c0c0/c0c0/c0c0\]19;rgb:0000/0000/0000\]4;232;rgb:0808/0808/0808\]4;256;rgb:c0c0/c0c0/c0c0\]708;rgb:ffff/ffff/ffff\ diff --git a/sequence.solarized b/sequence.solarized new file mode 100644 index 0000000..97253d3 --- /dev/null +++ b/sequence.solarized @@ -0,0 +1 @@ +]4;0;#073642\]4;1;#dc322f\]4;2;#859900\]4;3;#b58900\]4;4;#268bd2\]4;5;#CB4B16\]4;6;#2aa198\]4;7;#eee8d5\]4;8;#6c7c80\]4;9;#dc322f\]4;10;#859900\]4;11;#b58900\]4;12;#268bd2\]4;13;#CB4B16\]4;14;#2aa198\]4;15;#eee8d5\]10;#839496\]11;#002B36\]12;#dc322f\]13;#839496\]17;#839496\]19;#073642\]4;232;#073642\]4;256;#839496\]708;#073642\