diff options
Diffstat (limited to 'dot_config/i3')
25 files changed, 2352 insertions, 0 deletions
diff --git a/dot_config/i3/config b/dot_config/i3/config new file mode 100644 index 0000000..bb07f08 --- /dev/null +++ b/dot_config/i3/config | |||
@@ -0,0 +1,631 @@ | |||
1 | # This file is a modified version based on default i3-config-wizard config | ||
2 | # source is available here: | ||
3 | # https://raw.githubusercontent.com/endeavouros-team/endeavouros-i3wm-setup/master/.config/i3/config | ||
4 | # Maintainer: joekamprad [[email protected]] | ||
5 | # https://endeavouros.com | ||
6 | # | ||
7 | # iconic font icon search: https://fontawesome.com/v4.7/cheatsheet/ | ||
8 | # | ||
9 | # --> to update this run the following command (will backup existing setup file) | ||
10 | # wget --backups=1 https://raw.githubusercontent.com/endeavouros-team/endeavouros-i3wm-setup/main/.config/i3/config -P ~/.config/i3/ | ||
11 | # | ||
12 | # Endeavouros-i3 config file | ||
13 | # Source for complete framework of our i3 config and theming here: https://github.com/endeavouros-team/endeavouros-i3wm-setup | ||
14 | # EndeavourOS wiki holds some Information also: https://discovery.endeavouros.com/window-tiling-managers/i3-wm/ | ||
15 | # Please see http://i3wm.org/docs/userguide.html for the official i3 reference! | ||
16 | |||
17 | ####################### | ||
18 | # config starts here: # | ||
19 | ####################### | ||
20 | |||
21 | # Font for window titles. Will also be used by the bar unless a different font | ||
22 | # is used in the bar {} block below. | ||
23 | # This font is widely installed, provides lots of unicode glyphs, right-to-left | ||
24 | # text rendering and scalability on retina/hidpi displays (thanks to pango). | ||
25 | font pango: Noto Sans Regular 11 | ||
26 | |||
27 | # set the mod key to the winkey: | ||
28 | set $mod Mod4 | ||
29 | |||
30 | ##################### | ||
31 | # workspace layout: # | ||
32 | ##################### | ||
33 | |||
34 | # default i3 tiling mode: | ||
35 | workspace_layout default | ||
36 | |||
37 | # i3 stacking layout: | ||
38 | # Each window will be fullscreen and tabbed top to bottom. | ||
39 | workspace_layout tabbed | ||
40 | #workspace_layout stacking | ||
41 | |||
42 | # i3 tabbed layout: | ||
43 | # Each new window will open fullscreen as a tab (left to right) | ||
44 | #workspace_layout tabbed | ||
45 | |||
46 | ############################## | ||
47 | # extra options for windows: # | ||
48 | ############################## | ||
49 | |||
50 | #border indicator on windows: | ||
51 | #new_window pixel 1 | ||
52 | |||
53 | # thin borders | ||
54 | # hide_edge_borders both | ||
55 | |||
56 | # Set inner/outer gaps | ||
57 | #gaps inner 0 | ||
58 | #gaps outer 0 | ||
59 | |||
60 | # show window title bars (not officially supported with i3gaps) | ||
61 | #default_border normal | ||
62 | |||
63 | # window title alignment | ||
64 | #title_align center | ||
65 | |||
66 | # Use Mouse+$mod to drag floating windows to their wanted position | ||
67 | floating_modifier $mod | ||
68 | |||
69 | # switch/iterate between workspaces | ||
70 | bindsym $mod+Tab workspace next | ||
71 | bindsym $mod+Shift+Tab workspace prev | ||
72 | |||
73 | # switch to workspace | ||
74 | bindsym $mod+1 workspace $ws1 | ||
75 | bindsym $mod+2 workspace $ws2 | ||
76 | bindsym $mod+3 workspace $ws3 | ||
77 | bindsym $mod+4 workspace $ws4 | ||
78 | bindsym $mod+5 workspace $ws5 | ||
79 | bindsym $mod+6 workspace $ws6 | ||
80 | bindsym $mod+7 workspace $ws7 | ||
81 | bindsym $mod+8 workspace $ws8 | ||
82 | bindsym $mod+9 workspace $ws9 | ||
83 | bindsym $mod+0 workspace $ws10 | ||
84 | |||
85 | # switch to workspace with numpad keys | ||
86 | bindcode $mod+87 workspace 1 | ||
87 | bindcode $mod+88 workspace 2 | ||
88 | bindcode $mod+89 workspace 3 | ||
89 | bindcode $mod+83 workspace 4 | ||
90 | bindcode $mod+84 workspace 5 | ||
91 | bindcode $mod+85 workspace 6 | ||
92 | bindcode $mod+79 workspace 7 | ||
93 | bindcode $mod+80 workspace 8 | ||
94 | bindcode $mod+81 workspace 9 | ||
95 | bindcode $mod+90 workspace 10 | ||
96 | |||
97 | # switch to workspace with numlock numpad keys | ||
98 | bindcode $mod+Mod2+87 workspace $ws1 | ||
99 | bindcode $mod+Mod2+88 workspace $ws2 | ||
100 | bindcode $mod+Mod2+89 workspace $ws3 | ||
101 | bindcode $mod+Mod2+83 workspace $ws4 | ||
102 | bindcode $mod+Mod2+84 workspace $ws5 | ||
103 | bindcode $mod+Mod2+85 workspace $ws6 | ||
104 | bindcode $mod+Mod2+79 workspace $ws7 | ||
105 | bindcode $mod+Mod2+80 workspace $ws8 | ||
106 | bindcode $mod+Mod2+81 workspace $ws9 | ||
107 | bindcode $mod+Mod2+90 workspace $ws10 | ||
108 | |||
109 | # move focused container to workspace | ||
110 | bindsym $mod+Shift+1 move container to workspace $ws1 | ||
111 | bindsym $mod+Shift+2 move container to workspace $ws2 | ||
112 | bindsym $mod+Shift+3 move container to workspace $ws3 | ||
113 | bindsym $mod+Shift+4 move container to workspace $ws4 | ||
114 | bindsym $mod+Shift+5 move container to workspace $ws5 | ||
115 | bindsym $mod+Shift+6 move container to workspace $ws6 | ||
116 | bindsym $mod+Shift+7 move container to workspace $ws7 | ||
117 | bindsym $mod+Shift+8 move container to workspace $ws8 | ||
118 | bindsym $mod+Shift+9 move container to workspace $ws9 | ||
119 | bindsym $mod+Shift+0 move container to workspace $ws10 | ||
120 | |||
121 | # move focused container to workspace with numpad keys | ||
122 | bindcode $mod+Shift+Mod2+87 move container to workspace $ws1 | ||
123 | bindcode $mod+Shift+Mod2+88 move container to workspace $ws2 | ||
124 | bindcode $mod+Shift+Mod2+89 move container to workspace $ws3 | ||
125 | bindcode $mod+Shift+Mod2+83 move container to workspace $ws4 | ||
126 | bindcode $mod+Shift+Mod2+84 move container to workspace $ws5 | ||
127 | bindcode $mod+Shift+Mod2+85 move container to workspace $ws6 | ||
128 | bindcode $mod+Shift+Mod2+79 move container to workspace $ws7 | ||
129 | bindcode $mod+Shift+Mod2+80 move container to workspace $ws8 | ||
130 | bindcode $mod+Shift+Mod2+81 move container to workspace $ws9 | ||
131 | bindcode $mod+Shift+Mod2+90 move container to workspace $ws10 | ||
132 | |||
133 | # move focused container to workspace with numpad keys | ||
134 | bindcode $mod+Shift+87 move container to workspace $ws1 | ||
135 | bindcode $mod+Shift+88 move container to workspace $ws2 | ||
136 | bindcode $mod+Shift+89 move container to workspace $ws3 | ||
137 | bindcode $mod+Shift+83 move container to workspace $ws4 | ||
138 | bindcode $mod+Shift+84 move container to workspace $ws5 | ||
139 | bindcode $mod+Shift+85 move container to workspace $ws6 | ||
140 | bindcode $mod+Shift+79 move container to workspace $ws7 | ||
141 | bindcode $mod+Shift+80 move container to workspace $ws8 | ||
142 | bindcode $mod+Shift+81 move container to workspace $ws9 | ||
143 | bindcode $mod+Shift+90 move container to workspace $ws10 | ||
144 | |||
145 | # resize window (you can also use the mouse for that): | ||
146 | mode "resize" { | ||
147 | bindsym h resize shrink width 10 px or 10 ppt | ||
148 | bindsym k resize grow height 10 px or 10 ppt | ||
149 | bindsym j resize shrink height 10 px or 10 ppt | ||
150 | bindsym l resize grow width 10 px or 10 ppt | ||
151 | |||
152 | # same bindings, but for the arrow keys | ||
153 | bindsym Left resize shrink width 10 px or 10 ppt | ||
154 | bindsym Up resize grow height 10 px or 10 ppt | ||
155 | bindsym Down resize shrink height 10 px or 10 ppt | ||
156 | bindsym Right resize grow width 10 px or 10 ppt | ||
157 | |||
158 | # back to normal: Enter or Escape | ||
159 | # bindsym Return mode "default" | ||
160 | bindsym Escape mode "default" | ||
161 | } | ||
162 | |||
163 | bindsym $mod+r mode "resize" | ||
164 | bindsym $mod+space [floating] resize set 1280 800 | ||
165 | |||
166 | ###################################### | ||
167 | # keybindings for different actions: # | ||
168 | ###################################### | ||
169 | |||
170 | # start a terminal | ||
171 | bindsym $mod+Return exec xfce4-terminal | ||
172 | |||
173 | # kill focused window | ||
174 | bindsym $mod+q kill | ||
175 | |||
176 | # exit-menu | ||
177 | bindsym $mod+Shift+e exec ~/.config/i3/scripts/powermenu | ||
178 | |||
179 | # Lock the system | ||
180 | # lock with a picture: | ||
181 | #bindsym $mod+l exec i3lock -i ~/.config/i3/i3-lock-screen.png -p default|win -t | ||
182 | # lock by blurring the screen: | ||
183 | bindsym $mod+l exec ~/.config/i3/scripts/blur-lock | ||
184 | |||
185 | # reload the configuration file | ||
186 | bindsym $mod+Shift+c reload | ||
187 | |||
188 | # restart i3 inplace (preserves your layout/session, can be used to update i3) | ||
189 | bindsym $mod+Shift+r restart | ||
190 | |||
191 | # keybinding in fancy rofi (automated): | ||
192 | bindsym F1 exec ~/.config/i3/scripts/keyhint-2 | ||
193 | # alternative | ||
194 | # keybinding list in editor: | ||
195 | # bindsym $mod+F1 exec xed ~/.config/i3/keybindings | ||
196 | |||
197 | # Backlight control | ||
198 | bindsym XF86MonBrightnessUp exec --no-startup-id xbacklight +5 && notify-send "Brightness - $(xbacklight -get | cut -d '.' -f 1)%" | ||
199 | bindsym XF86MonBrightnessDown exec --no-startup-id xbacklight -5 && notify-send "Brightness - $(xbacklight -get | cut -d '.' -f 1)%" | ||
200 | |||
201 | # change focus | ||
202 | bindsym $mod+j focus left | ||
203 | bindsym $mod+k focus down | ||
204 | bindsym $mod+b focus up | ||
205 | bindsym $mod+o focus right | ||
206 | |||
207 | # alternatively, you can use the cursor keys: | ||
208 | bindsym $mod+Left focus left | ||
209 | bindsym $mod+Down focus down | ||
210 | bindsym $mod+Up focus up | ||
211 | bindsym $mod+Right focus right | ||
212 | |||
213 | # move focused window | ||
214 | bindsym $mod+Shift+j move left | ||
215 | bindsym $mod+Shift+k move down | ||
216 | bindsym $mod+Shift+b move up | ||
217 | bindsym $mod+Shift+o move right | ||
218 | |||
219 | # alternatively, you can use the cursor keys: | ||
220 | bindsym $mod+Shift+Left move left | ||
221 | bindsym $mod+Shift+Down move down | ||
222 | bindsym $mod+Shift+Up move up | ||
223 | bindsym $mod+Shift+Right move right | ||
224 | |||
225 | # split in horizontal orientation | ||
226 | bindsym $mod+h split h | ||
227 | |||
228 | # split in vertical orientation | ||
229 | bindsym $mod+v split v | ||
230 | |||
231 | # enter fullscreen mode for the focused container | ||
232 | bindsym $mod+f fullscreen toggle | ||
233 | |||
234 | # change container layout (stacked, tabbed, toggle split) | ||
235 | bindsym $mod+s layout stacking | ||
236 | bindsym $mod+g layout tabbed | ||
237 | bindsym $mod+e layout toggle split | ||
238 | |||
239 | # toggle tiling / floating | ||
240 | bindsym $mod+Shift+space floating toggle | ||
241 | |||
242 | # change focus between tiling / floating windows | ||
243 | #bindsym $mod+space focus mode_toggle | ||
244 | |||
245 | # focus the parent container | ||
246 | bindsym $mod+a focus parent | ||
247 | |||
248 | # open new empty workspace | ||
249 | bindsym $mod+Shift+n exec --no-startup-id ~/.config/i3/scripts/empty_workspace | ||
250 | |||
251 | # Multimedia Keys | ||
252 | |||
253 | # volume | ||
254 | bindsym XF86AudioRaiseVolume exec --no-startup-id amixer -D pulse sset Master 5%+ && pkill -RTMIN+1 i3blocks | ||
255 | bindsym XF86AudioLowerVolume exec --no-startup-id amixer -D pulse sset Master 5%- && pkill -RTMIN+1 i3blocks | ||
256 | |||
257 | # gradular volume control | ||
258 | bindsym $mod+XF86AudioRaiseVolume exec --no-startup-id amixer -D pulse sset Master 1%+ && pkill -RTMIN+1 i3blocks | ||
259 | bindsym $mod+XF86AudioLowerVolume exec --no-startup-id amixer -D pulse sset Master 1%- && pkill -RTMIN+1 i3blocks | ||
260 | |||
261 | # mute | ||
262 | bindsym XF86AudioMute exec --no-startup-id amixer sset Master toggle && killall -USR1 i3blocks | ||
263 | |||
264 | # audio control | ||
265 | bindsym XF86AudioPlay exec --no-startup-id playerctl play | ||
266 | bindsym XF86AudioPause exec --no-startup-id playerctl pause | ||
267 | bindsym XF86AudioNext exec --no-startup-id playerctl next | ||
268 | bindsym XF86AudioPrev exec --no-startup-id playerctl previous | ||
269 | |||
270 | # Redirect sound to headphones | ||
271 | #bindsym $mod+p exec /usr/local/bin/switch-audio-port | ||
272 | |||
273 | ## App shortcuts | ||
274 | bindsym $mod+w exec /usr/bin/firefox | ||
275 | bindsym $mod+n exec /usr/bin/thunar | ||
276 | bindsym Print exec --no-startup-id mkdir -p ~/Pictures/Screenshot/`date +"%Y/%m"` && scrot ~/Pictures/Screenshot/%Y/%m/%Y-%m-%d-%T-screenshot.png && notify-send "Screenshot saved" | ||
277 | |||
278 | # Power Profiles menu switcher (rofi) | ||
279 | bindsym $mod+Shift+p exec --no-startup-id ~/.config/i3/scripts/power-profiles | ||
280 | |||
281 | ########################################## | ||
282 | # configuration for workspace behaviour: # | ||
283 | ########################################## | ||
284 | |||
285 | # Define names for default workspaces for which we configure key bindings later on. | ||
286 | # We use variables to avoid repeating the names in multiple places. | ||
287 | set $ws1 "1:" | ||
288 | set $ws2 "2:" | ||
289 | set $ws3 "3:" | ||
290 | set $ws4 "4:" | ||
291 | set $ws5 "5:" | ||
292 | set $ws6 "6" | ||
293 | set $ws7 "7" | ||
294 | set $ws8 "8" | ||
295 | set $ws9 "9" | ||
296 | set $ws10 "10" | ||
297 | |||
298 | # use workspaces on different displays: | ||
299 | # where you have to replace VGA-0/HDMI-0 with the names for your displays | ||
300 | # you can get from xrandr command | ||
301 | #workspace $ws1 output VGA-0 | ||
302 | #workspace $ws2 output VGA-0 | ||
303 | #workspace $ws3 output HDMI-0 | ||
304 | #workspace $ws4 output HDMI-0 | ||
305 | #workspace $ws5 output HDMI-0 | ||
306 | |||
307 | # bind program to workspace and focus to them on startup: | ||
308 | #assign [class="Xfce4-terminal"] $ws1 | ||
309 | assign [class="jetbrains-clion"] $ws1 | ||
310 | assign [class="Thunar"] $ws3 | ||
311 | assign [class="thunderbird"] $ws4 | ||
312 | assign [class="TelegramDesktop"] $ws5 | ||
313 | assign [class="discord"] $ws5 | ||
314 | assign [class="Microsoft Teams - Preview"] $ws5 | ||
315 | |||
316 | # automatic set focus new window if it opens on another workspace then the current: | ||
317 | for_window [class=Xfce4-terminal] focus | ||
318 | for_window [class=(?i)firefox] focus | ||
319 | for_window [class=Thunar] focus | ||
320 | for_window [class=thunderbird] focus | ||
321 | for_window [class=TelegramDesktop] focus | ||
322 | for_window [class="Microsoft Teams - Preview"] focus | ||
323 | |||
324 | ############## | ||
325 | # compositor # | ||
326 | ############## | ||
327 | |||
328 | # transparency | ||
329 | # uncomment one of them to be used (picom package is installed per default) | ||
330 | # options could need changes, related to used GPU and drivers. | ||
331 | # to find the right setting consult the archwiki or ask at the forum. | ||
332 | # | ||
333 | # xcompmgr: https://wiki.archlinux.org/title/Xcompmgr | ||
334 | # manpage: https://man.archlinux.org/man/xcompmgr.1.en | ||
335 | #exec --no-startup-id xcompmgr -C -n & | ||
336 | # or an more specialized config like this: | ||
337 | #exec --no-startup-id xcompmgr -c -C -t-5 -l-5 -r4.2 -o.55 & | ||
338 | # | ||
339 | # or: | ||
340 | # | ||
341 | # picom: https://wiki.archlinux.org/title/Picom | ||
342 | # manpage: https://man.archlinux.org/man/picom.1.en | ||
343 | # The default configuration is available in /etc/xdg/picom.conf | ||
344 | # For modifications, it can be copied to ~/.config/picom/picom.conf or ~/.config/picom.conf | ||
345 | # | ||
346 | # using default config | ||
347 | #exec_always --no-startup-id picom --backed glx --vsync | ||
348 | #exec_always --no-startup-id picom -b | ||
349 | # | ||
350 | # for custom config: | ||
351 | exec_always --no-startup-id picom --config ~/.config/picom.conf | ||
352 | |||
353 | ############################################# | ||
354 | # autostart applications/services on login: # | ||
355 | ############################################# | ||
356 | |||
357 | #get auth work with polkit-gnome | ||
358 | exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 | ||
359 | |||
360 | #ibus daemon | ||
361 | exec --no-startup-id env GDK_SCALE=1 ibus-daemon -drxR | ||
362 | |||
363 | #fcitx5 daemon | ||
364 | #exec --no-startup-id fcitx5 -d | ||
365 | |||
366 | # dex execute .desktop files + apps using /etc/xdg/autostart. | ||
367 | # when second to i3 a DE is installed or mixed usage of i3 + xfce4 or GNOME | ||
368 | # in this cases better disable dex and use manual starting apps using xdg/autostart | ||
369 | # if enabled you should comment welcome app. | ||
370 | # https://github.com/jceb/dex | ||
371 | #exec --no-startup-id dex -a -s /etc/xdg/autostart/:~/.config/autostart/ | ||
372 | exec --no-startup-id dex --autostart --environment i3 | ||
373 | |||
374 | # start welcome app | ||
375 | #exec --no-startup-id sh /usr/share/endeavouros/scripts/welcome --startdelay=3 | ||
376 | |||
377 | # num lock activated | ||
378 | #exec --no-startup-id numlockx on | ||
379 | |||
380 | # configure multiple keyboard layouts and hotkey to switch (Alt+CAPSLOCK in this example) | ||
381 | #exec --no-startup-id setxkbmap -layout 'us,sk' -variant altgr-intl,qwerty -option 'grp:alt_caps_toggle' | ||
382 | |||
383 | # start conky: | ||
384 | #exec_always --no-startup-id conky | ||
385 | |||
386 | # start a script to setup displays | ||
387 | # uncomment the next line, use arandr to setup displays and save the file as monitor: | ||
388 | exec --no-startup-id ~/.screenlayout/monitor.sh | ||
389 | |||
390 | # set wallpaper | ||
391 | exec --no-startup-id sleep 2 && nitrogen --restore | ||
392 | #exec --no-startup-id feh --bg-fill /usr/share/endeavouros/backgrounds/endeavouros_i3.png | ||
393 | |||
394 | # set powersavings for display: | ||
395 | #exec --no-startup-id xset s 0 dpms 600 600 600 | ||
396 | |||
397 | # disable power saving (for example if using xscreensaver) | ||
398 | exec --no-startup-id xset -dpms | ||
399 | |||
400 | # use xautolock to use autosuspend rules for mobile devices | ||
401 | # https://wiki.archlinux.org/title/Session_lock#xautolock | ||
402 | #exec --no-startup-id xautolock -time 60 -locker "systemctl suspend" | ||
403 | |||
404 | |||
405 | # xscreensaver | ||
406 | # https://www.jwz.org/xscreensaver | ||
407 | #exec --no-startup-id xscreensaver --no-splash | ||
408 | |||
409 | # Desktop notifications | ||
410 | exec --no-startup-id dunst --config ~/.config/dunst/dunstrc | ||
411 | # alternative if you installed aside with XFCE4: | ||
412 | #exec --no-startup-id env GDK_SCALE=2 /usr/lib/xfce4/notifyd/xfce4-notifyd & | ||
413 | |||
414 | # autotiling script | ||
415 | # https://github.com/nwg-piotr/autotiling | ||
416 | # `yay -S autotiling ;) (it is in AUR) | ||
417 | #exec_always --no-startup-id autotiling | ||
418 | |||
419 | # Autostart apps as you like | ||
420 | #exec --no-startup-id sleep 2 && xfce4-terminal | ||
421 | #exec --no-startup-id sleep 7 && firefox https://github.com/endeavouros-team/endeavouros-i3wm-setup/blob/main/force-knowledge.md | ||
422 | #exec --no-startup-id sleep 3 && thunar | ||
423 | exec --no-startup-id sleep 1 && thunderbird | ||
424 | |||
425 | ############### | ||
426 | # system tray # | ||
427 | ############### | ||
428 | # if you do not use dex: exec --no-startup-id dex --autostart --environment i3 | ||
429 | # you need to have tray apps started manually one by one: | ||
430 | |||
431 | # start blueberry app for managing bluetooth devices from tray: | ||
432 | #exec --no-startup-id blueberry-tray | ||
433 | |||
434 | # networkmanager-applet | ||
435 | #exec --no-startup-id nm-applet | ||
436 | |||
437 | # clipman-applet | ||
438 | #exec --no-startup-id xfce4-clipman | ||
439 | |||
440 | ################## | ||
441 | # floating rules # | ||
442 | ################## | ||
443 | |||
444 | # set floating (nontiling) for apps needing it | ||
445 | for_window [class="Yad" instance="yad"] floating enable | ||
446 | for_window [class="Galculator" instance="galculator"] floating enable | ||
447 | for_window [class="Blueberry.py" instance="blueberry.py"] floating enable | ||
448 | |||
449 | # set floating (nontiling) for special apps | ||
450 | for_window [class="Xsane" instance="xsane"] floating enable | ||
451 | for_window [class="Pavucontrol" instance="pavucontrol"] floating enable | ||
452 | for_window [class="qt5ct" instance="qt5ct"] floating enable | ||
453 | for_window [class="Blueberry.py" instance="blueberry.py"] floating enable | ||
454 | for_window [class="Bluetooth-sendto" instance="bluetooth-sendto"] floating enable | ||
455 | for_window [class="Pamac-manager"] floating enable | ||
456 | for_window [window_role="About"] floating enable | ||
457 | for_window [class="copyq"] floating enable | ||
458 | for_window [class="Nm-connection-editor"] floating enable | ||
459 | for_window [class="flameshot"] floating enable | ||
460 | for_window [class="TelegramDesktop"] floating enable resize set 1300 1200 | ||
461 | for_window [class="eudic"] floating enable resize set 800 800 | ||
462 | |||
463 | # Make the currently focused window a scratchpad | ||
464 | bindsym $mod+Shift+m move scratchpad | ||
465 | |||
466 | # Show the first scratchpad window | ||
467 | bindsym $mod+m scratchpad show | ||
468 | |||
469 | # set border of floating window | ||
470 | for_window [class="urxvt"] border pixel 1 | ||
471 | |||
472 | # set size of floating window | ||
473 | #for_window [window_role="(?i)GtkFileChooserDialog"] resize set 640 480 #to set size of file choose dialog | ||
474 | #for_window [class=".*"] resize set 1280 680 #to change size of all floating windows | ||
475 | |||
476 | # set position of floating window | ||
477 | for_window [class=".*"] move position center | ||
478 | |||
479 | ###################################### | ||
480 | # color settings for bar and windows # | ||
481 | ###################################### | ||
482 | |||
483 | # Define colors variables: | ||
484 | set $darkbluetrans #08052be6 | ||
485 | set $darkblue #08052b | ||
486 | set $lightblue #5294e2 | ||
487 | set $urgentred #e53935 | ||
488 | set $white #ffffff | ||
489 | set $black #000000 | ||
490 | set $purple #e345ff | ||
491 | set $darkgrey #383c4a | ||
492 | set $grey #b0b5bd | ||
493 | set $mediumgrey #8b8b8b | ||
494 | set $yellowbrown #e1b700 | ||
495 | |||
496 | # define colors for windows: | ||
497 | #class border bground text indicator child_border | ||
498 | client.focused $lightblue $darkblue $white $mediumgrey $mediumgrey | ||
499 | client.unfocused $darkblue $darkblue $grey $darkgrey $darkgrey | ||
500 | client.focused_inactive $darkblue $darkblue $grey $black $black | ||
501 | client.urgent $urgentred $urgentred $white $yellowbrown $yellowbrown | ||
502 | |||
503 | ############################################ | ||
504 | # bar settings (input comes from i3blocks) # | ||
505 | ############################################ | ||
506 | |||
507 | # Start i3bar to display a workspace bar | ||
508 | # (plus the system information i3status finds out, if available) | ||
509 | bar { | ||
510 | font pango: Noto Sans Regular 16 | ||
511 | status_command i3blocks -c ~/.config/i3/i3blocks.conf | ||
512 | position bottom | ||
513 | output eDP-1 | ||
514 | i3bar_command i3bar | ||
515 | #i3bar_command i3bar --transparency | ||
516 | #tray_output none | ||
517 | tray_output primary | ||
518 | tray_padding 0 | ||
519 | strip_workspace_numbers no | ||
520 | |||
521 | colors { | ||
522 | separator $purple | ||
523 | background $darkgrey | ||
524 | statusline $white | ||
525 | focused_workspace $mediumgrey $grey $darkgrey $purple | ||
526 | active_workspace $lightblue $mediumgrey $darkgrey $purple | ||
527 | inactive_workspace $darkgrey $darkgrey $grey $purple | ||
528 | urgent_workspace $urgentred $urgentred $white $purple | ||
529 | } | ||
530 | } | ||
531 | |||
532 | |||
533 | bar { | ||
534 | font pango: Noto Sans Regular 11 | ||
535 | status_command i3blocks -c ~/.config/i3/i3blocks.conf | ||
536 | position bottom | ||
537 | i3bar_command i3bar | ||
538 | output DP-3 | ||
539 | tray_output primary | ||
540 | tray_padding 0 | ||
541 | strip_workspace_numbers no | ||
542 | |||
543 | colors { | ||
544 | separator $purple | ||
545 | background $darkgrey | ||
546 | statusline $white | ||
547 | focused_workspace $mediumgrey $grey $darkgrey $purple | ||
548 | active_workspace $lightblue $mediumgrey $darkgrey $purple | ||
549 | inactive_workspace $darkgrey $darkgrey $grey $purple | ||
550 | urgent_workspace $urgentred $urgentred $white $purple | ||
551 | } | ||
552 | } | ||
553 | |||
554 | |||
555 | bar { | ||
556 | font pango: Noto Sans Regular 11 | ||
557 | status_command i3blocks -c ~/.config/i3/i3blocks.conf | ||
558 | position bottom | ||
559 | i3bar_command i3bar | ||
560 | output DP-4 | ||
561 | tray_output primary | ||
562 | tray_padding 0 | ||
563 | strip_workspace_numbers no | ||
564 | |||
565 | colors { | ||
566 | separator $purple | ||
567 | background $darkgrey | ||
568 | statusline $white | ||
569 | focused_workspace $mediumgrey $grey $darkgrey $purple | ||
570 | active_workspace $lightblue $mediumgrey $darkgrey $purple | ||
571 | inactive_workspace $darkgrey $darkgrey $grey $purple | ||
572 | urgent_workspace $urgentred $urgentred $white $purple | ||
573 | } | ||
574 | } | ||
575 | |||
576 | # you can add different bars for multidisplay setups on each display: | ||
577 | # set output HDMI-0 to the display you want the bar, --transparency can be set. | ||
578 | # Transparency needs rgba color codes to be used where the last two letters are the transparency factor see here: | ||
579 | # https://gist.github.com/lopspower/03fb1cc0ac9f32ef38f4 | ||
580 | # #08052be6 --> e6=90% | ||
581 | |||
582 | # bar { | ||
583 | # font pango: Noto Sans Regular 10 | ||
584 | # status_command i3blocks -c ~/.config/i3/i3blocks-2.conf | ||
585 | # i3bar_command i3bar --transparency | ||
586 | # output HDMI-0 | ||
587 | # position bottom | ||
588 | # | ||
589 | # When strip_workspace_numbers is set to yes, | ||
590 | # any workspace that has a name of the form | ||
591 | # “[n][:][NAME]” will display only the name. | ||
592 | #strip_workspace_numbers yes | ||
593 | ##strip_workspace_name no | ||
594 | # | ||
595 | # colors { | ||
596 | # separator $purple | ||
597 | # background $darkbluetrans | ||
598 | # statusline $white | ||
599 | # border bg txt indicator | ||
600 | # focused_workspace $lighterblue $lighterblue $darkblue $purple | ||
601 | # active_workspace $lightdblue $lightdblue $darkblue $purple | ||
602 | # inactive_workspace $darkblue $darkblue $lightdblue $purple | ||
603 | # urgent_workspace $urgentred $urgentred $white $purple | ||
604 | # } | ||
605 | #} | ||
606 | |||
607 | ##################################### | ||
608 | # Application menu handled by rofi: # | ||
609 | ##################################### | ||
610 | |||
611 | ## rofi bindings fancy application menu ($mod+d /F9 optional disabled) | ||
612 | |||
613 | bindsym $mod+d exec rofi -modi drun -show drun \ | ||
614 | -config ~/.config/rofi/rofidmenu.rasi | ||
615 | |||
616 | #bindsym F9 exec rofi -modi drun -show drun \ | ||
617 | # -config ~/.config/rofi/rofidmenu.rasi | ||
618 | |||
619 | ## rofi bindings for window menu ($mod+t /F10 optional disabled) | ||
620 | |||
621 | bindsym $mod+t exec rofi -show window \ | ||
622 | -config ~/.config/rofi/rofidmenu.rasi | ||
623 | |||
624 | #bindsym F10 exec rofi -show window \ | ||
625 | # -config ~/.config/rofi/rofidmenu.rasi | ||
626 | |||
627 | ## rofi bindings to manage clipboard (install rofi-greenclip from the AUR) | ||
628 | |||
629 | #exec --no-startup-id greenclip daemon>/dev/null | ||
630 | #bindsym $mod+c exec --no-startup-id rofi -modi "clipboard:greenclip print" -show clipboard \ | ||
631 | # -config ~/.config/rofi/rofidmenu.rasi | ||
diff --git a/dot_config/i3/i3blocks.conf b/dot_config/i3/i3blocks.conf new file mode 100644 index 0000000..dd9f5ac --- /dev/null +++ b/dot_config/i3/i3blocks.conf | |||
@@ -0,0 +1,182 @@ | |||
1 | # i3blocks config file changed for EndeavourOS-i3 setup | ||
2 | |||
3 | # source is available here: | ||
4 | # https://raw.githubusercontent.com/endeavouros-team/endeavouros-i3wm-setup/main/.config/i3/i3blocks.conf | ||
5 | # Maintainer: joekamprad [[email protected]] | ||
6 | # Former Visual Designer: Florent Valetti [@FLVAL EndeavourOS] | ||
7 | # created for i3wm setup on EndeavourOS | ||
8 | # https://endeavouros.com | ||
9 | |||
10 | # cheatsheet for icon fonts used on the block-bar: | ||
11 | # https://fontawesome.com/v4.7/cheatsheet/ | ||
12 | |||
13 | # --> to update this run the following command: | ||
14 | # wget --backups=1 https://raw.githubusercontent.com/endeavouros-team/endeavouros-i3wm-setup/main/.config/i3/i3blocks.conf -P ~/.config/i3/ | ||
15 | |||
16 | # Please see man i3blocks for a complete reference! | ||
17 | # The man page is also hosted at http://vivien.github.io/i3blocks | ||
18 | |||
19 | |||
20 | # List of valid properties: | ||
21 | # | ||
22 | # align | ||
23 | # color | ||
24 | # command | ||
25 | # full_text | ||
26 | # instance | ||
27 | # interval | ||
28 | # label | ||
29 | # min_width | ||
30 | # name | ||
31 | # separator | ||
32 | # separator_block_width | ||
33 | # short_text | ||
34 | # signal | ||
35 | # urgent | ||
36 | |||
37 | # Global properties | ||
38 | # | ||
39 | # The top properties below are applied to every block, but can be overridden. | ||
40 | separator=false | ||
41 | markup=pango | ||
42 | |||
43 | #[Weather] | ||
44 | #command=~/.config/i3/scripts/openweather | ||
45 | # or: | ||
46 | #command=~/.config/i3/scripts/openweather-city | ||
47 | #interval=1800 | ||
48 | #color=#7275b3 | ||
49 | |||
50 | #[terminal] | ||
51 | #full_text= | ||
52 | #color=#807dfe | ||
53 | #command=i3-msg -q exec xfce4-terminal | ||
54 | |||
55 | #[browser] | ||
56 | #full_text= | ||
57 | #color=#ff7f81 | ||
58 | #command=i3-msg -q exec firefox | ||
59 | |||
60 | #[files] | ||
61 | #full_text= | ||
62 | #color=#7f3fbf | ||
63 | #command=i3-msg -q exec thunar ~/ | ||
64 | |||
65 | #[mail] | ||
66 | #full_text= | ||
67 | #color=#dbcb75 | ||
68 | #command=i3-msg -q exec thunderbird | ||
69 | |||
70 | #[simple-2] | ||
71 | #full_text=: : | ||
72 | #color=#717171 | ||
73 | |||
74 | # Disk usage | ||
75 | # | ||
76 | # The directory defaults to $HOME if the instance is not specified. | ||
77 | # The script may be called with a optional argument to set the alert | ||
78 | # (defaults to 10 for 10%). | ||
79 | #[disk] | ||
80 | #label= | ||
81 | #instance=/home | ||
82 | #command=~/.config/i3/scripts/disk | ||
83 | #interval=30 | ||
84 | |||
85 | # Memory usage | ||
86 | # | ||
87 | # The type defaults to "mem" if the instance is not specified. | ||
88 | #[memory] | ||
89 | #label= | ||
90 | #command=~/.config/i3/scripts/memory | ||
91 | #interval=2 | ||
92 | |||
93 | #[cpu_usage] | ||
94 | #label= | ||
95 | #command=~/.config/i3/scripts/cpu_usage | ||
96 | ##min_width=CPU: 100.00% | ||
97 | #interval=2 | ||
98 | |||
99 | [CPU-temperature] | ||
100 | label= | ||
101 | command=~/.config/i3/scripts/temperature | ||
102 | interval=30 | ||
103 | #T_WARN=70 | ||
104 | #T_CRIT=90 | ||
105 | #SENSOR_CHIP="" | ||
106 | # where SENSOR_CHIP can be find with sensors output | ||
107 | # can be used also for GPU temperature or other temperature sensors lm-sensors detects. | ||
108 | |||
109 | # showing name of connected network (enable for wifi use) | ||
110 | [net] | ||
111 | label= | ||
112 | command=echo "$(LANG=C nmcli d | grep connected | awk '{print $4}' | head -n1)" | ||
113 | interval=30 | ||
114 | |||
115 | [bandwidth] | ||
116 | command=~/.config/i3/scripts/bandwidth2 | ||
117 | interval=persist | ||
118 | |||
119 | # Battery indicator | ||
120 | [battery] | ||
121 | command=~/.config/i3/scripts/battery2 | ||
122 | # for alternative battery script change to battery1 | ||
123 | # change this to battery-pinebook-pro if you are running on pinebook-pro | ||
124 | label= | ||
125 | interval=30 | ||
126 | |||
127 | #[simple-2] | ||
128 | #full_text=: | ||
129 | #color=#717171 | ||
130 | |||
131 | [pavucontrol] | ||
132 | full_text= | ||
133 | command=pavucontrol | ||
134 | |||
135 | [volume-pulseaudio] | ||
136 | command=~/.config/i3/scripts/volume | ||
137 | instance=Master | ||
138 | interval=1 | ||
139 | |||
140 | # display keyboard layout name | ||
141 | # for keyboard layouts switcher | ||
142 | # see i3 config file | ||
143 | # this needs xkblayout-state installed from the AUR: | ||
144 | # https://aur.archlinux.org/packages/xkblayout-state-git | ||
145 | #[keyboard-layout] | ||
146 | #command=~/.config/i3/scripts/keyboard-layout | ||
147 | #interval=2 | ||
148 | |||
149 | #[keybindings] | ||
150 | #full_text= | ||
151 | #command=~/.config/i3/scripts/keyhint | ||
152 | |||
153 | # power-profiles-daemon implementation: | ||
154 | # needs package power-profiles-daemon installed and the service running see here: | ||
155 | # https://wiki.archlinux.org/title/CPU_frequency_scaling#power-profiles-daemon | ||
156 | |||
157 | #set power-profile | ||
158 | [ppd_menu] | ||
159 | full_text= | ||
160 | command=~/.config/i3/scripts/power-profiles | ||
161 | color=#407437 | ||
162 | |||
163 | #Show the current power-profile | ||
164 | #[ppd-status] | ||
165 | #command=~/.config/i3/scripts/ppd-status | ||
166 | #interval=5 | ||
167 | |||
168 | [time] | ||
169 | command=date '+%a %b %d %H:%M' | ||
170 | interval=1 | ||
171 | |||
172 | [worldclock] | ||
173 | full_text=Clock | ||
174 | command=~/.config/i3/scripts/worldclock | ||
175 | |||
176 | [shutdown_menu] | ||
177 | full_text= | ||
178 | command=~/.config/i3/scripts/powermenu | ||
179 | |||
180 | [simple-2] | ||
181 | full_text=: | ||
182 | color=#717171 | ||
diff --git a/dot_config/i3/keybindings b/dot_config/i3/keybindings new file mode 100644 index 0000000..f5edbc6 --- /dev/null +++ b/dot_config/i3/keybindings | |||
@@ -0,0 +1,106 @@ | |||
1 | EndeavourOS i3wm Keybindings cheat sheet: | ||
2 | |||
3 | --> to update this run the following command: | ||
4 | wget --backups=1 https://raw.githubusercontent.com/endeavouros-team/endeavouros-i3wm-setup/main/.config/i3/keybindings -P ~/.config/i3/ | ||
5 | |||
6 | All sources and updates are available at GitHub: | ||
7 | https://github.com/endeavouros-team/endeavouros-i3wm-setup | ||
8 | |||
9 | For reference consult our WIKI: | ||
10 | https://discovery.endeavouros.com/window-tiling-managers/i3-wm/ | ||
11 | |||
12 | = windows key | ||
13 | |||
14 | # start xfce4-terminal | ||
15 | +Return | ||
16 | |||
17 | # kill focused window | ||
18 | +q | ||
19 | |||
20 | # Application menu search by typing (fancy Rofi menu): | ||
21 | +d | ||
22 | |||
23 | # Window switcher menu (fancy Rofi menu): | ||
24 | +t | ||
25 | |||
26 | # fancy exit-menu on bottom right: | ||
27 | +Shift+e | ||
28 | |||
29 | # Lock the system | ||
30 | # lock with a picture or blurring the screen (options in config) | ||
31 | +l | ||
32 | |||
33 | # reload the configuration file | ||
34 | +Shift+c | ||
35 | |||
36 | # restart i3 inplace (preserves your layout/session, can be used to upgrade i3) | ||
37 | +Shift+r | ||
38 | |||
39 | # keybinding in fancy rofi (automated) | ||
40 | F1 | ||
41 | |||
42 | # full keybinding list in editor: | ||
43 | +F1 | ||
44 | |||
45 | # change window focus | ||
46 | +j focus left | ||
47 | +k focus down | ||
48 | +b focus up | ||
49 | +o focus right | ||
50 | |||
51 | # alternatively, you can use the cursor keys: | ||
52 | +Left focus left | ||
53 | +Down focus down | ||
54 | +Up focus up | ||
55 | +Right focus right | ||
56 | |||
57 | # move a focused window | ||
58 | +Shift+j move left | ||
59 | +Shift+k move down | ||
60 | +Shift+b move up | ||
61 | +Shift+o move right | ||
62 | |||
63 | # alternatively, you can use the cursor keys: | ||
64 | +Shift+Left move left | ||
65 | +Shift+Down move down | ||
66 | +Shift+Up move up | ||
67 | +Shift+Right move right | ||
68 | |||
69 | # split in horizontal orientation | ||
70 | +h split h | ||
71 | |||
72 | # split in vertical orientation | ||
73 | +v split v | ||
74 | |||
75 | # enter fullscreen mode for the focused container | ||
76 | +f fullscreen toggle | ||
77 | |||
78 | # change container layout (stacked, tabbed, toggle split) | ||
79 | +s layout stacking | ||
80 | +g layout tabbed | ||
81 | +e layout toggle split | ||
82 | |||
83 | # toggle tiling / floating | ||
84 | +Shift+space floating toggle | ||
85 | |||
86 | # change focus between tiling / floating windows | ||
87 | +space focus mode_toggle | ||
88 | |||
89 | # focus the parent container | ||
90 | +a focus parent | ||
91 | |||
92 | # focus the child container | ||
93 | #+d focus child | ||
94 | |||
95 | # resize floating window | ||
96 | +right mouse button | ||
97 | |||
98 | ## Multimedia Keys | ||
99 | |||
100 | # Redirect sound to headphones | ||
101 | +p | ||
102 | |||
103 | ## App shortcuts | ||
104 | +w starts Firefox | ||
105 | +n starts Thunar | ||
106 | Button screenshot | ||
diff --git a/dot_config/i3/scripts/executable_bandwidth2 b/dot_config/i3/scripts/executable_bandwidth2 new file mode 100644 index 0000000..ebd398a --- /dev/null +++ b/dot_config/i3/scripts/executable_bandwidth2 | |||
@@ -0,0 +1,105 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | # | ||
3 | # Copyright (C) 2015 James Murphy | ||
4 | # Licensed under the terms of the GNU GPL v2 only. | ||
5 | # | ||
6 | # i3blocks blocklet script to monitor bandwidth usage | ||
7 | |||
8 | iface="${BLOCK_INSTANCE}" | ||
9 | iface="${IFACE:-$iface}" | ||
10 | dt="${DT:-3}" | ||
11 | unit="${UNIT:-KB}" | ||
12 | LABEL="${LABEL:-: }" # down arrow up arrow | ||
13 | #LABEL="${LABEL:-<span font='FontAwesome'> </span>}" # down arrow up arrow | ||
14 | printf_command="${PRINTF_COMMAND:-"printf \"${LABEL}%1.0f/%1.0f %s/s\\n\", rx, wx, unit;"}" | ||
15 | |||
16 | function default_interface { | ||
17 | ip route | awk '/^default via/ {print $5; exit}' | ||
18 | } | ||
19 | |||
20 | function check_proc_net_dev { | ||
21 | if [ ! -f "/proc/net/dev" ]; then | ||
22 | echo "/proc/net/dev not found" | ||
23 | exit 1 | ||
24 | fi | ||
25 | } | ||
26 | |||
27 | function list_interfaces { | ||
28 | check_proc_net_dev | ||
29 | echo "Interfaces in /proc/net/dev:" | ||
30 | grep -o "^[^:]\\+:" /proc/net/dev | tr -d " :" | ||
31 | } | ||
32 | |||
33 | while getopts i:t:u:p:lh opt; do | ||
34 | case "$opt" in | ||
35 | i) iface="$OPTARG" ;; | ||
36 | t) dt="$OPTARG" ;; | ||
37 | u) unit="$OPTARG" ;; | ||
38 | p) printf_command="$OPTARG" ;; | ||
39 | l) list_interfaces && exit 0 ;; | ||
40 | h) printf \ | ||
41 | "Usage: bandwidth3 [-i interface] [-t time] [-u unit] [-p printf_command] [-l] [-h] | ||
42 | Options: | ||
43 | -i\tNetwork interface to measure. Default determined using \`ip route\`. | ||
44 | -t\tTime interval in seconds between measurements. Default: 3 | ||
45 | -u\tUnits to measure bytes in. Default: Mb | ||
46 | \tAllowed units: Kb, KB, Mb, MB, Gb, GB, Tb, TB | ||
47 | \tUnits may have optional it/its/yte/ytes on the end, e.g. Mbits, KByte | ||
48 | -p\tAwk command to be called after a measurement is made. | ||
49 | \tDefault: printf \"<span font='FontAwesome'> </span>%%-5.1f/%%5.1f %%s/s\\\\n\", rx, wx, unit; | ||
50 | \tExposed variables: rx, wx, tx, unit, iface | ||
51 | -l\tList available interfaces in /proc/net/dev | ||
52 | -h\tShow this help text | ||
53 | " && exit 0;; | ||
54 | esac | ||
55 | done | ||
56 | |||
57 | check_proc_net_dev | ||
58 | |||
59 | iface="${iface:-$(default_interface)}" | ||
60 | while [ -z "$iface" ]; do | ||
61 | echo No default interface | ||
62 | sleep "$dt" | ||
63 | iface=$(default_interface) | ||
64 | done | ||
65 | |||
66 | case "$unit" in | ||
67 | Kb|Kbit|Kbits) bytes_per_unit=$((1024 / 8));; | ||
68 | KB|KByte|KBytes) bytes_per_unit=$((1024));; | ||
69 | Mb|Mbit|Mbits) bytes_per_unit=$((1024 * 1024 / 8));; | ||
70 | MB|MByte|MBytes) bytes_per_unit=$((1024 * 1024));; | ||
71 | Gb|Gbit|Gbits) bytes_per_unit=$((1024 * 1024 * 1024 / 8));; | ||
72 | GB|GByte|GBytes) bytes_per_unit=$((1024 * 1024 * 1024));; | ||
73 | Tb|Tbit|Tbits) bytes_per_unit=$((1024 * 1024 * 1024 * 1024 / 8));; | ||
74 | TB|TByte|TBytes) bytes_per_unit=$((1024 * 1024 * 1024 * 1024));; | ||
75 | *) echo Bad unit "$unit" && exit 1;; | ||
76 | esac | ||
77 | |||
78 | scalar=$((bytes_per_unit * dt)) | ||
79 | init_line=$(cat /proc/net/dev | grep "^[ ]*$iface:") | ||
80 | if [ -z "$init_line" ]; then | ||
81 | echo Interface not found in /proc/net/dev: "$iface" | ||
82 | exit 1 | ||
83 | fi | ||
84 | |||
85 | init_received=$(awk '{print $2}' <<< $init_line) | ||
86 | init_sent=$(awk '{print $10}' <<< $init_line) | ||
87 | |||
88 | (while true; do cat /proc/net/dev; sleep "$dt"; done) |\ | ||
89 | stdbuf -oL grep "^[ ]*$iface:" |\ | ||
90 | awk -v scalar="$scalar" -v unit="$unit" -v iface="$iface" ' | ||
91 | BEGIN{old_received='"$init_received"';old_sent='"$init_sent"'} | ||
92 | { | ||
93 | received=$2 | ||
94 | sent=$10 | ||
95 | rx=(received-old_received)/scalar; | ||
96 | wx=(sent-old_sent)/scalar; | ||
97 | tx=rx+wr; | ||
98 | old_received=received; | ||
99 | old_sent=sent; | ||
100 | if(rx >= 0 && wx >= 0){ | ||
101 | '"$printf_command"'; | ||
102 | fflush(stdout); | ||
103 | } | ||
104 | } | ||
105 | ' | ||
diff --git a/dot_config/i3/scripts/executable_battery-pinebook-pro b/dot_config/i3/scripts/executable_battery-pinebook-pro new file mode 100644 index 0000000..fd97370 --- /dev/null +++ b/dot_config/i3/scripts/executable_battery-pinebook-pro | |||
@@ -0,0 +1,18 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | #simple Shellscript for i3blocks on Pinebook pro | ||
3 | #05012020 [email protected] Gerhard S. | ||
4 | #battery-symbols: on Manjaro you need the awesome-terminal-fonts package installed! | ||
5 | PERCENT=$(cat /sys/class/power_supply/cw2015-battery/capacity) | ||
6 | STATUS=$(cat /sys/class/power_supply/cw2015-battery/status) | ||
7 | case $(( | ||
8 | $PERCENT >= 0 && $PERCENT <= 20 ? 1 : | ||
9 | $PERCENT > 20 && $PERCENT <= 40 ? 2 : | ||
10 | $PERCENT > 40 && $PERCENT <= 60 ? 3 : | ||
11 | $PERCENT > 60 && $PERCENT <= 80 ? 4 : 5)) in | ||
12 | # | ||
13 | (1) echo $STATUS:"" :$PERCENT%;; | ||
14 | (2) echo $STATUS:"" :$PERCENT%;; | ||
15 | (3) echo $STATUS:"" :$PERCENT%;; | ||
16 | (4) echo $STATUS:"" :$PERCENT%;; | ||
17 | (5) echo $STATUS:"" :$PERCENT%;; | ||
18 | esac | ||
diff --git a/dot_config/i3/scripts/executable_battery1 b/dot_config/i3/scripts/executable_battery1 new file mode 100644 index 0000000..3b9d5a7 --- /dev/null +++ b/dot_config/i3/scripts/executable_battery1 | |||
@@ -0,0 +1,114 @@ | |||
1 | #!/usr/bin/perl | ||
2 | # | ||
3 | # Copyright 2014 Pierre Mavro <[email protected]> | ||
4 | # Copyright 2014 Vivien Didelot <[email protected]> | ||
5 | # | ||
6 | # Licensed under the terms of the GNU GPL v3, or any later version. | ||
7 | # | ||
8 | # This script is meant to use with i3blocks. It parses the output of the "acpi" | ||
9 | # command (often provided by a package of the same name) to read the status of | ||
10 | # the battery, and eventually its remaining time (to full charge or discharge). | ||
11 | # | ||
12 | # The color will gradually change for a percentage below 85%, and the urgency | ||
13 | # (exit code 33) is set if there is less that 5% remaining. | ||
14 | |||
15 | # Edited by Andreas Lindlbauer <[email protected]> | ||
16 | |||
17 | use strict; | ||
18 | use warnings; | ||
19 | use utf8; | ||
20 | |||
21 | # otherwise we get in console "Wide character in print at" | ||
22 | binmode(STDOUT, ':utf8'); | ||
23 | |||
24 | # my $acpi; | ||
25 | my $upower; | ||
26 | my $percent; | ||
27 | my $bat_state; | ||
28 | my $status; | ||
29 | my $ac_adapt; | ||
30 | my $full_text; | ||
31 | my $short_text; | ||
32 | my $label = '😅'; | ||
33 | my $bat_number = $ENV{BLOCK_INSTANCE} || 0; | ||
34 | |||
35 | open (UPOWER, "upower -i /org/freedesktop/UPower/devices/battery_BAT$bat_number | grep 'percentage' |") or die; | ||
36 | $upower = <UPOWER>; | ||
37 | close(UPOWER); | ||
38 | |||
39 | # fail on unexpected output | ||
40 | if ($upower !~ /: (\d+)%/) { | ||
41 | die "$upower\n"; | ||
42 | } | ||
43 | |||
44 | $percent = $1; | ||
45 | $full_text = "$percent%"; | ||
46 | |||
47 | open (BAT_STATE, "upower -i /org/freedesktop/UPower/devices/battery_BAT$bat_number | grep 'state' |") or die; | ||
48 | $bat_state = <BAT_STATE>; | ||
49 | close(BAT_STATE); | ||
50 | |||
51 | if ($bat_state !~ /: (\w+)/) { | ||
52 | die "$bat_state\n"; | ||
53 | } | ||
54 | $status = $1; | ||
55 | |||
56 | if ($status eq 'discharging') { | ||
57 | $full_text .= ' '; | ||
58 | } elsif ($status eq 'charging') { | ||
59 | $full_text .= ' '; | ||
60 | } elsif ($status eq 'Unknown') { | ||
61 | open (AC_ADAPTER, "acpi -a |") or die; | ||
62 | $ac_adapt = <AC_ADAPTER>; | ||
63 | close(AC_ADAPTER); | ||
64 | |||
65 | if ($ac_adapt =~ /: ([\w-]+)/) { | ||
66 | $ac_adapt = $1; | ||
67 | |||
68 | if ($ac_adapt eq 'on-line') { | ||
69 | $full_text .= ' CHR'; | ||
70 | } elsif ($ac_adapt eq 'off-line') { | ||
71 | $full_text .= ' DIS'; | ||
72 | } | ||
73 | } | ||
74 | } | ||
75 | |||
76 | $short_text = $full_text; | ||
77 | |||
78 | if ($percent < 20) { | ||
79 | $label = ''; | ||
80 | } elsif ($percent < 45) { | ||
81 | $label = ''; | ||
82 | } elsif ($percent < 70) { | ||
83 | $label = ''; | ||
84 | } elsif ($percent < 95) { | ||
85 | $label = ''; | ||
86 | } else { | ||
87 | $label = ''; | ||
88 | } | ||
89 | |||
90 | # print text | ||
91 | print " ${label}"; | ||
92 | print " $full_text\n"; | ||
93 | print " ${label}"; | ||
94 | print " $short_text\n"; | ||
95 | |||
96 | # consider color and urgent flag only on discharge | ||
97 | if ($status eq 'discharging') { | ||
98 | |||
99 | if ($percent < 20) { | ||
100 | print "#FF0000\n"; | ||
101 | } elsif ($percent < 40) { | ||
102 | print "#FFAE00\n"; | ||
103 | } elsif ($percent < 60) { | ||
104 | print "#FFF600\n"; | ||
105 | } elsif ($percent < 85) { | ||
106 | print "#A8FF00\n"; | ||
107 | } | ||
108 | |||
109 | if ($percent < 5) { | ||
110 | exit(33); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | exit(0); | ||
diff --git a/dot_config/i3/scripts/executable_battery2 b/dot_config/i3/scripts/executable_battery2 new file mode 100644 index 0000000..2d55dab --- /dev/null +++ b/dot_config/i3/scripts/executable_battery2 | |||
@@ -0,0 +1,106 @@ | |||
1 | #!/usr/bin/env python3 | ||
2 | # | ||
3 | # Copyright (C) 2016 James Murphy | ||
4 | # Licensed under the GPL version 2 only | ||
5 | # | ||
6 | # A battery indicator blocklet script for i3blocks | ||
7 | |||
8 | from subprocess import check_output | ||
9 | import os | ||
10 | import re | ||
11 | |||
12 | config = dict(os.environ) | ||
13 | status = check_output(['acpi'], universal_newlines=True) | ||
14 | |||
15 | if not status: | ||
16 | # stands for no battery found | ||
17 | color = config.get("color_10", "red") | ||
18 | fulltext = "<span color='{}'><span font='FontAwesome'>\uf00d \uf240</span></span>".format(color) | ||
19 | percentleft = 100 | ||
20 | else: | ||
21 | # if there is more than one battery in one laptop, the percentage left is | ||
22 | # available for each battery separately, although state and remaining | ||
23 | # time for overall block is shown in the status of the first battery | ||
24 | batteries = status.split("\n") | ||
25 | state_batteries=[] | ||
26 | commasplitstatus_batteries=[] | ||
27 | percentleft_batteries=[] | ||
28 | time = "" | ||
29 | for battery in batteries: | ||
30 | if battery!='': | ||
31 | state_batteries.append(battery.split(": ")[1].split(", ")[0]) | ||
32 | commasplitstatus = battery.split(", ") | ||
33 | if not time: | ||
34 | time = commasplitstatus[-1].strip() | ||
35 | # check if it matches a time | ||
36 | time = re.match(r"(\d+):(\d+)", time) | ||
37 | if time: | ||
38 | time = ":".join(time.groups()) | ||
39 | timeleft = " ({})".format(time) | ||
40 | else: | ||
41 | timeleft = "" | ||
42 | |||
43 | p = int(commasplitstatus[1].rstrip("%\n")) | ||
44 | if p>0: | ||
45 | percentleft_batteries.append(p) | ||
46 | commasplitstatus_batteries.append(commasplitstatus) | ||
47 | state = state_batteries[0] | ||
48 | commasplitstatus = commasplitstatus_batteries[0] | ||
49 | if percentleft_batteries: | ||
50 | percentleft = int(sum(percentleft_batteries)/len(percentleft_batteries)) | ||
51 | else: | ||
52 | percentleft = 0 | ||
53 | |||
54 | # stands for charging | ||
55 | color = config.get("color_charging", "yellow") | ||
56 | FA_LIGHTNING = "<span color='{}'><span font='FontAwesome'>\uf0e7</span></span>".format(color) | ||
57 | |||
58 | # stands for plugged in | ||
59 | FA_PLUG = "<span font='FontAwesome'>\uf1e6</span>" | ||
60 | |||
61 | # stands for using battery | ||
62 | FA_BATTERY = "<span font='FontAwesome'>\uf240</span>" | ||
63 | |||
64 | # stands for unknown status of battery | ||
65 | FA_QUESTION = "<span font='FontAwesome'>\uf128</span>" | ||
66 | |||
67 | |||
68 | if state == "Discharging": | ||
69 | fulltext = FA_BATTERY + " " | ||
70 | elif state == "Full": | ||
71 | fulltext = FA_PLUG + " " | ||
72 | timeleft = "" | ||
73 | elif state == "Unknown": | ||
74 | fulltext = FA_QUESTION + " " + FA_BATTERY + " " | ||
75 | timeleft = "" | ||
76 | else: | ||
77 | fulltext = FA_LIGHTNING + " " + FA_PLUG + " " | ||
78 | |||
79 | def color(percent): | ||
80 | if percent < 10: | ||
81 | # exit code 33 will turn background red | ||
82 | return config.get("color_10", "#FFFFFF") | ||
83 | if percent < 20: | ||
84 | return config.get("color_20", "#FF3300") | ||
85 | if percent < 30: | ||
86 | return config.get("color_30", "#FF6600") | ||
87 | if percent < 40: | ||
88 | return config.get("color_40", "#FF9900") | ||
89 | if percent < 50: | ||
90 | return config.get("color_50", "#FFCC00") | ||
91 | if percent < 60: | ||
92 | return config.get("color_60", "#FFFF00") | ||
93 | if percent < 70: | ||
94 | return config.get("color_70", "#FFFF33") | ||
95 | if percent < 80: | ||
96 | return config.get("color_80", "#FFFF66") | ||
97 | return config.get("color_full", "#FFFFFF") | ||
98 | |||
99 | form = '<span color="{}">{}%</span>' | ||
100 | fulltext += form.format(color(percentleft), percentleft) | ||
101 | #fulltext += timeleft | ||
102 | |||
103 | print(fulltext) | ||
104 | print(fulltext) | ||
105 | if percentleft < 10: | ||
106 | exit(33) | ||
diff --git a/dot_config/i3/scripts/executable_blur-lock b/dot_config/i3/scripts/executable_blur-lock new file mode 100644 index 0000000..4ff7ed6 --- /dev/null +++ b/dot_config/i3/scripts/executable_blur-lock | |||
@@ -0,0 +1,11 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | PICTURE=/tmp/i3lock.png | ||
4 | SCREENSHOT="scrot -z $PICTURE" | ||
5 | |||
6 | BLUR="5x4" | ||
7 | |||
8 | $SCREENSHOT | ||
9 | convert $PICTURE -blur $BLUR $PICTURE | ||
10 | i3lock -i $PICTURE | ||
11 | rm $PICTURE | ||
diff --git a/dot_config/i3/scripts/executable_cpu_usage b/dot_config/i3/scripts/executable_cpu_usage new file mode 100644 index 0000000..8d8a267 --- /dev/null +++ b/dot_config/i3/scripts/executable_cpu_usage | |||
@@ -0,0 +1,62 @@ | |||
1 | #!/usr/bin/perl | ||
2 | # | ||
3 | # Copyright 2014 Pierre Mavro <[email protected]> | ||
4 | # Copyright 2014 Vivien Didelot <[email protected]> | ||
5 | # Copyright 2014 Andreas Guldstrand <[email protected]> | ||
6 | # | ||
7 | # Licensed under the terms of the GNU GPL v3, or any later version. | ||
8 | |||
9 | use strict; | ||
10 | use warnings; | ||
11 | use utf8; | ||
12 | use Getopt::Long; | ||
13 | |||
14 | # default values | ||
15 | my $t_warn = $ENV{T_WARN} // 50; | ||
16 | my $t_crit = $ENV{T_CRIT} // 80; | ||
17 | my $cpu_usage = -1; | ||
18 | my $decimals = $ENV{DECIMALS} // 0; | ||
19 | my $label = $ENV{LABEL} // ""; | ||
20 | |||
21 | sub help { | ||
22 | print "Usage: cpu_usage [-w <warning>] [-c <critical>] [-d <decimals>]\n"; | ||
23 | print "-w <percent>: warning threshold to become yellow\n"; | ||
24 | print "-c <percent>: critical threshold to become red\n"; | ||
25 | print "-d <decimals>: Use <decimals> decimals for percentage (default is $decimals) \n"; | ||
26 | exit 0; | ||
27 | } | ||
28 | |||
29 | GetOptions("help|h" => \&help, | ||
30 | "w=i" => \$t_warn, | ||
31 | "c=i" => \$t_crit, | ||
32 | "d=i" => \$decimals, | ||
33 | ); | ||
34 | |||
35 | # Get CPU usage | ||
36 | $ENV{LC_ALL}="en_US"; # if mpstat is not run under en_US locale, things may break, so make sure it is | ||
37 | open (MPSTAT, 'mpstat 1 1 |') or die; | ||
38 | while (<MPSTAT>) { | ||
39 | if (/^.*\s+(\d+\.\d+)[\s\x00]?$/) { | ||
40 | $cpu_usage = 100 - $1; # 100% - %idle | ||
41 | last; | ||
42 | } | ||
43 | } | ||
44 | close(MPSTAT); | ||
45 | |||
46 | $cpu_usage eq -1 and die 'Can\'t find CPU information'; | ||
47 | |||
48 | # Print short_text, full_text | ||
49 | print "${label}"; | ||
50 | printf "%02.${decimals}f%%\n", $cpu_usage; | ||
51 | print "${label}"; | ||
52 | printf "%02.${decimals}f%%\n", $cpu_usage; | ||
53 | |||
54 | # Print color, if needed | ||
55 | if ($cpu_usage >= $t_crit) { | ||
56 | print "#FF0000\n"; | ||
57 | exit 33; | ||
58 | } elsif ($cpu_usage >= $t_warn) { | ||
59 | print "#FFFC00\n"; | ||
60 | } | ||
61 | |||
62 | exit 0; | ||
diff --git a/dot_config/i3/scripts/executable_disk b/dot_config/i3/scripts/executable_disk new file mode 100644 index 0000000..e18c7aa --- /dev/null +++ b/dot_config/i3/scripts/executable_disk | |||
@@ -0,0 +1,48 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | # Copyright (C) 2014 Julien Bonjean <[email protected]> | ||
3 | |||
4 | # This program is free software: you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation, either version 3 of the License, or | ||
7 | # (at your option) any later version. | ||
8 | |||
9 | # This program is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | |||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | DIR="${DIR:-$BLOCK_INSTANCE}" | ||
18 | DIR="${DIR:-$HOME}" | ||
19 | ALERT_LOW="${ALERT_LOW:-$1}" | ||
20 | ALERT_LOW="${ALERT_LOW:-10}" # color will turn red under this value (default: 10%) | ||
21 | |||
22 | LOCAL_FLAG="-l" | ||
23 | if [ "$1" = "-n" ] || [ "$2" = "-n" ]; then | ||
24 | LOCAL_FLAG="" | ||
25 | fi | ||
26 | |||
27 | df -h -P $LOCAL_FLAG "$DIR" | awk -v label="$LABEL" -v alert_low=$ALERT_LOW ' | ||
28 | /\/.*/ { | ||
29 | # full text | ||
30 | print label $4 | ||
31 | |||
32 | # short text | ||
33 | print label $4 | ||
34 | |||
35 | use=$5 | ||
36 | |||
37 | # no need to continue parsing | ||
38 | exit 0 | ||
39 | } | ||
40 | |||
41 | END { | ||
42 | gsub(/%$/,"",use) | ||
43 | if (100 - use < alert_low) { | ||
44 | # color | ||
45 | print "#FF0000" | ||
46 | } | ||
47 | } | ||
48 | ' | ||
diff --git a/dot_config/i3/scripts/executable_keyboard-layout b/dot_config/i3/scripts/executable_keyboard-layout new file mode 100644 index 0000000..9a3e314 --- /dev/null +++ b/dot_config/i3/scripts/executable_keyboard-layout | |||
@@ -0,0 +1,5 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | KBD=$(/usr/bin/xkblayout-state print '%s') | ||
4 | echo $KBD | ||
5 | |||
diff --git a/dot_config/i3/scripts/executable_keyhint b/dot_config/i3/scripts/executable_keyhint new file mode 100644 index 0000000..8b8c3e3 --- /dev/null +++ b/dot_config/i3/scripts/executable_keyhint | |||
@@ -0,0 +1,25 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | Main() { | ||
4 | source /usr/share/endeavouros/scripts/eos-script-lib-yad || return 1 | ||
5 | |||
6 | local command=( | ||
7 | eos_yad --title="EndeavourOS i3-wm keybindings:" --no-buttons --geometry=400x345-15-400 --list | ||
8 | --column=key: --column=description: --column=command: | ||
9 | "ESC" "close this app" "" | ||
10 | "=" "modkey" "(set mod Mod4)" | ||
11 | "+enter" "open a terminal" "" | ||
12 | "+Shift+n" "new empty workspace" "" | ||
13 | "+w" "open Browser" "" | ||
14 | "+n" "open Filebrowser" "" | ||
15 | "+d" "app menu" "" | ||
16 | "+q" "close focused app" "" | ||
17 | "Print-key" "screenshot" "" | ||
18 | "+Shift+e" "logout menu" "" | ||
19 | "F1" "open keybinding helper" "" | ||
20 | ) | ||
21 | |||
22 | "${command[@]}" | ||
23 | } | ||
24 | |||
25 | Main "$@" | ||
diff --git a/dot_config/i3/scripts/executable_keyhint-2 b/dot_config/i3/scripts/executable_keyhint-2 new file mode 100644 index 0000000..2e86d12 --- /dev/null +++ b/dot_config/i3/scripts/executable_keyhint-2 | |||
@@ -0,0 +1,6 @@ | |||
1 | I3_CONFIG=$HOME/.config/i3/config | ||
2 | mod_key=$(sed -nre 's/^set \$mod (.*)/\1/p' ${I3_CONFIG}) | ||
3 | grep "^bindsym" ${I3_CONFIG} \ | ||
4 | | sed "s/-\(-\w\+\)\+//g;s/\$mod/${mod_key}/g;s/Mod1/Alt/g;s/exec //;s/bindsym //;s/^\s\+//;s/^\([^ ]\+\) \(.\+\)$/\2: \1/;s/^\s\+//" \ | ||
5 | | tr -s ' ' \ | ||
6 | | rofi -dmenu -theme ~/.config/rofi/rofikeyhint.rasi | ||
diff --git a/dot_config/i3/scripts/executable_literal_empty_workspace b/dot_config/i3/scripts/executable_literal_empty_workspace new file mode 100644 index 0000000..b962cde --- /dev/null +++ b/dot_config/i3/scripts/executable_literal_empty_workspace | |||
@@ -0,0 +1,10 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | MAX_DESKTOPS=20 | ||
4 | |||
5 | WORKSPACES=$(seq -s '\n' 1 1 ${MAX_DESKTOPS}) | ||
6 | |||
7 | EMPTY_WORKSPACE=$( (i3-msg -t get_workspaces | tr ',' '\n' | grep num | awk -F: '{print int($2)}' ; \ | ||
8 | echo -e ${WORKSPACES} ) | sort -n | uniq -u | head -n 1) | ||
9 | |||
10 | i3-msg workspace ${EMPTY_WORKSPACE} | ||
diff --git a/dot_config/i3/scripts/executable_memory b/dot_config/i3/scripts/executable_memory new file mode 100644 index 0000000..6a69a6f --- /dev/null +++ b/dot_config/i3/scripts/executable_memory | |||
@@ -0,0 +1,69 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | # Copyright (C) 2014 Julien Bonjean <[email protected]> | ||
3 | |||
4 | # This program is free software: you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation, either version 3 of the License, or | ||
7 | # (at your option) any later version. | ||
8 | |||
9 | # This program is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | |||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | TYPE="${BLOCK_INSTANCE:-mem}" | ||
18 | |||
19 | awk -v type=$TYPE ' | ||
20 | /^MemTotal:/ { | ||
21 | mem_total=$2 | ||
22 | } | ||
23 | /^MemFree:/ { | ||
24 | mem_free=$2 | ||
25 | } | ||
26 | /^Buffers:/ { | ||
27 | mem_free+=$2 | ||
28 | } | ||
29 | /^Cached:/ { | ||
30 | mem_free+=$2 | ||
31 | } | ||
32 | /^SwapTotal:/ { | ||
33 | swap_total=$2 | ||
34 | } | ||
35 | /^SwapFree:/ { | ||
36 | swap_free=$2 | ||
37 | } | ||
38 | END { | ||
39 | if (type == "swap") { | ||
40 | free=swap_free/1024/1024 | ||
41 | used=(swap_total-swap_free)/1024/1024 | ||
42 | total=swap_total/1024/1024 | ||
43 | } else { | ||
44 | free=mem_free/1024/1024 | ||
45 | used=(mem_total-mem_free)/1024/1024 | ||
46 | total=mem_total/1024/1024 | ||
47 | } | ||
48 | |||
49 | pct=0 | ||
50 | if (total > 0) { | ||
51 | pct=used/total*100 | ||
52 | } | ||
53 | |||
54 | # full text | ||
55 | # printf("%.1fG/%.1fG (%.f%%)\n", used, total, pct) | ||
56 | |||
57 | # short text | ||
58 | printf("%.f%%\n", pct) | ||
59 | |||
60 | # color | ||
61 | if (pct > 90) { | ||
62 | print("#FF0000") | ||
63 | } else if (pct > 80) { | ||
64 | print("#FFAE00") | ||
65 | } else if (pct > 70) { | ||
66 | print("#FFF600") | ||
67 | } | ||
68 | } | ||
69 | ' /proc/meminfo | ||
diff --git a/dot_config/i3/scripts/executable_openweather b/dot_config/i3/scripts/executable_openweather new file mode 100644 index 0000000..c51f9d3 --- /dev/null +++ b/dot_config/i3/scripts/executable_openweather | |||
@@ -0,0 +1,93 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | # Edited by Andreas Lindlbauer <[email protected]> | ||
3 | |||
4 | temps=("#0600FF" "#0500FF" "#0400FF" "#0300FF" "#0200FF" "#0100FF" "#0000FF" "#0002FF" "#0012FF" "#0022FF" "#0032FF" "#0044FF" "#0054FF" "#0064FF" "#0074FF" "#0084FF" "#0094FF" "#00A4FF" "#00B4FF" "#00C4FF" "#00D4FF" "#00E4FF" "#00FFF4" "#00FFD0" "#00FFA8" "#00FF83" "#00FF5C" "#00FF36" "#00FF10" "#17FF00" "#3EFF00" "#65FF00" "#B0FF00" "#FDFF00" "#FFF000" "#FFDC00" "#FFC800" "#FFB400" "#FFA000" "#FF8C00" "#FF7800" "#FF6400" "#FF5000" "#FF3C00" "#FF2800" "#FF1400" "#FF0000") | ||
5 | |||
6 | command -v jq >/dev/null 2>&1 || { echo >&2 "Program 'jq' required but it is not installed. | ||
7 | Aborting."; exit 1; } | ||
8 | command -v wget >/dev/null 2>&1 || { echo >&2 "Program 'wget' required but is not installed. | ||
9 | Aborting."; exit 1; } | ||
10 | |||
11 | # To use this script you need to create an API key here https://home.openweathermap.org | ||
12 | # You need to put your Open Weather APIKEY here: | ||
13 | APIKEY="keykeykey" | ||
14 | # And get your Latitute and Longitudes to put in here: | ||
15 | LAT="XX.XXXX" | ||
16 | LON="XX.XXXX" | ||
17 | URL="http://api.openweathermap.org/data/2.5/onecall?lat=${LAT}&lon=${LON}&units=metric&exclude=minutely,hourly,daily&APPID=${APIKEY}" | ||
18 | WEATHER_RESPONSE=$(wget -qO- "${URL}") | ||
19 | |||
20 | WEATHER_CONDITION=$(echo "$WEATHER_RESPONSE" | jq '.current.weather[0].main' | sed 's/"//g') | ||
21 | WEATHER_TEMP=$(echo "$WEATHER_RESPONSE" | jq '.current.feels_like') | ||
22 | WEATHER_INT=${WEATHER_TEMP%.*} | ||
23 | |||
24 | TIME_NOW=$( echo "$WEATHER_RESPONSE" | jq '.current.dt') | ||
25 | SUNRISE=$( echo "$WEATHER_RESPONSE" | jq '.current.sunrise') | ||
26 | SUNSET=$( echo "$WEATHER_RESPONSE" | jq '.current.sunset') | ||
27 | DESCRIPTION=$( echo "$WEATHER_RESPONSE" | jq '.current.weather[0].description' | sed 's/"//g') | ||
28 | WEATHER_ALERT=$( echo "$WEATHER_RESPONSE" | jq '.alerts[0].event' | sed 's/"//g') | ||
29 | DAYTIME="n" | ||
30 | |||
31 | if [[ "$TIME_NOW" > "$SUNRISE" ]] && [[ "$TIME_NOW" < "$SUNSET" ]]; then | ||
32 | DAYTIME="d" | ||
33 | fi | ||
34 | |||
35 | case $WEATHER_CONDITION in | ||
36 | 'Clouds') | ||
37 | if [ "$DAYTIME" == "d" ]; then | ||
38 | WEATHER_ICON="" | ||
39 | else | ||
40 | WEATHER_ICON="" | ||
41 | fi | ||
42 | ;; | ||
43 | 'Rain') | ||
44 | WEATHER_ICON="" | ||
45 | ;; | ||
46 | 'Drizzle') | ||
47 | if [ "$DAYTIME" == "d" ]; then | ||
48 | WEATHER_ICON="" | ||
49 | else | ||
50 | WEATHER_ICON="" | ||
51 | fi | ||
52 | ;; | ||
53 | 'Thunderstorm') | ||
54 | WEATHER_ICON="" | ||
55 | ;; | ||
56 | 'Snow') | ||
57 | WEATHER_ICON="" | ||
58 | ;; | ||
59 | 'Clear') | ||
60 | if [ "$DAYTIME" == "d" ]; then | ||
61 | WEATHER_ICON="" | ||
62 | else | ||
63 | WEATHER_ICON="" | ||
64 | fi | ||
65 | ;; | ||
66 | *) | ||
67 | WEATHER_ICON="🌫" | ||
68 | ;; | ||
69 | esac | ||
70 | |||
71 | WEATHER_COLOR="#FFFFFF" | ||
72 | if [ "$WEATHER_INT" -lt "-11" ]; then | ||
73 | WEATHER_COLOR="#0000FF" | ||
74 | elif [ "$WEATHER_INT" -gt 35 ]; then | ||
75 | WEATHER_COLOR="#FF0000" | ||
76 | else | ||
77 | WEATHER_INT=$(( WEATHER_INT + 11 )) | ||
78 | WEATHER_COLOR="${temps[$WEATHER_INT]}" | ||
79 | fi | ||
80 | |||
81 | full_text="${WEATHER_ICON} ${WEATHER_TEMP}°C: ${DESCRIPTION} " | ||
82 | if [ "$WEATHER_ALERT" != "null" ]; then | ||
83 | WARN_START=$(echo "$WEATHER_RESPONSE" | jq '.alerts[0].start') | ||
84 | WARN_END=$(echo "$WEATHER_RESPONSE" | jq '.alerts[0].end') | ||
85 | WARN_START=$(date -d @"$WARN_START" +%a_%k:%M) | ||
86 | WARN_END=$(date -d @"$WARN_END" +%a_%k:%M) | ||
87 | full_text="${WEATHER_ICON} ${WEATHER_TEMP}°C: ${DESCRIPTION} ${WEATHER_ALERT} from ${WARN_START} to ${WARN_END} " | ||
88 | fi | ||
89 | |||
90 | |||
91 | echo "${full_text}" | ||
92 | echo "${WEATHER_TEMP}°C " | ||
93 | echo "${WEATHER_COLOR}" | ||
diff --git a/dot_config/i3/scripts/executable_openweather-city b/dot_config/i3/scripts/executable_openweather-city new file mode 100644 index 0000000..6ea051c --- /dev/null +++ b/dot_config/i3/scripts/executable_openweather-city | |||
@@ -0,0 +1,43 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | command -v jq >/dev/null 2>&1 || { echo >&2 "Program 'jq' required but it is not installed. | ||
4 | Aborting."; exit 1; } | ||
5 | command -v wget >/dev/null 2>&1 || { echo >&2 "Program 'wget' required but is not installed. | ||
6 | Aborting."; exit 1; } | ||
7 | |||
8 | # To use this script you need to create an API key here https://home.openweathermap.org | ||
9 | # You need to put your Open Weather APIKEY here: | ||
10 | APIKEY="keykey" | ||
11 | # find your City ID here: https://openweathermap.org/ | ||
12 | # search for your city and copy the ID from the URL inside the browser. | ||
13 | CITY_ID="idid" | ||
14 | URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&units=metric&APPID=${APIKEY}" | ||
15 | |||
16 | WEATHER_RESPONSE=$(wget -qO- "${URL}") | ||
17 | |||
18 | WEATHER_CONDITION=$(echo $WEATHER_RESPONSE | jq '.weather[0].main' | sed 's/"//g') | ||
19 | WEATHER_TEMP=$(echo $WEATHER_RESPONSE | jq '.main.temp') | ||
20 | WIND_DIR=$( echo "$WEATHER_RESPONSE" | jq '.wind.deg') | ||
21 | WIND_SPEED=$( echo "$WEATHER_RESPONSE" | jq '.wind.speed') | ||
22 | |||
23 | WIND_SPEED=$(awk "BEGIN {print 60*60*$WIND_SPEED/1000}") | ||
24 | WIND_DIR=$(awk "BEGIN {print int(($WIND_DIR % 360)/22.5)}") | ||
25 | DIR_ARRAY=( N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW N ) | ||
26 | WIND_DIR=${DIR_ARRAY[WIND_DIR]} | ||
27 | |||
28 | case $WEATHER_CONDITION in | ||
29 | 'Clouds') | ||
30 | WEATHER_ICON="" | ||
31 | ;; | ||
32 | 'Rain') | ||
33 | WEATHER_ICON="" | ||
34 | ;; | ||
35 | 'Snow') | ||
36 | WEATHER_ICON="" | ||
37 | ;; | ||
38 | *) | ||
39 | WEATHER_ICON="" | ||
40 | ;; | ||
41 | esac | ||
42 | |||
43 | echo "${WEATHER_ICON} ${WEATHER_TEMP}°C: ${WIND_SPEED} km/h ${WIND_DIR}" | ||
diff --git a/dot_config/i3/scripts/executable_openweather.conf b/dot_config/i3/scripts/executable_openweather.conf new file mode 100644 index 0000000..f11aa86 --- /dev/null +++ b/dot_config/i3/scripts/executable_openweather.conf | |||
@@ -0,0 +1,5 @@ | |||
1 | # Weather | ||
2 | [Weather] | ||
3 | command=~/.config/i3/scripts/openweather | ||
4 | interval=1800 | ||
5 | color=#7275b3 | ||
diff --git a/dot_config/i3/scripts/executable_power-profiles b/dot_config/i3/scripts/executable_power-profiles new file mode 100644 index 0000000..feb63dc --- /dev/null +++ b/dot_config/i3/scripts/executable_power-profiles | |||
@@ -0,0 +1,190 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | # | ||
3 | # Use rofi/zenity to change system runstate thanks to systemd. | ||
4 | # | ||
5 | # Note: this currently relies on associative array support in the shell. | ||
6 | # | ||
7 | # Inspired from i3pystatus wiki: | ||
8 | # https://github.com/enkore/i3pystatus/wiki/Shutdown-Menu | ||
9 | # | ||
10 | # Copyright 2015 Benjamin Chrétien <chretien at lirmm dot fr> | ||
11 | # | ||
12 | # This program is free software: you can redistribute it and/or modify | ||
13 | # it under the terms of the GNU General Public License as published by | ||
14 | # the Free Software Foundation, either version 3 of the License, or | ||
15 | # (at your option) any later version. | ||
16 | |||
17 | # This program is distributed in the hope that it will be useful, | ||
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | # GNU General Public License for more details. | ||
21 | |||
22 | # You should have received a copy of the GNU General Public License | ||
23 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
24 | |||
25 | # power-profiles-daemon implementation: | ||
26 | # needs package power-profiles-daemon installed and the service running see here: | ||
27 | # https://wiki.archlinux.org/title/CPU_frequency_scaling#power-profiles-daemon | ||
28 | # used in i3-blocks: ~/.config/i3/i3blocks.conf together with: ~/.config/i3/scripts/ppd-status | ||
29 | |||
30 | |||
31 | ####################################################################### | ||
32 | # BEGIN CONFIG # | ||
33 | ####################################################################### | ||
34 | |||
35 | # Use a custom lock script | ||
36 | #LOCKSCRIPT="i3lock-extra -m pixelize" | ||
37 | |||
38 | # Colors: FG (foreground), BG (background), HL (highlighted) | ||
39 | FG_COLOR="#bbbbbb" | ||
40 | BG_COLOR="#111111" | ||
41 | HLFG_COLOR="#111111" | ||
42 | HLBG_COLOR="#bbbbbb" | ||
43 | BORDER_COLOR="#222222" | ||
44 | |||
45 | # Options not related to colors | ||
46 | #ROFI_TEXT=":" | ||
47 | #ROFI_OPTIONS=(-width -11 -location 0 -hide-scrollbar -bw 30 -color-window "#dd310027,#dd0310027,#dd310027" -padding 5) | ||
48 | #ROFI_OPTIONS=(-width -18 -location 4 -hide-scrollbar -color-window "#cc310027,#00a0009a,#cc310027" -padding 5 -font "Sourcecode Pro Regular 10, FontAwesome 9") | ||
49 | ROFI_OPTIONS=(-theme ~/.config/rofi/power-profiles.rasi) | ||
50 | # Zenity options | ||
51 | ZENITY_TITLE="Power Profiles" | ||
52 | ZENITY_TEXT="Set Profiles:" | ||
53 | ZENITY_OPTIONS=(--column= --hide-header) | ||
54 | |||
55 | ####################################################################### | ||
56 | # END CONFIG # | ||
57 | ####################################################################### | ||
58 | |||
59 | # Whether to ask for user's confirmation | ||
60 | enable_confirmation=false | ||
61 | |||
62 | # Preferred launcher if both are available | ||
63 | preferred_launcher="rofi" | ||
64 | |||
65 | usage="$(basename "$0") [-h] [-c] [-p name] -- display a menu for shutdown, reboot, lock etc. | ||
66 | |||
67 | where: | ||
68 | -h show this help text | ||
69 | -c ask for user confirmation | ||
70 | -p preferred launcher (rofi or zenity) | ||
71 | |||
72 | This script depends on: | ||
73 | - systemd, | ||
74 | - i3, | ||
75 | - rofi or zenity." | ||
76 | |||
77 | # Check whether the user-defined launcher is valid | ||
78 | launcher_list=(rofi zenity) | ||
79 | function check_launcher() { | ||
80 | if [[ ! "${launcher_list[@]}" =~ (^|[[:space:]])"$1"($|[[:space:]]) ]]; then | ||
81 | echo "Supported launchers: ${launcher_list[*]}" | ||
82 | exit 1 | ||
83 | else | ||
84 | # Get array with unique elements and preferred launcher first | ||
85 | # Note: uniq expects a sorted list, so we cannot use it | ||
86 | i=1 | ||
87 | launcher_list=($(for l in "$1" "${launcher_list[@]}"; do printf "%i %s\n" "$i" "$l"; let i+=1; done \ | ||
88 | | sort -uk2 | sort -nk1 | cut -d' ' -f2- | tr '\n' ' ')) | ||
89 | fi | ||
90 | } | ||
91 | |||
92 | # Parse CLI arguments | ||
93 | while getopts "hcp:" option; do | ||
94 | case "${option}" in | ||
95 | h) echo "${usage}" | ||
96 | exit 0 | ||
97 | ;; | ||
98 | c) enable_confirmation=true | ||
99 | ;; | ||
100 | p) preferred_launcher="${OPTARG}" | ||
101 | check_launcher "${preferred_launcher}" | ||
102 | ;; | ||
103 | *) exit 1 | ||
104 | ;; | ||
105 | esac | ||
106 | done | ||
107 | |||
108 | # Check whether a command exists | ||
109 | function command_exists() { | ||
110 | command -v "$1" &> /dev/null 2>&1 | ||
111 | } | ||
112 | |||
113 | # systemctl required | ||
114 | if ! command_exists systemctl ; then | ||
115 | exit 1 | ||
116 | fi | ||
117 | |||
118 | # menu defined as an associative array | ||
119 | typeset -A menu | ||
120 | |||
121 | # Menu with keys/commands | ||
122 | |||
123 | menu=( | ||
124 | [ Performance]="powerprofilesctl set performance" | ||
125 | [ Balanced]="powerprofilesctl set balanced" | ||
126 | [ Power Saver]="powerprofilesctl set power-saver" | ||
127 | [ Cancel]="" | ||
128 | ) | ||
129 | |||
130 | menu_nrows=${#menu[@]} | ||
131 | |||
132 | # Menu entries that may trigger a confirmation message | ||
133 | menu_confirm="Shutdown Reboot Hibernate Suspend Halt Logout" | ||
134 | |||
135 | launcher_exe="" | ||
136 | launcher_options="" | ||
137 | rofi_colors="" | ||
138 | |||
139 | function prepare_launcher() { | ||
140 | if [[ "$1" == "rofi" ]]; then | ||
141 | rofi_colors=(-bc "${BORDER_COLOR}" -bg "${BG_COLOR}" -fg "${FG_COLOR}" \ | ||
142 | -hlfg "${HLFG_COLOR}" -hlbg "${HLBG_COLOR}") | ||
143 | launcher_exe="rofi" | ||
144 | launcher_options=(-dmenu -i -lines "${menu_nrows}" -p "${ROFI_TEXT}" \ | ||
145 | "${rofi_colors}" "${ROFI_OPTIONS[@]}") | ||
146 | elif [[ "$1" == "zenity" ]]; then | ||
147 | launcher_exe="zenity" | ||
148 | launcher_options=(--list --title="${ZENITY_TITLE}" --text="${ZENITY_TEXT}" \ | ||
149 | "${ZENITY_OPTIONS[@]}") | ||
150 | fi | ||
151 | } | ||
152 | |||
153 | for l in "${launcher_list[@]}"; do | ||
154 | if command_exists "${l}" ; then | ||
155 | prepare_launcher "${l}" | ||
156 | break | ||
157 | fi | ||
158 | done | ||
159 | |||
160 | # No launcher available | ||
161 | if [[ -z "${launcher_exe}" ]]; then | ||
162 | exit 1 | ||
163 | fi | ||
164 | |||
165 | launcher=(${launcher_exe} "${launcher_options[@]}") | ||
166 | selection="$(printf '%s\n' "${!menu[@]}" | sort | "${launcher[@]}")" | ||
167 | |||
168 | function ask_confirmation() { | ||
169 | if [ "${launcher_exe}" == "rofi" ]; then | ||
170 | confirmed=$(echo -e "Yes\nNo" | rofi -dmenu -i -lines 2 -p "${selection}?" \ | ||
171 | "${rofi_colors}" "${ROFI_OPTIONS[@]}") | ||
172 | [ "${confirmed}" == "Yes" ] && confirmed=0 | ||
173 | elif [ "${launcher_exe}" == "zenity" ]; then | ||
174 | zenity --question --text "Are you sure you want to ${selection,,}?" | ||
175 | confirmed=$? | ||
176 | fi | ||
177 | |||
178 | if [ "${confirmed}" == 0 ]; then | ||
179 | i3-msg -q "exec --no-startup-id ${menu[${selection}]}" | ||
180 | fi | ||
181 | } | ||
182 | |||
183 | if [[ $? -eq 0 && ! -z ${selection} ]]; then | ||
184 | if [[ "${enable_confirmation}" = true && \ | ||
185 | ${menu_confirm} =~ (^|[[:space:]])"${selection}"($|[[:space:]]) ]]; then | ||
186 | ask_confirmation | ||
187 | else | ||
188 | i3-msg -q "exec --no-startup-id ${menu[${selection}]}" | ||
189 | fi | ||
190 | fi | ||
diff --git a/dot_config/i3/scripts/executable_powermenu b/dot_config/i3/scripts/executable_powermenu new file mode 100644 index 0000000..e72f0a2 --- /dev/null +++ b/dot_config/i3/scripts/executable_powermenu | |||
@@ -0,0 +1,186 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | # | ||
3 | # Use rofi/zenity to change system runstate thanks to systemd. | ||
4 | # | ||
5 | # Note: this currently relies on associative array support in the shell. | ||
6 | # | ||
7 | # Inspired from i3pystatus wiki: | ||
8 | # https://github.com/enkore/i3pystatus/wiki/Shutdown-Menu | ||
9 | # | ||
10 | # Copyright 2015 Benjamin Chrétien <chretien at lirmm dot fr> | ||
11 | # | ||
12 | # This program is free software: you can redistribute it and/or modify | ||
13 | # it under the terms of the GNU General Public License as published by | ||
14 | # the Free Software Foundation, either version 3 of the License, or | ||
15 | # (at your option) any later version. | ||
16 | |||
17 | # This program is distributed in the hope that it will be useful, | ||
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | # GNU General Public License for more details. | ||
21 | |||
22 | # You should have received a copy of the GNU General Public License | ||
23 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
24 | |||
25 | # modified to work with latest rofi update by joekamprad <[email protected]> | ||
26 | |||
27 | ####################################################################### | ||
28 | # BEGIN CONFIG # | ||
29 | ####################################################################### | ||
30 | |||
31 | # Use a custom lock script | ||
32 | #LOCKSCRIPT="i3lock-extra -m pixelize" | ||
33 | |||
34 | # Colors: FG (foreground), BG (background), HL (highlighted) | ||
35 | FG_COLOR="#bbbbbb" | ||
36 | BG_COLOR="#111111" | ||
37 | HLFG_COLOR="#111111" | ||
38 | HLBG_COLOR="#bbbbbb" | ||
39 | BORDER_COLOR="#222222" | ||
40 | |||
41 | # Options not related to colors (most rofi options do not work anymore) | ||
42 | ROFI_OPTIONS=(-theme ~/.config/rofi/powermenu.rasi) | ||
43 | # Zenity options | ||
44 | ZENITY_TITLE="Power Menu" | ||
45 | ZENITY_TEXT="Action:" | ||
46 | ZENITY_OPTIONS=(--column= --hide-header) | ||
47 | |||
48 | ####################################################################### | ||
49 | # END CONFIG # | ||
50 | ####################################################################### | ||
51 | |||
52 | # Whether to ask for user's confirmation | ||
53 | enable_confirmation=false | ||
54 | |||
55 | # Preferred launcher if both are available | ||
56 | preferred_launcher="rofi" | ||
57 | |||
58 | usage="$(basename "$0") [-h] [-c] [-p name] -- display a menu for shutdown, reboot, lock etc. | ||
59 | |||
60 | where: | ||
61 | -h show this help text | ||
62 | -c ask for user confirmation | ||
63 | -p preferred launcher (rofi or zenity) | ||
64 | |||
65 | This script depends on: | ||
66 | - systemd, | ||
67 | - i3, | ||
68 | - rofi or zenity." | ||
69 | |||
70 | # Check whether the user-defined launcher is valid | ||
71 | launcher_list=(rofi zenity) | ||
72 | function check_launcher() { | ||
73 | if [[ ! "${launcher_list[@]}" =~ (^|[[:space:]])"$1"($|[[:space:]]) ]]; then | ||
74 | echo "Supported launchers: ${launcher_list[*]}" | ||
75 | exit 1 | ||
76 | else | ||
77 | # Get array with unique elements and preferred launcher first | ||
78 | # Note: uniq expects a sorted list, so we cannot use it | ||
79 | i=1 | ||
80 | launcher_list=($(for l in "$1" "${launcher_list[@]}"; do printf "%i %s\n" "$i" "$l"; let i+=1; done \ | ||
81 | | sort -uk2 | sort -nk1 | cut -d' ' -f2- | tr '\n' ' ')) | ||
82 | fi | ||
83 | } | ||
84 | |||
85 | # Parse CLI arguments | ||
86 | while getopts "hcp:" option; do | ||
87 | case "${option}" in | ||
88 | h) echo "${usage}" | ||
89 | exit 0 | ||
90 | ;; | ||
91 | c) enable_confirmation=true | ||
92 | ;; | ||
93 | p) preferred_launcher="${OPTARG}" | ||
94 | check_launcher "${preferred_launcher}" | ||
95 | ;; | ||
96 | *) exit 1 | ||
97 | ;; | ||
98 | esac | ||
99 | done | ||
100 | |||
101 | # Check whether a command exists | ||
102 | function command_exists() { | ||
103 | command -v "$1" &> /dev/null 2>&1 | ||
104 | } | ||
105 | |||
106 | # systemctl required | ||
107 | if ! command_exists systemctl ; then | ||
108 | exit 1 | ||
109 | fi | ||
110 | |||
111 | # menu defined as an associative array | ||
112 | typeset -A menu | ||
113 | |||
114 | # Menu with keys/commands | ||
115 | |||
116 | menu=( | ||
117 | [ Shutdown]="systemctl poweroff" | ||
118 | [ Reboot]="systemctl reboot" | ||
119 | [ Suspend]="systemctl suspend" | ||
120 | [ Hibernate]="systemctl hibernate" | ||
121 | [ Lock]="~/.config/i3/scripts/blur-lock" | ||
122 | [ Logout]="i3-msg exit" | ||
123 | [ Cancel]="" | ||
124 | ) | ||
125 | |||
126 | menu_nrows=${#menu[@]} | ||
127 | |||
128 | # Menu entries that may trigger a confirmation message | ||
129 | menu_confirm="Shutdown Reboot Hibernate Suspend Halt Logout" | ||
130 | |||
131 | launcher_exe="" | ||
132 | launcher_options="" | ||
133 | rofi_colors="" | ||
134 | |||
135 | function prepare_launcher() { | ||
136 | if [[ "$1" == "rofi" ]]; then | ||
137 | rofi_colors=(-bc "${BORDER_COLOR}" -bg "${BG_COLOR}" -fg "${FG_COLOR}" \ | ||
138 | -hlfg "${HLFG_COLOR}" -hlbg "${HLBG_COLOR}") | ||
139 | launcher_exe="rofi" | ||
140 | launcher_options=(-dmenu -i -lines "${menu_nrows}" -p "${ROFI_TEXT}" \ | ||
141 | "${rofi_colors}" "${ROFI_OPTIONS[@]}") | ||
142 | elif [[ "$1" == "zenity" ]]; then | ||
143 | launcher_exe="zenity" | ||
144 | launcher_options=(--list --title="${ZENITY_TITLE}" --text="${ZENITY_TEXT}" \ | ||
145 | "${ZENITY_OPTIONS[@]}") | ||
146 | fi | ||
147 | } | ||
148 | |||
149 | for l in "${launcher_list[@]}"; do | ||
150 | if command_exists "${l}" ; then | ||
151 | prepare_launcher "${l}" | ||
152 | break | ||
153 | fi | ||
154 | done | ||
155 | |||
156 | # No launcher available | ||
157 | if [[ -z "${launcher_exe}" ]]; then | ||
158 | exit 1 | ||
159 | fi | ||
160 | |||
161 | launcher=(${launcher_exe} "${launcher_options[@]}") | ||
162 | selection="$(printf '%s\n' "${!menu[@]}" | sort | "${launcher[@]}")" | ||
163 | |||
164 | function ask_confirmation() { | ||
165 | if [ "${launcher_exe}" == "rofi" ]; then | ||
166 | confirmed=$(echo -e "Yes\nNo" | rofi -dmenu -i -lines 2 -p "${selection}?" \ | ||
167 | "${rofi_colors}" "${ROFI_OPTIONS[@]}") | ||
168 | [ "${confirmed}" == "Yes" ] && confirmed=0 | ||
169 | elif [ "${launcher_exe}" == "zenity" ]; then | ||
170 | zenity --question --text "Are you sure you want to ${selection,,}?" | ||
171 | confirmed=$? | ||
172 | fi | ||
173 | |||
174 | if [ "${confirmed}" == 0 ]; then | ||
175 | i3-msg -q "exec ${menu[${selection}]}" | ||
176 | fi | ||
177 | } | ||
178 | |||
179 | if [[ $? -eq 0 && ! -z ${selection} ]]; then | ||
180 | if [[ "${enable_confirmation}" = true && \ | ||
181 | ${menu_confirm} =~ (^|[[:space:]])"${selection}"($|[[:space:]]) ]]; then | ||
182 | ask_confirmation | ||
183 | else | ||
184 | i3-msg -q "exec ${menu[${selection}]}" | ||
185 | fi | ||
186 | fi | ||
diff --git a/dot_config/i3/scripts/executable_ppd-status b/dot_config/i3/scripts/executable_ppd-status new file mode 100644 index 0000000..8e6eb7b --- /dev/null +++ b/dot_config/i3/scripts/executable_ppd-status | |||
@@ -0,0 +1,11 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | # | ||
3 | # power-profiles-daemon implementation: | ||
4 | # needs package power-profiles-daemon installed and the service running see here: | ||
5 | # https://wiki.archlinux.org/title/CPU_frequency_scaling#power-profiles-daemon | ||
6 | # used in i3-blocks: ~/.config/i3/i3blocks.conf together with: ~/.config/i3/scripts/power-profiles | ||
7 | |||
8 | # script to show current power profile | ||
9 | |||
10 | current_profile=$(/usr/bin/powerprofilesctl get) | ||
11 | echo "$current_profile" | ||
diff --git a/dot_config/i3/scripts/executable_temperature b/dot_config/i3/scripts/executable_temperature new file mode 100644 index 0000000..4e31610 --- /dev/null +++ b/dot_config/i3/scripts/executable_temperature | |||
@@ -0,0 +1,86 @@ | |||
1 | #!/usr/bin/env perl | ||
2 | # Copyright 2014 Pierre Mavro <[email protected]> | ||
3 | # Copyright 2014 Vivien Didelot <[email protected]> | ||
4 | # Copyright 2014 Andreas Guldstrand <[email protected]> | ||
5 | # Copyright 2014 Benjamin Chretien <chretien at lirmm dot fr> | ||
6 | |||
7 | # This program is free software: you can redistribute it and/or modify | ||
8 | # it under the terms of the GNU General Public License as published by | ||
9 | # the Free Software Foundation, either version 3 of the License, or | ||
10 | # (at your option) any later version. | ||
11 | |||
12 | # This program is distributed in the hope that it will be useful, | ||
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | # GNU General Public License for more details. | ||
16 | |||
17 | # You should have received a copy of the GNU General Public License | ||
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | # | ||
20 | # Edited by Andreas Lindlbauer <[email protected]> | ||
21 | |||
22 | use strict; | ||
23 | use warnings; | ||
24 | use utf8; | ||
25 | use Getopt::Long; | ||
26 | |||
27 | binmode(STDOUT, ":utf8"); | ||
28 | |||
29 | # default values | ||
30 | my $t_warn = $ENV{T_WARN} || 70; | ||
31 | my $t_crit = $ENV{T_CRIT} || 90; | ||
32 | my $chip = $ENV{SENSOR_CHIP} || ""; | ||
33 | my $temperature = -9999; | ||
34 | my $label = "😀 "; | ||
35 | |||
36 | sub help { | ||
37 | print "Usage: temperature [-w <warning>] [-c <critical>] [--chip <chip>]\n"; | ||
38 | print "-w <percent>: warning threshold to become yellow\n"; | ||
39 | print "-c <percent>: critical threshold to become red\n"; | ||
40 | print "--chip <chip>: sensor chip\n"; | ||
41 | exit 0; | ||
42 | } | ||
43 | |||
44 | GetOptions("help|h" => \&help, | ||
45 | "w=i" => \$t_warn, | ||
46 | "c=i" => \$t_crit, | ||
47 | "chip=s" => \$chip); | ||
48 | |||
49 | # Get chip temperature | ||
50 | open (SENSORS, "sensors -u $chip |") or die; | ||
51 | while (<SENSORS>) { | ||
52 | if (/^\s+temp1_input:\s+[\+]*([\-]*\d+\.\d)/) { | ||
53 | $temperature = $1; | ||
54 | last; | ||
55 | } | ||
56 | } | ||
57 | close(SENSORS); | ||
58 | |||
59 | $temperature eq -9999 and die 'Cannot find temperature'; | ||
60 | |||
61 | if ($temperature < 45) { | ||
62 | $label = ''; | ||
63 | } elsif ($temperature < 55) { | ||
64 | $label = ''; | ||
65 | } elsif ($temperature < 65) { | ||
66 | $label = ''; | ||
67 | } elsif ($temperature < 75) { | ||
68 | $label = ''; | ||
69 | } else { | ||
70 | $label = ''; | ||
71 | } | ||
72 | # Print short_text, full_text | ||
73 | print "${label}"; | ||
74 | print " $temperature°C\n"; | ||
75 | print "${label}"; | ||
76 | print " $temperature°C\n"; | ||
77 | |||
78 | # Print color, if needed | ||
79 | if ($temperature >= $t_crit) { | ||
80 | print "#FF0000\n"; | ||
81 | exit 33; | ||
82 | } elsif ($temperature >= $t_warn) { | ||
83 | print "#FFFC00\n"; | ||
84 | } | ||
85 | |||
86 | exit 0; | ||
diff --git a/dot_config/i3/scripts/executable_volume b/dot_config/i3/scripts/executable_volume new file mode 100644 index 0000000..39618e1 --- /dev/null +++ b/dot_config/i3/scripts/executable_volume | |||
@@ -0,0 +1,93 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | # Copyright (C) 2014 Julien Bonjean <[email protected]> | ||
3 | # Copyright (C) 2014 Alexander Keller <[email protected]> | ||
4 | |||
5 | # This program is free software: you can redistribute it and/or modify | ||
6 | # it under the terms of the GNU General Public License as published by | ||
7 | # the Free Software Foundation, either version 3 of the License, or | ||
8 | # (at your option) any later version. | ||
9 | |||
10 | # This program is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | # GNU General Public License for more details. | ||
14 | |||
15 | # You should have received a copy of the GNU General Public License | ||
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | # original source: https://github.com/vivien/i3blocks-contrib/tree/master/volume | ||
19 | # check the readme: https://github.com/vivien/i3blocks-contrib/blob/master/volume/README.md | ||
20 | #------------------------------------------------------------------------ | ||
21 | |||
22 | # The second parameter overrides the mixer selection | ||
23 | # For PulseAudio users, eventually use "pulse" | ||
24 | # For Jack/Jack2 users, use "jackplug" | ||
25 | # For ALSA users, you may use "default" for your primary card | ||
26 | # or you may use hw:# where # is the number of the card desired | ||
27 | if [[ -z "$MIXER" ]] ; then | ||
28 | MIXER="default" | ||
29 | if command -v pulseaudio >/dev/null 2>&1 && pulseaudio --check ; then | ||
30 | # pulseaudio is running, but not all installations use "pulse" | ||
31 | if amixer -D pulse info >/dev/null 2>&1 ; then | ||
32 | MIXER="pulse" | ||
33 | fi | ||
34 | fi | ||
35 | [ -n "$(lsmod | grep jack)" ] && MIXER="jackplug" | ||
36 | MIXER="${2:-$MIXER}" | ||
37 | fi | ||
38 | |||
39 | # The instance option sets the control to report and configure | ||
40 | # This defaults to the first control of your selected mixer | ||
41 | # For a list of the available, use `amixer -D $Your_Mixer scontrols` | ||
42 | if [[ -z "$SCONTROL" ]] ; then | ||
43 | SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols | | ||
44 | sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" | | ||
45 | head -n1 | ||
46 | )}" | ||
47 | fi | ||
48 | |||
49 | # The first parameter sets the step to change the volume by (and units to display) | ||
50 | # This may be in in % or dB (eg. 5% or 3dB) | ||
51 | if [[ -z "$STEP" ]] ; then | ||
52 | STEP="${1:-5%}" | ||
53 | fi | ||
54 | |||
55 | # AMIXER(1): | ||
56 | # "Use the mapped volume for evaluating the percentage representation like alsamixer, to be | ||
57 | # more natural for human ear." | ||
58 | NATURAL_MAPPING=${NATURAL_MAPPING:-0} | ||
59 | if [[ "$NATURAL_MAPPING" != "0" ]] ; then | ||
60 | AMIXER_PARAMS="-M" | ||
61 | fi | ||
62 | |||
63 | #------------------------------------------------------------------------ | ||
64 | |||
65 | capability() { # Return "Capture" if the device is a capture device | ||
66 | amixer $AMIXER_PARAMS -D $MIXER get $SCONTROL | | ||
67 | sed -n "s/ Capabilities:.*cvolume.*/Capture/p" | ||
68 | } | ||
69 | |||
70 | volume() { | ||
71 | amixer $AMIXER_PARAMS -D $MIXER get $SCONTROL $(capability) | ||
72 | } | ||
73 | |||
74 | format() { | ||
75 | |||
76 | perl_filter='if (/.*\[(\d+%)\] (\[(-?\d+.\d+dB)\] )?\[(on|off)\]/)' | ||
77 | perl_filter+='{CORE::say $4 eq "off" ? "MUTE" : "' | ||
78 | # If dB was selected, print that instead | ||
79 | perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo '$1') | ||
80 | perl_filter+='"; exit}' | ||
81 | output=$(perl -ne "$perl_filter") | ||
82 | echo "$LABEL$output" | ||
83 | } | ||
84 | |||
85 | #------------------------------------------------------------------------ | ||
86 | |||
87 | case $BLOCK_BUTTON in | ||
88 | 3) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute | ||
89 | 4) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase | ||
90 | 5) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease | ||
91 | esac | ||
92 | |||
93 | volume | format | ||
diff --git a/dot_config/i3/scripts/executable_vpn b/dot_config/i3/scripts/executable_vpn new file mode 100644 index 0000000..a348f96 --- /dev/null +++ b/dot_config/i3/scripts/executable_vpn | |||
@@ -0,0 +1,25 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | # | ||
3 | # Copyright (C) 2021 Andreas Lindlbauer | ||
4 | # Licensed under the terms of EUPLv1.2. | ||
5 | # | ||
6 | # i3blocks blocklet script to monitor the (nord)vpn connection | ||
7 | |||
8 | vpnstatus="📢" | ||
9 | nordvpn_output=$(nordvpn status | cat -v | head -1 | sed -e 's/\^M-^M ^M//g' ) | ||
10 | if [ "${nordvpn_output}" = "Status: Connected" ]; then | ||
11 | vpnstatus="🥸" | ||
12 | elif [ "${nordvpn_output}" = "A new version of NordVPN is available! Please update the application." ]; then | ||
13 | nordvpn_output=$(nordvpn status | cat -v | head -2 | tail -1 | sed -e 's/\^M-^M ^M//g' ) | ||
14 | if [ "${nordvpn_output}" = "Status: Connected" ]; then | ||
15 | vpnstatus="🥴" | ||
16 | elif [ "${nordvpn_output}" = "Status: Disconnected" ]; then | ||
17 | vpnstatus="📢" | ||
18 | fi | ||
19 | elif [ "${nordvpn_output}" = "Status: Disconnected" ]; then | ||
20 | vpnstatus="📢" | ||
21 | elif [[ "$nordvpn_output" == *\/* ]] || [[ "$nordvpn_output" == *\\* ]]; then | ||
22 | vpnstatus="Something's very wrong" | ||
23 | fi | ||
24 | |||
25 | echo "$vpnstatus" | ||
diff --git a/dot_config/i3/scripts/executable_worldclock b/dot_config/i3/scripts/executable_worldclock new file mode 100644 index 0000000..573800e --- /dev/null +++ b/dot_config/i3/scripts/executable_worldclock | |||
@@ -0,0 +1,122 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | # | ||
3 | # Use rofi/zenity to display world clock. | ||
4 | # | ||
5 | # Note: this currently relies on associative array support in the shell. | ||
6 | # | ||
7 | # Inspired from i3pystatus wiki: | ||
8 | # https://github.com/enkore/i3pystatus/wiki/Shutdown-Menu | ||
9 | # | ||
10 | # Copyright 2022 Jinwei Zhao <i at jinwei dot me> | ||
11 | # | ||
12 | # This program is free software: you can redistribute it and/or modify | ||
13 | # it under the terms of the GNU General Public License as published by | ||
14 | # the Free Software Foundation, either version 3 of the License, or | ||
15 | # (at your option) any later version. | ||
16 | |||
17 | # This program is distributed in the hope that it will be useful, | ||
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | # GNU General Public License for more details. | ||
21 | |||
22 | # You should have received a copy of the GNU General Public License | ||
23 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
24 | |||
25 | # modified to work with latest rofi update by joekamprad <[email protected]> | ||
26 | |||
27 | ####################################################################### | ||
28 | # BEGIN CONFIG # | ||
29 | ####################################################################### | ||
30 | |||
31 | # Colors: FG (foreground), BG (background), HL (highlighted) | ||
32 | FG_COLOR="#bbbbbb" | ||
33 | BG_COLOR="#111111" | ||
34 | HLFG_COLOR="#111111" | ||
35 | HLBG_COLOR="#bbbbbb" | ||
36 | BORDER_COLOR="#222222" | ||
37 | |||
38 | # Options not related to colors (most rofi options do not work anymore) | ||
39 | ROFI_OPTIONS=(-theme ~/.config/rofi/worldclock.rasi) | ||
40 | |||
41 | ####################################################################### | ||
42 | # END CONFIG # | ||
43 | ####################################################################### | ||
44 | |||
45 | # Preferred launcher if both are available | ||
46 | preferred_launcher="rofi" | ||
47 | |||
48 | # Check whether the user-defined launcher is valid | ||
49 | launcher_list=(rofi) | ||
50 | function check_launcher() { | ||
51 | if [[ ! "${launcher_list[@]}" =~ (^|[[:space:]])"$1"($|[[:space:]]) ]]; then | ||
52 | echo "Supported launchers: ${launcher_list[*]}" | ||
53 | exit 1 | ||
54 | else | ||
55 | # Get array with unique elements and preferred launcher first | ||
56 | # Note: uniq expects a sorted list, so we cannot use it | ||
57 | i=1 | ||
58 | launcher_list=($(for l in "$1" "${launcher_list[@]}"; do printf "%i %s\n" "$i" "$l"; let i+=1; done \ | ||
59 | | sort -uk2 | sort -nk1 | cut -d' ' -f2- | tr '\n' ' ')) | ||
60 | fi | ||
61 | } | ||
62 | |||
63 | # Parse CLI arguments | ||
64 | while getopts "hcp:" option; do | ||
65 | case "${option}" in | ||
66 | p) preferred_launcher="${OPTARG}" | ||
67 | check_launcher "${preferred_launcher}" | ||
68 | ;; | ||
69 | *) exit 1 | ||
70 | ;; | ||
71 | esac | ||
72 | done | ||
73 | |||
74 | # Check whether a command exists | ||
75 | function command_exists() { | ||
76 | command -v "$1" &> /dev/null 2>&1 | ||
77 | } | ||
78 | |||
79 | # menu defined as an associative array | ||
80 | typeset -A menu | ||
81 | |||
82 | menu=( | ||
83 | [🇨🇦: `date '+%b %d %H:%M'`]="" | ||
84 | [🇬🇧: `TZ=Europe/London date '+%b %d %H:%M'`]="" | ||
85 | [🇨🇳: `TZ=Asia/Shanghai date '+%b %d %H:%M'`]="" | ||
86 | ) | ||
87 | |||
88 | menu_nrows=${#menu[@]} | ||
89 | |||
90 | launcher_exe="" | ||
91 | launcher_options="" | ||
92 | rofi_colors="" | ||
93 | |||
94 | function prepare_launcher() { | ||
95 | if [[ "$1" == "rofi" ]]; then | ||
96 | rofi_colors=(-bc "${BORDER_COLOR}" -bg "${BG_COLOR}" -fg "${FG_COLOR}" \ | ||
97 | -hlfg "${HLFG_COLOR}" -hlbg "${HLBG_COLOR}") | ||
98 | launcher_exe="rofi" | ||
99 | launcher_options=(-dmenu -i -lines "${menu_nrows}" -p "${ROFI_TEXT}" \ | ||
100 | "${rofi_colors}" "${ROFI_OPTIONS[@]}") | ||
101 | elif [[ "$1" == "zenity" ]]; then | ||
102 | launcher_exe="zenity" | ||
103 | launcher_options=(--list --title="${ZENITY_TITLE}" --text="${ZENITY_TEXT}" \ | ||
104 | "${ZENITY_OPTIONS[@]}") | ||
105 | fi | ||
106 | } | ||
107 | |||
108 | for l in "${launcher_list[@]}"; do | ||
109 | if command_exists "${l}" ; then | ||
110 | prepare_launcher "${l}" | ||
111 | break | ||
112 | fi | ||
113 | done | ||
114 | |||
115 | # No launcher available | ||
116 | if [[ -z "${launcher_exe}" ]]; then | ||
117 | exit 1 | ||
118 | fi | ||
119 | |||
120 | launcher=(${launcher_exe} "${launcher_options[@]}") | ||
121 | printf '%s\n' "${!menu[@]}" | sort | "${launcher[@]}" | ||
122 | |||