]> git.sur5r.net Git - i3/i3.github.io/blob - docs/4.10/user-contributed/py3status.html
save docs for 4.10
[i3/i3.github.io] / docs / 4.10 / user-contributed / py3status.html
1 ---
2 layout: default
3 title: Docs
4 group: Docs
5 ---
6 <div id="content" class="usergen">
7 <h1>User-contributed article: enhanced and extensible i3bar with py3status</h1>
8
9 <p>
10 In the i3 documentation, the recommended tool for <a
11 href="http://i3wm.org/docs/userguide.html#_displaying_a_status_line">displaying
12 a status line is to use i3status</a> combined with i3bar.
13 </p>
14
15 <p>
16 While i3status is very efficient at what it does, it is by design limited to
17 a few modules and does not allow you to inject your own scripts output on your
18 i3bar. This is said pretty clearly on the i3status man page:
19 </p>
20
21 <pre><tt>In i3status, we don’t want to implement process management again.
22 Therefore, there is no module to run arbitrary scripts or commands.
23 Instead, you should use your shell.</tt></pre>
24
25 <h2>Introducing py3status</h2>
26
27 <p>
28 The goal of py3status is to fill this gap by allowing users to simply extend
29 their i3bar while preserving their current i3status configuration. The main idea
30 is to rely on i3status' strength without adding any configuration on the user's
31 side. py3status is thus a wrapper script for i3status and its configuration as
32 explained <a href="https://github.com/ultrabug/py3status/wiki">on the wiki</a>.
33 </p>
34
35 <h2>Usage</h2>
36
37 <p>
38 Using py3status is easy, no need to multi-pipe your scripts after i3status.
39 Instead just replace <i>i3status</i> in your current <b>status_command</b> by
40  <i>py3status</i>.
41 For example, if your current status_command in your i3 config file resides in
42 ~/.i3/i3status.conf, you would change your i3 config to this:
43 </p>
44
45 <pre><tt>status_command py3status -c ~/.i3/i3status.conf</tt></pre>
46
47 <h2>Handle i3bar click events from your i3status.conf</h2>
48
49 <p>
50 Py3status (since v2) is also wrapping and extending your i3status.conf and
51 allows you directly handle all the i3bar click events on any of your configured
52 modules whether they are i3status modules or py3status modules.
53 </p>
54
55 <p>
56 To do so, all you have to do is add a new configuration parameter named
57 <b>on_click [button number]</b> to your module config and py3status will then
58 execute the given i3 command (using i3-msg). This means you can run simple
59 tasks like executing a program or execute any other i3 specific command.
60 </p>
61 <p>Some examples below from i3status.conf:</p>
62
63 <pre><tt>
64 # reload the i3 config when I left click on the i3status time module
65 # and restart i3 when I middle click on it
66 time {
67     on_click 1 = "reload"
68     on_click 2 = "restart"
69 }
70
71 # run wicd-gtk GUI when I left click on the i3status ethernet module
72 # and kill it when I right click on it
73 ethernet eth0 {
74     # if you use %speed, i3status requires root privileges
75     format_up = "E: %ip"
76     format_down = ""
77     on_click 1 = "exec wicd-gtk"
78     on_click 3 = "exec killall wicd-gtk"
79 }
80
81 # run thunar when I left click on the / disk info module
82 disk / {
83     format = "/ %free"
84     on_click 1 = "exec thunar /"
85 }
86
87 # open an URL on opera when I left click on the py3status weather_yahoo module
88 weather_yahoo paris {
89     cache_timeout = 1800
90     city_code = "FRXX0076"
91     forecast_days = 2
92     on_click 1 = "exec opera http://www.meteo.fr"
93     request_timeout = 10
94 }
95 </tt></pre>
96
97 <h2>Use py3status modules in your i3bar</h2>
98
99 <p>
100 Py3status (since v2) also comes with some configurable modules you can load and
101 configure directly from your i3status.conf just like any other i3status module.
102 <a 
103 href="https://github.com/ultrabug/py3status/tree/master/py3status/modules">You 
104 can see the list of the modules and their configuration parameters here.</a>
105 </p>
106
107 <p>
108 To load a py3status module you just have to list it like any other i3status
109 module using the <b>order +=</b> parameter. For example you could insert and 
110 load the imap module like this:
111 </p>
112
113 <pre><tt>
114 order += "disk /home"
115 order += "disk /"
116 order += "imap"
117 order += "time"
118 </tt></pre>
119
120 <p>And then you could configure it like this:</p>
121
122 <pre><tt>
123 # configure the py3status imap module
124 # and run thunderbird when I left click on it
125 imap {
126     cache_timeout = 60
127     imap_server = 'imap.myprovider.com'
128     mailbox = 'INBOX'
129     name = 'Mail'
130     password = 'coconut'
131     port = '993'
132     user = 'mylogin'
133     on_click 1 = "exec thunderbird"
134 }
135 </tt></pre>
136
137
138 <h2>Write your own modules to display your own stuff</h2>
139
140 <p>
141 Py3status features a simple and straightforward module system which you can use
142 to get your own output displayed on your i3bar. You can read more and view some
143 examples <a
144 href="https://github.com/ultrabug/py3status/wiki/Write-your-own-modules"> on the
145 wiki</a>.
146 </p>
147
148 <h2>Documentation</h2>
149
150 <p>
151 You can read the full and up to date documentation on the <a
152 href="https://github.com/ultrabug/py3status">py3status home page</a>.
153 </p>