]> git.sur5r.net Git - i3/i3/blob - testcases/t/177-bar-config.t
Merge branch 'fix-floating-pos'
[i3/i3] / testcases / t / 177-bar-config.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 # !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
4 #
5 # Checks that the bar config is parsed correctly.
6 #
7
8 use i3test;
9
10 #####################################################################
11 # test a config without any bars
12 #####################################################################
13
14 my $config = <<EOT;
15 # i3 config file (v4)
16 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
17 EOT
18
19 my $pid = launch_with_config($config);
20
21 my $i3 = i3(get_socket_path(0));
22 my $bars = $i3->get_bar_config()->recv;
23 is(@$bars, 0, 'no bars configured');
24
25 exit_gracefully($pid);
26
27 #####################################################################
28 # now provide a simple bar configuration
29 #####################################################################
30
31 $config = <<EOT;
32 # i3 config file (v4)
33 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
34
35 bar {
36     # Start a default instance of i3bar which provides workspace buttons.
37     # Additionally, i3status will provide a statusline.
38     status_command i3status --foo
39 }
40 EOT
41
42 $pid = launch_with_config($config);
43
44 $i3 = i3(get_socket_path(0));
45 $bars = $i3->get_bar_config()->recv;
46 is(@$bars, 1, 'one bar configured');
47
48 my $bar_id = shift @$bars;
49
50 my $bar_config = $i3->get_bar_config($bar_id)->recv;
51 is($bar_config->{status_command}, 'i3status --foo', 'status_command correct');
52 ok(!$bar_config->{verbose}, 'verbose off by default');
53 ok($bar_config->{workspace_buttons}, 'workspace buttons enabled per default');
54 is($bar_config->{mode}, 'dock', 'dock mode by default');
55 is($bar_config->{position}, 'bottom', 'position bottom by default');
56
57 #####################################################################
58 # ensure that reloading cleans up the old bar configs
59 #####################################################################
60
61 cmd 'reload';
62 $bars = $i3->get_bar_config()->recv;
63 is(@$bars, 1, 'still one bar configured');
64
65 exit_gracefully($pid);
66
67 #####################################################################
68 # validate a more complex configuration
69 #####################################################################
70
71 $config = <<EOT;
72 # i3 config file (v4)
73 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
74
75 bar {
76     # Start a default instance of i3bar which provides workspace buttons.
77     # Additionally, i3status will provide a statusline.
78     status_command i3status --bar
79
80     output HDMI1
81     output HDMI2
82
83     tray_output LVDS1
84     tray_output HDMI2
85     position top
86     mode dock
87     font Terminus
88     workspace_buttons no
89     verbose yes
90     socket_path /tmp/foobar
91
92     colors {
93         background #ff0000
94         statusline   #00ff00
95
96         focused_workspace   #ffffff #285577
97         active_workspace    #888888 #222222
98         inactive_workspace  #888888 #222222
99         urgent_workspace    #ffffff #900000
100     }
101 }
102 EOT
103
104 $pid = launch_with_config($config);
105
106 $i3 = i3(get_socket_path(0));
107 $bars = $i3->get_bar_config()->recv;
108 is(@$bars, 1, 'one bar configured');
109
110 $bar_id = shift @$bars;
111
112 $bar_config = $i3->get_bar_config($bar_id)->recv;
113 is($bar_config->{status_command}, 'i3status --bar', 'status_command correct');
114 ok($bar_config->{verbose}, 'verbose on');
115 ok(!$bar_config->{workspace_buttons}, 'workspace buttons disabled');
116 is($bar_config->{mode}, 'dock', 'dock mode');
117 is($bar_config->{position}, 'top', 'position top');
118 is_deeply($bar_config->{outputs}, [ 'HDMI1', 'HDMI2' ], 'outputs ok');
119 is($bar_config->{tray_output}, 'HDMI2', 'tray_output ok');
120 is($bar_config->{font}, 'Terminus', 'font ok');
121 is($bar_config->{socket_path}, '/tmp/foobar', 'socket_path ok');
122 is_deeply($bar_config->{colors},
123     {
124         background => '#ff0000',
125         statusline => '#00ff00',
126         focused_workspace_text => '#ffffff',
127         focused_workspace_bg => '#285577',
128         active_workspace_text => '#888888',
129         active_workspace_bg => '#222222',
130         inactive_workspace_text => '#888888',
131         inactive_workspace_bg => '#222222',
132         urgent_workspace_text => '#ffffff',
133         urgent_workspace_bg => '#900000',
134     }, 'colors ok');
135
136 exit_gracefully($pid);
137
138 #####################################################################
139 # ensure that multiple bars get different IDs
140 #####################################################################
141
142 $config = <<EOT;
143 # i3 config file (v4)
144 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
145
146 bar {
147     # Start a default instance of i3bar which provides workspace buttons.
148     # Additionally, i3status will provide a statusline.
149     status_command i3status --bar
150
151     output HDMI1
152 }
153
154 bar {
155     output VGA1
156 }
157 EOT
158
159 $pid = launch_with_config($config);
160
161 $i3 = i3(get_socket_path(0));
162 $bars = $i3->get_bar_config()->recv;
163 is(@$bars, 2, 'two bars configured');
164 isnt($bars->[0], $bars->[1], 'bar IDs are different');
165
166 my $bar1_config = $i3->get_bar_config($bars->[0])->recv;
167 my $bar2_config = $i3->get_bar_config($bars->[1])->recv;
168
169 isnt($bar1_config->{outputs}, $bar2_config->{outputs}, 'outputs different');
170
171 exit_gracefully($pid);
172
173 #####################################################################
174 # make sure comments work properly
175 #####################################################################
176
177 $config = <<EOT;
178 # i3 config file (v4)
179 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
180
181 bar {
182     # Start a default instance of i3bar which provides workspace buttons.
183     # Additionally, i3status will provide a statusline.
184     status_command i3status --bar
185     #status_command i3status --qux
186 #status_command i3status --qux
187
188     output HDMI1
189     colors {
190         background #000000
191         #background #ffffff
192     }
193 }
194 EOT
195
196 $pid = launch_with_config($config);
197
198 $i3 = i3(get_socket_path(0));
199 $bars = $i3->get_bar_config()->recv;
200 $bar_id = shift @$bars;
201
202 $bar_config = $i3->get_bar_config($bar_id)->recv;
203 is($bar_config->{status_command}, 'i3status --bar', 'status_command correct');
204 is($bar_config->{colors}->{background}, '#000000', 'background color ok');
205
206 exit_gracefully($pid);
207
208 done_testing;