2 # vim:ts=4:sw=4:expandtab
4 # Checks that the bar config is parsed correctly.
7 use i3test i3_autostart => 0;
9 #####################################################################
10 # test a config without any bars
11 #####################################################################
15 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
18 my $pid = launch_with_config($config);
20 my $i3 = i3(get_socket_path(0));
21 my $bars = $i3->get_bar_config()->recv;
22 is(@$bars, 0, 'no bars configured');
24 exit_gracefully($pid);
26 #####################################################################
27 # now provide a simple bar configuration
28 #####################################################################
32 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
35 # Start a default instance of i3bar which provides workspace buttons.
36 # Additionally, i3status will provide a statusline.
37 status_command i3status --foo
41 $pid = launch_with_config($config);
43 $i3 = i3(get_socket_path(0));
44 $bars = $i3->get_bar_config()->recv;
45 is(@$bars, 1, 'one bar configured');
47 my $bar_id = shift @$bars;
49 my $bar_config = $i3->get_bar_config($bar_id)->recv;
50 is($bar_config->{status_command}, 'i3status --foo', 'status_command correct');
51 ok(!$bar_config->{verbose}, 'verbose off by default');
52 ok($bar_config->{workspace_buttons}, 'workspace buttons enabled per default');
53 is($bar_config->{mode}, 'dock', 'dock mode by default');
54 is($bar_config->{position}, 'bottom', 'position bottom by default');
56 #####################################################################
57 # ensure that reloading cleans up the old bar configs
58 #####################################################################
61 $bars = $i3->get_bar_config()->recv;
62 is(@$bars, 1, 'still one bar configured');
64 exit_gracefully($pid);
66 #####################################################################
67 # validate a more complex configuration
68 #####################################################################
72 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
75 # Start a default instance of i3bar which provides workspace buttons.
76 # Additionally, i3status will provide a statusline.
77 status_command i3status --bar
89 socket_path /tmp/foobar
95 focused_workspace #ffffff #285577
96 active_workspace #888888 #222222
97 inactive_workspace #888888 #222222
98 urgent_workspace #ffffff #900000
103 $pid = launch_with_config($config);
105 $i3 = i3(get_socket_path(0));
106 $bars = $i3->get_bar_config()->recv;
107 is(@$bars, 1, 'one bar configured');
109 $bar_id = shift @$bars;
111 $bar_config = $i3->get_bar_config($bar_id)->recv;
112 is($bar_config->{status_command}, 'i3status --bar', 'status_command correct');
113 ok($bar_config->{verbose}, 'verbose on');
114 ok(!$bar_config->{workspace_buttons}, 'workspace buttons disabled');
115 is($bar_config->{mode}, 'dock', 'dock mode');
116 is($bar_config->{position}, 'top', 'position top');
117 is_deeply($bar_config->{outputs}, [ 'HDMI1', 'HDMI2' ], 'outputs ok');
118 is($bar_config->{tray_output}, 'HDMI2', 'tray_output ok');
119 is($bar_config->{font}, 'Terminus', 'font ok');
120 is($bar_config->{socket_path}, '/tmp/foobar', 'socket_path ok');
121 is_deeply($bar_config->{colors},
123 background => '#ff0000',
124 statusline => '#00ff00',
125 focused_workspace_text => '#ffffff',
126 focused_workspace_bg => '#285577',
127 active_workspace_text => '#888888',
128 active_workspace_bg => '#222222',
129 inactive_workspace_text => '#888888',
130 inactive_workspace_bg => '#222222',
131 urgent_workspace_text => '#ffffff',
132 urgent_workspace_bg => '#900000',
135 exit_gracefully($pid);
137 #####################################################################
138 # ensure that multiple bars get different IDs
139 #####################################################################
142 # i3 config file (v4)
143 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
146 # Start a default instance of i3bar which provides workspace buttons.
147 # Additionally, i3status will provide a statusline.
148 status_command i3status --bar
158 $pid = launch_with_config($config);
160 $i3 = i3(get_socket_path(0));
161 $bars = $i3->get_bar_config()->recv;
162 is(@$bars, 2, 'two bars configured');
163 isnt($bars->[0], $bars->[1], 'bar IDs are different');
165 my $bar1_config = $i3->get_bar_config($bars->[0])->recv;
166 my $bar2_config = $i3->get_bar_config($bars->[1])->recv;
168 isnt($bar1_config->{outputs}, $bar2_config->{outputs}, 'outputs different');
170 exit_gracefully($pid);
172 #####################################################################
173 # make sure comments work properly
174 #####################################################################
177 # i3 config file (v4)
178 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
181 # Start a default instance of i3bar which provides workspace buttons.
182 # Additionally, i3status will provide a statusline.
183 status_command i3status --bar
184 #status_command i3status --qux
185 #status_command i3status --qux
195 $pid = launch_with_config($config);
197 $i3 = i3(get_socket_path(0));
198 $bars = $i3->get_bar_config()->recv;
199 $bar_id = shift @$bars;
201 $bar_config = $i3->get_bar_config($bar_id)->recv;
202 is($bar_config->{status_command}, 'i3status --bar', 'status_command correct');
203 is($bar_config->{colors}->{background}, '#000000', 'background color ok');
205 exit_gracefully($pid);