aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2019-10-09 20:35:36 -0400
committerLoic Guegan <manzerbredes@mailbox.org>2019-10-09 20:35:36 -0400
commitbbe92b2bda81d325a438dfeceb311041cc25c47f (patch)
tree4730801aae13f1d6307d9c046358ef4f323d5317
parentd9ad091ba1eaf59883f060d232cf103d7142cb0d (diff)
Debug apply command
-rwxr-xr-xsrc/config.py18
-rw-r--r--tests/data/config-brackets-same-line304
-rw-r--r--tests/data/config-strange-colors-keyword-location304
-rwxr-xr-xtests/run.sh38
-rw-r--r--tests/test-apply-brackets-same-line.out304
-rw-r--r--tests/test-apply-brackets-same-line.sh8
-rw-r--r--tests/test-apply-no-vars.out3
-rw-r--r--tests/test-apply-strange-colors-keyword-location.out10
-rw-r--r--tests/test-apply-strange-colors-keyword-location.sh8
-rw-r--r--tests/test-apply-with-vars.out3
-rw-r--r--tests/test-extract-with-vars-and-apply.out3
11 files changed, 975 insertions, 28 deletions
diff --git a/src/config.py b/src/config.py
index ee0d1f8..6308485 100755
--- a/src/config.py
+++ b/src/config.py
@@ -61,13 +61,13 @@ def extract(config_file):
is_theme_line=True
if contains(".*colors",line):
in_colors=True
- beforeColor=before_token("colors",line).strip()
- if len(beforeColor)>0:
- tmp.write(beforeColor+"\n")
+ tmp.write(before_token("colors",line))
if not(is_theme_line) and not(in_colors):
tmp.write(line_orig)
if contains(".*}",line) and in_colors:
- in_colors=False
+ in_colors=False
+ if len(re.findall("}",line)) > 1: # WARNING: two brackets can be on the same line so print it
+ tmp.write("}")
f.close()
tmp.close()
return(tmp.name)
@@ -114,16 +114,14 @@ def write_theme(tmp_config,theme):
if contains("(\s)*bar",line):
in_bar=True
if contains(".*}",line) and in_bar:
- beforeBrace=before_token("}",line).strip()
- if len(beforeBrace)>0:
- tmp.write(beforeBrace+"\n")
- tmp.write(" colors {\n")
+ tmp.write(before_token("}",line))
+ tmp.write("colors {\n")
for key,value in sorted_items(bar_theme):
if not(isinstance(value,dict)):
- tmp.write(" "+key+" "+value+"\n")
+ tmp.write(" "+key+" "+value+"\n") # Not that here we use custom indentation
else:
tmp.write(" "+key+" "+value["border"]+" "+value["background"]+" "+value["text"]+"\n")
- tmp.write(" }\n}\n")
+ tmp.write("}}\n") # Not that here we loose last brace indentation
in_bar=False
else:
tmp.write(line_orig)
diff --git a/tests/data/config-brackets-same-line b/tests/data/config-brackets-same-line
new file mode 100644
index 0000000..515b497
--- /dev/null
+++ b/tests/data/config-brackets-same-line
@@ -0,0 +1,304 @@
+##### Variables #####
+##### Define workspaces names
+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"
+set $ws-firefox ""
+set $ws-org ""
+set $ws-tools ""
+set $ws-mutt ""
+set $ws-weechat ""
+set $ws-newsboat ""
+set $ws-R ""
+set $ws-signal "Signal"
+set $ws-cmus ""
+###### Define some default keys
+set $LEFT j
+set $DOWN k
+set $UP l
+set $RIGHT m
+##### Define shutter sound location (for screenshots)
+set $shutter_sound ~/.config/i3/shutter.mp3
+##### Define modifier
+set $mod Mod4
+set $jump Mod3
+#####################
+
+##### Appearence #####
+##### Define font
+font pango:DejaVu Sans Mono 12
+##### To gain a bit of space
+hide_edge_borders both
+######################
+
+##### I3 Behavior #####
+##### Disable cycle (like workspace) in a container with several windows
+focus_wrapping no
+##### Enable workspace auto back and forth (go back to the previous workspace with same keybinding)
+workspace_auto_back_and_forth yes
+##### Default workspace layout
+workspace_layout tabbed
+#######################
+
+##### Setup Mouse #####
+##### Disable mouse on hover focus
+focus_follows_mouse no
+##### Define mouse floating window size and move modifier
+floating_modifier $mod
+floating_minimum_size 200 x 200
+#######################
+
+##### Keys Bindings #####
+##### Volume
+bindsym XF86AudioRaiseVolume exec amixer -D pulse sset Master 5%+
+bindsym XF86AudioLowerVolume exec amixer -D pulse sset Master 5%-
+bindsym XF86AudioMute exec amixer -D pulse sset Master toggle
+##### Scratchpad
+bindsym $mod+asterisk scratchpad show
+bindsym $mod+Shift+asterisk move scratchpad
+##### Define brightness control
+bindcode 233 exec xbacklight -inc 5
+bindcode 232 exec xbacklight -dec 5
+##### Move workspace to next output
+bindsym $mod+ugrave move workspace to output right
+##### Define screenshot key
+bindsym Print exec scrot ~/Pictures/screenshots/%Y-%m-%d_%H:%M:%S.png && exec ffplay -nodisp -autoexit $shutter_sound
+bindsym $mod+Print exec scrot -e "ffplay -nodisp -autoexit $shutter_sound && gimp \$f" ~/Pictures/screenshots/%Y-%m-%d_%H:%M:%S.png
+##### Start terminal
+bindsym $mod+Shift+Return exec xterm
+##### Kill a window
+bindsym $mod+Shift+a kill
+##### Start dmenu
+bindsym $mod+d exec dmenu_run -b -i -sb "#CC0000" -nb "#4A4A4A" -fn "Deja Vu Sans Mono-14:bold"
+##### Configure password manager
+bindsym $mod+Shift+d exec pp
+##### Change focus
+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+$LEFT move left
+bindsym $mod+Shift+$DOWN move down
+bindsym $mod+Shift+$UP move up
+bindsym $mod+Shift+$RIGHT move right
+##### Layout Splits
+bindsym $mod+h split h
+bindsym $mod+v split v
+##### Toggle fullscreen
+bindsym $mod+f fullscreen toggle
+##### Change container layout (either stacked, tabbed or splitv/splith)
+bindsym $mod+s layout stacking
+bindsym $mod+z layout tabbed
+bindsym $mod+t 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 container
+bindsym $mod+q focus parent
+bindsym $mod+Shift+q focus child
+##### Workspace next and prev
+bindsym $mod+Right workspace next
+bindsym $mod+Left workspace prev
+##### Switch to workspace
+bindsym $mod+ampersand workspace $ws1
+bindsym $mod+eacute workspace $ws2
+bindsym $mod+quotedbl workspace $ws3
+bindsym $mod+apostrophe workspace $ws4
+bindsym $mod+parenleft workspace $ws5
+bindsym $mod+minus workspace $ws6
+bindsym $mod+egrave workspace $ws7
+bindsym $mod+underscore workspace $ws8
+bindsym $mod+ccedilla workspace $ws9
+bindsym $mod+agrave workspace $ws10
+bindsym $mod+exclam workspace $ws-tools
+##### Move focused container to workspace
+bindsym $mod+Shift+ampersand move container to workspace $ws1
+bindsym $mod+Shift+eacute move container to workspace $ws2
+bindsym $mod+Shift+quotedbl move container to workspace $ws3
+bindsym $mod+Shift+apostrophe move container to workspace $ws4
+bindsym $mod+Shift+5 move container to workspace $ws5
+bindsym $mod+Shift+minus move container to workspace $ws6
+bindsym $mod+Shift+egrave move container to workspace $ws7
+bindsym $mod+Shift+underscore move container to workspace $ws8
+bindsym $mod+Shift+ccedilla move container to workspace $ws9
+bindsym $mod+Shift+agrave move container to workspace $ws10
+bindsym $mod+Shift+exclam move container to workspace $ws-tools
+# Read 1 character and mark the current window with this character
+bindsym $mod+shift+w exec i3-input -F 'mark %s' -l 1 -P 'Mark: '
+##### Reload configuration file
+bindsym $mod+Shift+c reload
+##### Restart i3 inplace
+bindsym $mod+Shift+r restart
+##### Exit i3
+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
+mode "resize" {
+ # Pressing left will shrink the window’s width.
+ bindsym $LEFT resize shrink width 10 px or 10 ppt
+ # Pressing down will grow the window’s height.
+ bindsym $UP resize grow height 10 px or 10 ppt
+ # Pressing up will shrink the window’s height.
+ bindsym $DOWN 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
+
+ # Back to normal
+ bindsym Return mode "default"
+ bindsym Escape mode "default"
+ bindsym q mode "default"
+}
+bindsym $mod+r mode "resize"
+##### Cmus control
+mode "cmus" {
+ # Toggle pause
+ bindsym c exec cmus-remote -u
+ # Next
+ bindsym b exec cmus-remote -n
+ # Previous
+ bindsym z exec cmus-remote -r
+ #Shuffle
+ bindsym s exec cmus-rand integrated
+ # Vol up
+ bindsym Shift + plus exec cmus-remote -v +5%
+ bindsym KP_Add exec cmus-remote -v +5%
+ # Vol down
+ bindsym minus exec cmus-remote -v -5%
+ bindsym KP_Subtract exec cmus-remote -v -5%
+ # Quit
+ bindsym x exec cmus-remote -C quit; mode "default"
+ # Back to normal
+ bindsym Return mode "default"
+ bindsym Escape mode "default"
+ bindsym q mode "default"
+}
+bindsym $mod c mode "cmus"
+##### App launcher keys
+mode "launcher" {
+ # Lancer terminal
+ bindsym t exec tmux_run; mode "default"
+ # Define lock control
+ bindsym F3 exec i3lock -f -i ~/.dotfiles-deps/i3/lock.png; mode "default"
+ # Open wicd
+ bindsym w exec xterm -e nmtui; mode "default"
+ # Open pavucontrol
+ bindsym p exec i3-pavucontrol; mode "default"
+ # Start weechat
+ bindsym Shift + w exec xterm -e weechat || notify-send -t 2000 "Weechat already launched"; mode "default"
+ # Open mc
+ bindsym m exec xterm -e mc; mode "default"
+ # Join cmus
+ bindsym c exec xterm -e cmus; mode "default"
+ # Start deluge
+ bindsym d exec xterm -e deluge-console ; mode "default"
+ # Open orgfiles
+ bindsym o exec org-session ; mode "default"
+ # Enable double screen
+ bindsym F1 exec ~/.config/i3/inria.sh; mode "default"
+ # Disable double screen
+ bindsym F2 exec ~/.config/i3/noinria.sh; mode "default"
+ bindsym F4 exec xrandr --output DP1-2 --same-as eDP1 ; mode "default"
+ # Back to normal
+ bindsym Return mode "default"
+ bindsym Escape mode "default"
+ bindsym q mode "default"
+}
+bindsym $mod+o mode "launcher"
+##### Quick window switching (maybe using i3-input will be more generic)
+bindsym $jump+m workspace $ws-mutt
+bindsym $jump+w workspace $ws-weechat
+bindsym $jump+n workspace $ws-newsboat
+bindsym $jump+r workspace $ws-R
+bindsym $jump+s workspace $ws-signal
+bindsym $jump+c workspace $ws-cmus
+bindsym $jump+f workspace $ws-firefox
+bindsym $jump+agrave workspace $ws-org
+#########################
+
+##### Startup #####
+##### Startup tools
+exec --no-startup-id xmodmap ~/.Xmodmap
+exec --no-startup-id xterm -T Mutt -e mutt
+exec --no-startup-id xterm -xrm "xterm*allowTitleOps: false" -T Weechat -e weechat # We should prevent Weechat to change xterm window title (with -xm ...)
+exec --no-startup-id xterm -xrm "xterm*allowTitleOps: false" -T Cmus -e cmus
+exec --no-startup-id pulseeffects
+exec --no-startup-id signal-desktop-disable-gpu
+exec --no-startup-id xterm -T "R Session" -e R
+exec --no-startup-id xterm -T "Newsboat" -e newsboat
+##### Startup applications
+exec --no-startup-id firefox
+exec --no-startup-id org-session
+exec --no-startup-id /usr/bin/emacs --daemon
+exec --no-startup-id xcompmgr
+exec --no-startup-id xrdb ~/.Xdefaults
+exec --no-startup-id clipit
+exec --no-startup-id redshift -l 48.1265:-1.6499 -t 5500:3600 -g 0.8 -m vidmode -v
+exec --no-startup-id dunst -conf ~/.dunstrc
+exec_always feh --bg-scale ~/.config/i3/background.jpg
+###################
+
+##### Workspaces Assignments #####
+##### Assign apps to workspace
+assign [class="^firefox$"] $ws-firefox
+assign [class="^Eclipse$"] $ws2
+assign [title="org-session"] $ws-org
+##### Assign tools workspaces
+assign [class="^Signal$"] $ws-signal
+assign [title="Mutt"] $ws-mutt
+assign [title="Weechat"] $ws-weechat
+assign [title="R Session"] $ws-R
+assign [title="Newsboat"] $ws-newsboat
+assign [class="Pulseeffects"] $ws-cmus
+assign [title="Cmus"] $ws-cmus
+##################################
+
+##### Configure Windows #####
+for_window [class="feh"] floating enable
+for_window [class="Geeqie"] floating enable, resize set 1700 900, move position center
+for_window [class="MPlayer"] floating enable
+for_window [title="^Tmux$"] floating enable, resize set 1700 900, move position center
+for_window [class="^Pavucontrol$"] floating enable, resize set 1700 900, move position center
+#############################
+
+##### Configure Outputs #####
+workspace $ws1 output eDP1 # Compilation
+workspace $ws2 output DP1-2 # Eclipse
+workspace $ws3 output DP1-2
+workspace $ws4 output DP1-2
+workspace $ws5 output DP1-2
+workspace $ws6 output DP1-2
+workspace $ws7 output DP1-2
+workspace $ws8 output DP1-2
+workspace $ws9 output DP1-1 # Web browser
+workspace $ws10 output DP1-2 # org-session signal
+#############################
+
+##### Theme #####
+bar {
+ #mode hide
+ position top
+ font pango:DejaVu Sans Mono 14
+ status_command i3status -c ~/.config/i3/i3status.conf
+ separator_symbol "|"
+ colors {
+ active_workspace #414141 #2d2d2d #ffffff
+ background #2d2d2d
+ focused_workspace #4183F6 #2d76f6 #ffffff
+ inactive_workspace #414141 #2d2d2d #bbbbbb
+ separator #bbbbbb
+ statusline #ffffff
+ urgent_workspace #FFCB21 #ffc609 #ffffff
+}}
+#################
+client.focused #4183F6 #2d76f6 #ffffff #d8442e #4183F6
+client.focused_inactive #C1C1C1 #bbbbbb #ffffff #009c58 #C1C1C1
+client.unfocused #414141 #2d2d2d #ffffff #bbbbbb #414141
+client.urgent #FFCB21 #ffc609 #ffffff #d8442e #FFCB21
diff --git a/tests/data/config-strange-colors-keyword-location b/tests/data/config-strange-colors-keyword-location
new file mode 100644
index 0000000..c4319c4
--- /dev/null
+++ b/tests/data/config-strange-colors-keyword-location
@@ -0,0 +1,304 @@
+##### Variables #####
+##### Define workspaces names
+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"
+set $ws-firefox ""
+set $ws-org ""
+set $ws-tools ""
+set $ws-mutt ""
+set $ws-weechat ""
+set $ws-newsboat ""
+set $ws-R ""
+set $ws-signal "Signal"
+set $ws-cmus ""
+###### Define some default keys
+set $LEFT j
+set $DOWN k
+set $UP l
+set $RIGHT m
+##### Define shutter sound location (for screenshots)
+set $shutter_sound ~/.config/i3/shutter.mp3
+##### Define modifier
+set $mod Mod4
+set $jump Mod3
+#####################
+
+##### Appearence #####
+##### Define font
+font pango:DejaVu Sans Mono 12
+##### To gain a bit of space
+hide_edge_borders both
+######################
+
+##### I3 Behavior #####
+##### Disable cycle (like workspace) in a container with several windows
+focus_wrapping no
+##### Enable workspace auto back and forth (go back to the previous workspace with same keybinding)
+workspace_auto_back_and_forth yes
+##### Default workspace layout
+workspace_layout tabbed
+#######################
+
+##### Setup Mouse #####
+##### Disable mouse on hover focus
+focus_follows_mouse no
+##### Define mouse floating window size and move modifier
+floating_modifier $mod
+floating_minimum_size 200 x 200
+#######################
+
+##### Keys Bindings #####
+##### Volume
+bindsym XF86AudioRaiseVolume exec amixer -D pulse sset Master 5%+
+bindsym XF86AudioLowerVolume exec amixer -D pulse sset Master 5%-
+bindsym XF86AudioMute exec amixer -D pulse sset Master toggle
+##### Scratchpad
+bindsym $mod+asterisk scratchpad show
+bindsym $mod+Shift+asterisk move scratchpad
+##### Define brightness control
+bindcode 233 exec xbacklight -inc 5
+bindcode 232 exec xbacklight -dec 5
+##### Move workspace to next output
+bindsym $mod+ugrave move workspace to output right
+##### Define screenshot key
+bindsym Print exec scrot ~/Pictures/screenshots/%Y-%m-%d_%H:%M:%S.png && exec ffplay -nodisp -autoexit $shutter_sound
+bindsym $mod+Print exec scrot -e "ffplay -nodisp -autoexit $shutter_sound && gimp \$f" ~/Pictures/screenshots/%Y-%m-%d_%H:%M:%S.png
+##### Start terminal
+bindsym $mod+Shift+Return exec xterm
+##### Kill a window
+bindsym $mod+Shift+a kill
+##### Start dmenu
+bindsym $mod+d exec dmenu_run -b -i -sb "#CC0000" -nb "#4A4A4A" -fn "Deja Vu Sans Mono-14:bold"
+##### Configure password manager
+bindsym $mod+Shift+d exec pp
+##### Change focus
+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+$LEFT move left
+bindsym $mod+Shift+$DOWN move down
+bindsym $mod+Shift+$UP move up
+bindsym $mod+Shift+$RIGHT move right
+##### Layout Splits
+bindsym $mod+h split h
+bindsym $mod+v split v
+##### Toggle fullscreen
+bindsym $mod+f fullscreen toggle
+##### Change container layout (either stacked, tabbed or splitv/splith)
+bindsym $mod+s layout stacking
+bindsym $mod+z layout tabbed
+bindsym $mod+t 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 container
+bindsym $mod+q focus parent
+bindsym $mod+Shift+q focus child
+##### Workspace next and prev
+bindsym $mod+Right workspace next
+bindsym $mod+Left workspace prev
+##### Switch to workspace
+bindsym $mod+ampersand workspace $ws1
+bindsym $mod+eacute workspace $ws2
+bindsym $mod+quotedbl workspace $ws3
+bindsym $mod+apostrophe workspace $ws4
+bindsym $mod+parenleft workspace $ws5
+bindsym $mod+minus workspace $ws6
+bindsym $mod+egrave workspace $ws7
+bindsym $mod+underscore workspace $ws8
+bindsym $mod+ccedilla workspace $ws9
+bindsym $mod+agrave workspace $ws10
+bindsym $mod+exclam workspace $ws-tools
+##### Move focused container to workspace
+bindsym $mod+Shift+ampersand move container to workspace $ws1
+bindsym $mod+Shift+eacute move container to workspace $ws2
+bindsym $mod+Shift+quotedbl move container to workspace $ws3
+bindsym $mod+Shift+apostrophe move container to workspace $ws4
+bindsym $mod+Shift+5 move container to workspace $ws5
+bindsym $mod+Shift+minus move container to workspace $ws6
+bindsym $mod+Shift+egrave move container to workspace $ws7
+bindsym $mod+Shift+underscore move container to workspace $ws8
+bindsym $mod+Shift+ccedilla move container to workspace $ws9
+bindsym $mod+Shift+agrave move container to workspace $ws10
+bindsym $mod+Shift+exclam move container to workspace $ws-tools
+# Read 1 character and mark the current window with this character
+bindsym $mod+shift+w exec i3-input -F 'mark %s' -l 1 -P 'Mark: '
+##### Reload configuration file
+bindsym $mod+Shift+c reload
+##### Restart i3 inplace
+bindsym $mod+Shift+r restart
+##### Exit i3
+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
+mode "resize" {
+ # Pressing left will shrink the window’s width.
+ bindsym $LEFT resize shrink width 10 px or 10 ppt
+ # Pressing down will grow the window’s height.
+ bindsym $UP resize grow height 10 px or 10 ppt
+ # Pressing up will shrink the window’s height.
+ bindsym $DOWN 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
+
+ # Back to normal
+ bindsym Return mode "default"
+ bindsym Escape mode "default"
+ bindsym q mode "default"
+}
+bindsym $mod+r mode "resize"
+##### Cmus control
+mode "cmus" {
+ # Toggle pause
+ bindsym c exec cmus-remote -u
+ # Next
+ bindsym b exec cmus-remote -n
+ # Previous
+ bindsym z exec cmus-remote -r
+ #Shuffle
+ bindsym s exec cmus-rand integrated
+ # Vol up
+ bindsym Shift + plus exec cmus-remote -v +5%
+ bindsym KP_Add exec cmus-remote -v +5%
+ # Vol down
+ bindsym minus exec cmus-remote -v -5%
+ bindsym KP_Subtract exec cmus-remote -v -5%
+ # Quit
+ bindsym x exec cmus-remote -C quit; mode "default"
+ # Back to normal
+ bindsym Return mode "default"
+ bindsym Escape mode "default"
+ bindsym q mode "default"
+}
+bindsym $mod c mode "cmus"
+##### App launcher keys
+mode "launcher" {
+ # Lancer terminal
+ bindsym t exec tmux_run; mode "default"
+ # Define lock control
+ bindsym F3 exec i3lock -f -i ~/.dotfiles-deps/i3/lock.png; mode "default"
+ # Open wicd
+ bindsym w exec xterm -e nmtui; mode "default"
+ # Open pavucontrol
+ bindsym p exec i3-pavucontrol; mode "default"
+ # Start weechat
+ bindsym Shift + w exec xterm -e weechat || notify-send -t 2000 "Weechat already launched"; mode "default"
+ # Open mc
+ bindsym m exec xterm -e mc; mode "default"
+ # Join cmus
+ bindsym c exec xterm -e cmus; mode "default"
+ # Start deluge
+ bindsym d exec xterm -e deluge-console ; mode "default"
+ # Open orgfiles
+ bindsym o exec org-session ; mode "default"
+ # Enable double screen
+ bindsym F1 exec ~/.config/i3/inria.sh; mode "default"
+ # Disable double screen
+ bindsym F2 exec ~/.config/i3/noinria.sh; mode "default"
+ bindsym F4 exec xrandr --output DP1-2 --same-as eDP1 ; mode "default"
+ # Back to normal
+ bindsym Return mode "default"
+ bindsym Escape mode "default"
+ bindsym q mode "default"
+}
+bindsym $mod+o mode "launcher"
+##### Quick window switching (maybe using i3-input will be more generic)
+bindsym $jump+m workspace $ws-mutt
+bindsym $jump+w workspace $ws-weechat
+bindsym $jump+n workspace $ws-newsboat
+bindsym $jump+r workspace $ws-R
+bindsym $jump+s workspace $ws-signal
+bindsym $jump+c workspace $ws-cmus
+bindsym $jump+f workspace $ws-firefox
+bindsym $jump+agrave workspace $ws-org
+#########################
+
+##### Startup #####
+##### Startup tools
+exec --no-startup-id xmodmap ~/.Xmodmap
+exec --no-startup-id xterm -T Mutt -e mutt
+exec --no-startup-id xterm -xrm "xterm*allowTitleOps: false" -T Weechat -e weechat # We should prevent Weechat to change xterm window title (with -xm ...)
+exec --no-startup-id xterm -xrm "xterm*allowTitleOps: false" -T Cmus -e cmus
+exec --no-startup-id pulseeffects
+exec --no-startup-id signal-desktop-disable-gpu
+exec --no-startup-id xterm -T "R Session" -e R
+exec --no-startup-id xterm -T "Newsboat" -e newsboat
+##### Startup applications
+exec --no-startup-id firefox
+exec --no-startup-id org-session
+exec --no-startup-id /usr/bin/emacs --daemon
+exec --no-startup-id xcompmgr
+exec --no-startup-id xrdb ~/.Xdefaults
+exec --no-startup-id clipit
+exec --no-startup-id redshift -l 48.1265:-1.6499 -t 5500:3600 -g 0.8 -m vidmode -v
+exec --no-startup-id dunst -conf ~/.dunstrc
+exec_always feh --bg-scale ~/.config/i3/background.jpg
+###################
+
+##### Workspaces Assignments #####
+##### Assign apps to workspace
+assign [class="^firefox$"] $ws-firefox
+assign [class="^Eclipse$"] $ws2
+assign [title="org-session"] $ws-org
+##### Assign tools workspaces
+assign [class="^Signal$"] $ws-signal
+assign [title="Mutt"] $ws-mutt
+assign [title="Weechat"] $ws-weechat
+assign [title="R Session"] $ws-R
+assign [title="Newsboat"] $ws-newsboat
+assign [class="Pulseeffects"] $ws-cmus
+assign [title="Cmus"] $ws-cmus
+##################################
+
+##### Configure Windows #####
+for_window [class="feh"] floating enable
+for_window [class="Geeqie"] floating enable, resize set 1700 900, move position center
+for_window [class="MPlayer"] floating enable
+for_window [title="^Tmux$"] floating enable, resize set 1700 900, move position center
+for_window [class="^Pavucontrol$"] floating enable, resize set 1700 900, move position center
+#############################
+
+##### Configure Outputs #####
+workspace $ws1 output eDP1 # Compilation
+workspace $ws2 output DP1-2 # Eclipse
+workspace $ws3 output DP1-2
+workspace $ws4 output DP1-2
+workspace $ws5 output DP1-2
+workspace $ws6 output DP1-2
+workspace $ws7 output DP1-2
+workspace $ws8 output DP1-2
+workspace $ws9 output DP1-1 # Web browser
+workspace $ws10 output DP1-2 # org-session signal
+#############################
+
+##### Theme #####
+bar {
+ #mode hide
+ position top
+ font pango:DejaVu Sans Mono 14
+ status_command i3status -c ~/.config/i3/i3status.conf
+ separator_symbol "|" colors {
+ active_workspace #414141 #2d2d2d #ffffff
+ background #2d2d2d
+ focused_workspace #4183F6 #2d76f6 #ffffff
+ inactive_workspace #414141 #2d2d2d #bbbbbb
+ separator #bbbbbb
+ statusline #ffffff
+ urgent_workspace #FFCB21 #ffc609 #ffffff
+ }
+}
+#################
+client.focused #4183F6 #2d76f6 #ffffff #d8442e #4183F6
+client.focused_inactive #C1C1C1 #bbbbbb #ffffff #009c58 #C1C1C1
+client.unfocused #414141 #2d2d2d #ffffff #bbbbbb #414141
+client.urgent #FFCB21 #ffc609 #ffffff #d8442e #FFCB21
diff --git a/tests/run.sh b/tests/run.sh
index 3691700..8c2828e 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -1,11 +1,13 @@
#!/bin/bash
-[ $# -ne 1 ] && { echo "Usage: $0 <run | break>"; exit 1; }
+[ $# -ne 1 ] && { echo "Usage: $0 <run | break | verbose | reset>"; exit 1; }
##### Arguments #####
wai=$(dirname $(readlink -f $0))
out=$(mktemp)
[ "$1" == "break" ] && int=1 || int=0
+[ "$1" == "verbose" ] && verbose=1 || verbose=0
+[ "$1" == "reset" ] && reset=1 || reset=0
#####################
##### Utils Functions #####
@@ -27,7 +29,14 @@ for test in $(find ${wai} -type f -name "test-*.sh")
do
test_name=$(basename $test)
expectations="${wai}/${test_name%.*}.out"
- bash ${test} > "${out}" 2>&1 # Run Test
+ if [ $reset -eq 1 ]
+ then
+ bash ${test} > "${out}" 2>&1 # Run Test
+ cat "${out}" > "${expectations}"
+ continue
+ else
+ bash ${test} > "${out}" 2>&1 # Run Test
+ fi
diff_out=$(diff "${out}" "${expectations}")
if [ ! -z "${diff_out}" ]
@@ -35,16 +44,15 @@ do
fail "${test_name}"
nb_fail=$(( nb_fail + 1 ))
- if [ $int -eq 1 ]
+ if [ $int -eq 1 ] || [ $verbose -eq 1 ]
then
echo "========== Diff =========="
echo -e "${diff_out}"
- echo "========== Original =========="
- cat "${expectations}"
- echo "========== Test Output =========="
- cat "${out}"
- clean
- exit 1
+ if [ $verbose -eq 0 ]
+ then
+ clean
+ exit 1
+ fi
fi
else
nb_pass=$(( nb_pass + 1 ))
@@ -55,7 +63,13 @@ clean
#################################
-echo -e "\n===== STATS ====="
-echo "${nb_pass} pass"
-echo "${nb_fail} fails"
+if [ $reset -eq 0 ]
+then
+ echo -e "\n===== STATS ====="
+ echo "${nb_pass} pass"
+ echo "${nb_fail} fails"
+ [ ${nb_fail} -gt 0 ] && exit 1
+else
+ echo "Reset done."
+fi
diff --git a/tests/test-apply-brackets-same-line.out b/tests/test-apply-brackets-same-line.out
new file mode 100644
index 0000000..8e07b12
--- /dev/null
+++ b/tests/test-apply-brackets-same-line.out
@@ -0,0 +1,304 @@
+##### Variables #####
+##### Define workspaces names
+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"
+set $ws-firefox ""
+set $ws-org ""
+set $ws-tools ""
+set $ws-mutt ""
+set $ws-weechat ""
+set $ws-newsboat ""
+set $ws-R ""
+set $ws-signal "Signal"
+set $ws-cmus ""
+###### Define some default keys
+set $LEFT j
+set $DOWN k
+set $UP l
+set $RIGHT m
+##### Define shutter sound location (for screenshots)
+set $shutter_sound ~/.config/i3/shutter.mp3
+##### Define modifier
+set $mod Mod4
+set $jump Mod3
+#####################
+
+##### Appearence #####
+##### Define font
+font pango:DejaVu Sans Mono 12
+##### To gain a bit of space
+hide_edge_borders both
+######################
+
+##### I3 Behavior #####
+##### Disable cycle (like workspace) in a container with several windows
+focus_wrapping no
+##### Enable workspace auto back and forth (go back to the previous workspace with same keybinding)
+workspace_auto_back_and_forth yes
+##### Default workspace layout
+workspace_layout tabbed
+#######################
+
+##### Setup Mouse #####
+##### Disable mouse on hover focus
+focus_follows_mouse no
+##### Define mouse floating window size and move modifier
+floating_modifier $mod
+floating_minimum_size 200 x 200
+#######################
+
+##### Keys Bindings #####
+##### Volume
+bindsym XF86AudioRaiseVolume exec amixer -D pulse sset Master 5%+
+bindsym XF86AudioLowerVolume exec amixer -D pulse sset Master 5%-
+bindsym XF86AudioMute exec amixer -D pulse sset Master toggle
+##### Scratchpad
+bindsym $mod+asterisk scratchpad show
+bindsym $mod+Shift+asterisk move scratchpad
+##### Define brightness control
+bindcode 233 exec xbacklight -inc 5
+bindcode 232 exec xbacklight -dec 5
+##### Move workspace to next output
+bindsym $mod+ugrave move workspace to output right
+##### Define screenshot key
+bindsym Print exec scrot ~/Pictures/screenshots/%Y-%m-%d_%H:%M:%S.png && exec ffplay -nodisp -autoexit $shutter_sound
+bindsym $mod+Print exec scrot -e "ffplay -nodisp -autoexit $shutter_sound && gimp \$f" ~/Pictures/screenshots/%Y-%m-%d_%H:%M:%S.png
+##### Start terminal
+bindsym $mod+Shift+Return exec xterm
+##### Kill a window
+bindsym $mod+Shift+a kill
+##### Start dmenu
+bindsym $mod+d exec dmenu_run -b -i -sb "#CC0000" -nb "#4A4A4A" -fn "Deja Vu Sans Mono-14:bold"
+##### Configure password manager
+bindsym $mod+Shift+d exec pp
+##### Change focus
+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+$LEFT move left
+bindsym $mod+Shift+$DOWN move down
+bindsym $mod+Shift+$UP move up
+bindsym $mod+Shift+$RIGHT move right
+##### Layout Splits
+bindsym $mod+h split h
+bindsym $mod+v split v
+##### Toggle fullscreen
+bindsym $mod+f fullscreen toggle
+##### Change container layout (either stacked, tabbed or splitv/splith)
+bindsym $mod+s layout stacking
+bindsym $mod+z layout tabbed
+bindsym $mod+t 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 container
+bindsym $mod+q focus parent
+bindsym $mod+Shift+q focus child
+##### Workspace next and prev
+bindsym $mod+Right workspace next
+bindsym $mod+Left workspace prev
+##### Switch to workspace
+bindsym $mod+ampersand workspace $ws1
+bindsym $mod+eacute workspace $ws2
+bindsym $mod+quotedbl workspace $ws3
+bindsym $mod+apostrophe workspace $ws4
+bindsym $mod+parenleft workspace $ws5
+bindsym $mod+minus workspace $ws6
+bindsym $mod+egrave workspace $ws7
+bindsym $mod+underscore workspace $ws8
+bindsym $mod+ccedilla workspace $ws9
+bindsym $mod+agrave workspace $ws10
+bindsym $mod+exclam workspace $ws-tools
+##### Move focused container to workspace
+bindsym $mod+Shift+ampersand move container to workspace $ws1
+bindsym $mod+Shift+eacute move container to workspace $ws2
+bindsym $mod+Shift+quotedbl move container to workspace $ws3
+bindsym $mod+Shift+apostrophe move container to workspace $ws4
+bindsym $mod+Shift+5 move container to workspace $ws5
+bindsym $mod+Shift+minus move container to workspace $ws6
+bindsym $mod+Shift+egrave move container to workspace $ws7
+bindsym $mod+Shift+underscore move container to workspace $ws8
+bindsym $mod+Shift+ccedilla move container to workspace $ws9
+bindsym $mod+Shift+agrave move container to workspace $ws10
+bindsym $mod+Shift+exclam move container to workspace $ws-tools
+# Read 1 character and mark the current window with this character
+bindsym $mod+shift+w exec i3-input -F 'mark %s' -l 1 -P 'Mark: '
+##### Reload configuration file
+bindsym $mod+Shift+c reload
+##### Restart i3 inplace
+bindsym $mod+Shift+r restart
+##### Exit i3
+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
+mode "resize" {
+ # Pressing left will shrink the window’s width.
+ bindsym $LEFT resize shrink width 10 px or 10 ppt
+ # Pressing down will grow the window’s height.
+ bindsym $UP resize grow height 10 px or 10 ppt
+ # Pressing up will shrink the window’s height.
+ bindsym $DOWN 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
+
+ # Back to normal
+ bindsym Return mode "default"
+ bindsym Escape mode "default"
+ bindsym q mode "default"
+}
+bindsym $mod+r mode "resize"
+##### Cmus control
+mode "cmus" {
+ # Toggle pause
+ bindsym c exec cmus-remote -u
+ # Next
+ bindsym b exec cmus-remote -n
+ # Previous
+ bindsym z exec cmus-remote -r
+ #Shuffle
+ bindsym s exec cmus-rand integrated
+ # Vol up
+ bindsym Shift + plus exec cmus-remote -v +5%
+ bindsym KP_Add exec cmus-remote -v +5%
+ # Vol down
+ bindsym minus exec cmus-remote -v -5%
+ bindsym KP_Subtract exec cmus-remote -v -5%
+ # Quit
+ bindsym x exec cmus-remote -C quit; mode "default"
+ # Back to normal
+ bindsym Return mode "default"
+ bindsym Escape mode "default"
+ bindsym q mode "default"
+}
+bindsym $mod c mode "cmus"
+##### App launcher keys
+mode "launcher" {
+ # Lancer terminal
+ bindsym t exec tmux_run; mode "default"
+ # Define lock control
+ bindsym F3 exec i3lock -f -i ~/.dotfiles-deps/i3/lock.png; mode "default"
+ # Open wicd
+ bindsym w exec xterm -e nmtui; mode "default"
+ # Open pavucontrol
+ bindsym p exec i3-pavucontrol; mode "default"
+ # Start weechat
+ bindsym Shift + w exec xterm -e weechat || notify-send -t 2000 "Weechat already launched"; mode "default"
+ # Open mc
+ bindsym m exec xterm -e mc; mode "default"
+ # Join cmus
+ bindsym c exec xterm -e cmus; mode "default"
+ # Start deluge
+ bindsym d exec xterm -e deluge-console ; mode "default"
+ # Open orgfiles
+ bindsym o exec org-session ; mode "default"
+ # Enable double screen
+ bindsym F1 exec ~/.config/i3/inria.sh; mode "default"
+ # Disable double screen
+ bindsym F2 exec ~/.config/i3/noinria.sh; mode "default"
+ bindsym F4 exec xrandr --output DP1-2 --same-as eDP1 ; mode "default"
+ # Back to normal
+ bindsym Return mode "default"
+ bindsym Escape mode "default"
+ bindsym q mode "default"
+}
+bindsym $mod+o mode "launcher"
+##### Quick window switching (maybe using i3-input will be more generic)
+bindsym $jump+m workspace $ws-mutt
+bindsym $jump+w workspace $ws-weechat
+bindsym $jump+n workspace $ws-newsboat
+bindsym $jump+r workspace $ws-R
+bindsym $jump+s workspace $ws-signal
+bindsym $jump+c workspace $ws-cmus
+bindsym $jump+f workspace $ws-firefox
+bindsym $jump+agrave workspace $ws-org
+#########################
+
+##### Startup #####
+##### Startup tools
+exec --no-startup-id xmodmap ~/.Xmodmap
+exec --no-startup-id xterm -T Mutt -e mutt
+exec --no-startup-id xterm -xrm "xterm*allowTitleOps: false" -T Weechat -e weechat # We should prevent Weechat to change xterm window title (with -xm ...)
+exec --no-startup-id xterm -xrm "xterm*allowTitleOps: false" -T Cmus -e cmus
+exec --no-startup-id pulseeffects
+exec --no-startup-id signal-desktop-disable-gpu
+exec --no-startup-id xterm -T "R Session" -e R
+exec --no-startup-id xterm -T "Newsboat" -e newsboat
+##### Startup applications
+exec --no-startup-id firefox
+exec --no-startup-id org-session
+exec --no-startup-id /usr/bin/emacs --daemon
+exec --no-startup-id xcompmgr
+exec --no-startup-id xrdb ~/.Xdefaults
+exec --no-startup-id clipit
+exec --no-startup-id redshift -l 48.1265:-1.6499 -t 5500:3600 -g 0.8 -m vidmode -v
+exec --no-startup-id dunst -conf ~/.dunstrc
+exec_always feh --bg-scale ~/.config/i3/background.jpg
+###################
+
+##### Workspaces Assignments #####
+##### Assign apps to workspace
+assign [class="^firefox$"] $ws-firefox
+assign [class="^Eclipse$"] $ws2
+assign [title="org-session"] $ws-org
+##### Assign tools workspaces
+assign [class="^Signal$"] $ws-signal
+assign [title="Mutt"] $ws-mutt
+assign [title="Weechat"] $ws-weechat
+assign [title="R Session"] $ws-R
+assign [title="Newsboat"] $ws-newsboat
+assign [class="Pulseeffects"] $ws-cmus
+assign [title="Cmus"] $ws-cmus
+##################################
+
+##### Configure Windows #####
+for_window [class="feh"] floating enable
+for_window [class="Geeqie"] floating enable, resize set 1700 900, move position center
+for_window [class="MPlayer"] floating enable
+for_window [title="^Tmux$"] floating enable, resize set 1700 900, move position center
+for_window [class="^Pavucontrol$"] floating enable, resize set 1700 900, move position center
+#############################
+
+##### Configure Outputs #####
+workspace $ws1 output eDP1 # Compilation
+workspace $ws2 output DP1-2 # Eclipse
+workspace $ws3 output DP1-2
+workspace $ws4 output DP1-2
+workspace $ws5 output DP1-2
+workspace $ws6 output DP1-2
+workspace $ws7 output DP1-2
+workspace $ws8 output DP1-2
+workspace $ws9 output DP1-1 # Web browser
+workspace $ws10 output DP1-2 # org-session signal
+#############################
+
+##### Theme #####
+bar {
+ #mode hide
+ position top
+ font pango:DejaVu Sans Mono 14
+ status_command i3status -c ~/.config/i3/i3status.conf
+ separator_symbol "|"
+ colors {
+ active_workspace #414141 #2d2d2d #ffffff
+ background #2d2d2d
+ focused_workspace #4183F6 #2d76f6 #ffffff
+ inactive_workspace #414141 #2d2d2d #bbbbbb
+ separator #bbbbbb
+ statusline #ffffff
+ urgent_workspace #FFCB21 #ffc609 #ffffff
+}}
+client.focused #4183F6 #2d76f6 #ffffff #d8442e #4183F6
+client.focused_inactive #C1C1C1 #bbbbbb #ffffff #009c58 #C1C1C1
+client.unfocused #414141 #2d2d2d #ffffff #bbbbbb #414141
+client.urgent #FFCB21 #ffc609 #ffffff #d8442e #FFCB21
+
diff --git a/tests/test-apply-brackets-same-line.sh b/tests/test-apply-brackets-same-line.sh
new file mode 100644
index 0000000..8a00047
--- /dev/null
+++ b/tests/test-apply-brackets-same-line.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+wai=$(dirname $(readlink -f $0))
+source "${wai}/include.sh"
+
+##### Test apply on theme with no variables
+$exec apply -d ${data}/google ${data}/config-brackets-same-line
+
diff --git a/tests/test-apply-no-vars.out b/tests/test-apply-no-vars.out
index bcd7f3a..e8c6c64 100644
--- a/tests/test-apply-no-vars.out
+++ b/tests/test-apply-no-vars.out
@@ -296,8 +296,7 @@ bar {
separator #bbbbbb
statusline #ffffff
urgent_workspace #FFCB21 #ffc609 #ffffff
- }
-}
+}}
#################
client.focused #4183F6 #2d76f6 #ffffff #d8442e #4183F6
client.focused_inactive #C1C1C1 #bbbbbb #ffffff #009c58 #C1C1C1
diff --git a/tests/test-apply-strange-colors-keyword-location.out b/tests/test-apply-strange-colors-keyword-location.out
new file mode 100644
index 0000000..6fe13e7
--- /dev/null
+++ b/tests/test-apply-strange-colors-keyword-location.out
@@ -0,0 +1,10 @@
+Traceback (most recent call last):
+ File "/home/loic/Documents/Git/manzerbredes/i3-colors/tests/../src/i3-colors.py", line 67, in <module>
+ args.func(args)
+ File "/home/loic/Documents/Git/manzerbredes/i3-colors/tests/../src/i3-colors.py", line 20, in apply
+ new_config=config.apply(config_file,loaded_theme,dry=True)
+ File "/home/loic/Documents/Git/manzerbredes/i3-colors/src/config.py", line 141, in apply
+ tmp=extract(config_file)
+ File "/home/loic/Documents/Git/manzerbredes/i3-colors/src/config.py", line 52, in extract
+ f=open(config_file,"r")
+FileNotFoundError: [Errno 2] No such file or directory: '/home/loic/Documents/Git/manzerbredes/i3-colors/tests/data/config-strange-colors-keywords-location'
diff --git a/tests/test-apply-strange-colors-keyword-location.sh b/tests/test-apply-strange-colors-keyword-location.sh
new file mode 100644
index 0000000..1137624
--- /dev/null
+++ b/tests/test-apply-strange-colors-keyword-location.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+wai=$(dirname $(readlink -f $0))
+source "${wai}/include.sh"
+
+##### Test apply on theme with no variables
+$exec apply -d ${data}/google ${data}/config-strange-colors-keywords-location
+
diff --git a/tests/test-apply-with-vars.out b/tests/test-apply-with-vars.out
index 5ed41f4..d6bd5df 100644
--- a/tests/test-apply-with-vars.out
+++ b/tests/test-apply-with-vars.out
@@ -296,8 +296,7 @@ bar {
separator #AAAAAA
statusline #FFFFFF
urgent_workspace #CE4045 #CE4045 #FFFFFF
- }
-}
+}}
#################
client.focused #4F99D3 #4F99D3 #151718 #9FCA56 #4F99D3
client.focused_inactive #9FCA56 #9FCA56 #151718 #A074C4 #9FCA56
diff --git a/tests/test-extract-with-vars-and-apply.out b/tests/test-extract-with-vars-and-apply.out
index 2827676..7530aec 100644
--- a/tests/test-extract-with-vars-and-apply.out
+++ b/tests/test-extract-with-vars-and-apply.out
@@ -296,8 +296,7 @@ bar {
separator #bbbbbb
statusline #ffffff
urgent_workspace #FFCB21 #ffc609 #ffffff
- }
-}
+}}
#################
client.focused #4183F6 #aaaaaa #ffffff #d8442e #4183F6
client.focused_inactive #bbb2bb #bbbbbb #ffffff #009c58 #C1C1C1