[Misc] switching to new repo for org files
1357
docs/deprecated/awesome.org
Normal file
715
docs/deprecated/i3.org
Normal file
@@ -0,0 +1,715 @@
|
||||
#+TITLE: i3
|
||||
#+setupfile: ../headers
|
||||
#+PROPERTY: header-args :noweb yes :exports code :tangle ~/.config/i3/config
|
||||
#+PROPERTY: header-args:emacs-lisp :exports none :tangle no
|
||||
|
||||
* i3
|
||||
#+begin_center
|
||||
*Before proceeding, be aware that I deprecated this i3 config on August 22nd, 2020, meaning I won’t update it anymore unless I use it again some day in the future. I will keep it on my website though.*
|
||||
#+end_center
|
||||
|
||||
=i3= is a window manager for GNU/Linux which automatically tiles windows in workspaces. This configuration was ade to automatically handle some tasks such as which software allowed where, autostart, and launching software with shortcuts.
|
||||
|
||||
It is to be noted I am using [[https://github.com/Airblader/i3][Airblader’s fork of i3]], =i3-gaps=. Some configuration will not work with =i3=.
|
||||
|
||||
#+BEGIN_SRC conf :exports none
|
||||
# -*- mode: conf -*-
|
||||
#+END_SRC
|
||||
|
||||
** Screenshots
|
||||
#+CAPTION: Desktop with Neofetch in the terminal
|
||||
[[./img/neofetch.png.webp]]
|
||||
|
||||
#+CAPTION: Desktop with Emacs opened
|
||||
[[./img/emacs.png.webp]]
|
||||
|
||||
#+CAPTION: Desktop with Rofi
|
||||
[[./img/rofi.png.webp]]
|
||||
|
||||
** Variables declaration
|
||||
*** Global
|
||||
The first I do is declaring the modifier key and the alt key —I don’t find the names =Mod1= and =Mod4= to be explicit enough. This will map =$mod= to the Super key (or as some people unfortunately call it, the /Windows/ key) and =$alt= to the Alt key.
|
||||
|
||||
Let’s also bind the =$up=, =$down=, =$left= and =$right= variables to respectively the up, down, left, and right arrows on the keyboard. Why bind them to variables? If I ever want to modify the arrow keys to some other keys, like =é=, =a=, =u=, and =i= (the equivalent of =wqsd= on the bépo layout) or =c=, =t=, =s=, and =r= (the equivalent of =hjkl= on the bépo layout), I will just have to modify these four lines.
|
||||
|
||||
I’ll also set the =$term= variable. A lot of shortcuts in my i3 config rely on the terminal emulator itself to launch commands in the terminal, and thus call the terminal itself. If I ever need to move from my current terminal, I will just have to change the name of the executable here.
|
||||
|
||||
#+NAME: variable-table
|
||||
| variable | value |
|
||||
|----------+-------|
|
||||
| $mod | Mod4 |
|
||||
| $alt | Mod1 |
|
||||
| $up | Up |
|
||||
| $down | Down |
|
||||
| $left | Left |
|
||||
| $right | Right |
|
||||
| $term | st |
|
||||
|
||||
#+NAME: variable-sh
|
||||
| variable | value |
|
||||
|-------------+--------------------------------------------------------------------------|
|
||||
| $exiti3 | i3-nagbar -t warning -m 'Leave i3?' -b 'Yes' 'i3-msg exit' |
|
||||
| $lockscreen | Lucien Cartier-Tilet\n(Phuntsok Drak-pa)\n+33 (0)6 83 90 56 89 |
|
||||
| $rofiexec | rofi -combi-modi 'window,drun' -show combi -mohh combi -m -1 -show-icons |
|
||||
| $mail | emacsclient -c -e '(mu4e)' -n |
|
||||
| $ec | emacsclient -c -n |
|
||||
| $walset | wal -i ~/Pictures/Wallpapers -o wal-set |
|
||||
|
||||
Variables will be set like so.
|
||||
#+BEGIN_SRC conf :tangle no
|
||||
set $term st
|
||||
#+END_SRC
|
||||
|
||||
#+NAME: generate-variables
|
||||
#+BEGIN_SRC emacs-lisp :var variables=variable-table :cache yes
|
||||
(mapconcat (lambda (x) (format "set %s %s" (car x) (cadr x)))
|
||||
variables
|
||||
"\n")
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS[48079cbd7e6dbf2003fe5ae87216bd38f638b6f8]: generate-variables
|
||||
: set $mod Mod4
|
||||
: set $alt Mod1
|
||||
: set $up Up
|
||||
: set $down Down
|
||||
: set $left Left
|
||||
: set $right Right
|
||||
: set $term st
|
||||
|
||||
Finally, some variables hold some long strings for commands I don’t want to have to type multiple times.
|
||||
#+NAME: generate-variables2
|
||||
#+BEGIN_SRC emacs-lisp :var variables=variable-sh :cache yes
|
||||
(mapconcat (lambda (x) (format "set %s \"%s\"" (car x) (cadr x)))
|
||||
variables
|
||||
"\n")
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS[c901e3e31c500859661650e86a6b63aef286acbe]: generate-variables2
|
||||
: set $exiti3 "i3-nagbar -t warning -m 'Leave i3?' -b 'Yes' 'i3-msg exit'"
|
||||
: set $lockscreen "Lucien Cartier-Tilet\n(Phuntsok Drak-pa)\n+33 (0)6 83 90 56 89"
|
||||
: set $rofiexec "rofi -combi-modi 'window,drun' -show combi -mohh combi -m -1 -show-icons"
|
||||
: set $mail "emacsclient -c -e '(mu4e)' -n"
|
||||
: set $ec "emacsclient -c -n"
|
||||
: set $walset "wal -i ~/Pictures/Wallpapers -o wal-set"
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf :noweb yes
|
||||
<<generate-variables()>>
|
||||
<<generate-variables2()>>
|
||||
#+END_SRC
|
||||
|
||||
Now comes the font for the window tiles. Honestly, this setting is useless since we do not see it, but let’s set it anyway.
|
||||
#+BEGIN_SRC conf
|
||||
font Fira Sans Book:style=Book:pixelsize=10
|
||||
#+END_SRC
|
||||
|
||||
*** Floating windows
|
||||
Floating windows are windows that are not tiled with other windows, but rather are free to go anywhere on your screen, with any size. A bit like what you would get with any other non-tiling window manager or desktop environment (though most of them support minimal tiling features).
|
||||
|
||||
Let’s declare our floading modyfier. With floating windows, you can move them around by clicking on the window’s borders; but since we don’t have any with this config, we will have instead to press the floating modifier while clicking on the window (anywhere on the window is fine) to move them around.
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf
|
||||
floating_modifier $mod
|
||||
#+END_SRC
|
||||
|
||||
** i3 global settings
|
||||
Some settings affect i3 globally, such as its aspect or how it handles the mouse. Hence, here are some settings I set in my configuration.
|
||||
|
||||
*** Mouse settings
|
||||
First of all, I do not want i3 to warp my mouse each time I change windows; my mouse stays where it is.
|
||||
#+BEGIN_SRC conf
|
||||
mouse_warping none
|
||||
#+END_SRC
|
||||
|
||||
I also to not want the window focus to follow my mouse, because sometimes I will just knock my physical mouse out of the way of my hand, and when I do that the software mouse will most likely end up in another window I do not want to focus.
|
||||
#+BEGIN_SRC conf
|
||||
focus_follows_mouse no
|
||||
#+END_SRC
|
||||
|
||||
*** Popup handling
|
||||
While in fullscreen, some software might generate a popup. In that case, I want to be aware of that, and any popup will make me leave fullscreen in order to be presented with said popup.
|
||||
#+BEGIN_SRC conf
|
||||
popup_during_fullscreen leave_fullscreen
|
||||
#+END_SRC
|
||||
|
||||
*** Behavior of workspace changes
|
||||
When changing workspace as described below, we often want to go back to the previous workspace we were working on, but we might not remember immediately which one it was, or we might still have our fingers ready to fire the shortcut which made us make the first workspace change. Hence, if we type the same workspace change shortcut, instead of doing nothing it will bring us back to the previous workspace we were on.
|
||||
#+BEGIN_SRC conf
|
||||
workspace_auto_back_and_forth yes
|
||||
#+END_SRC
|
||||
|
||||
*** Gaps and window appearance
|
||||
As mentioned in at the beginning of this document, I am using i3-gaps, which brings spacing (gaps) between windows to i3.
|
||||
|
||||
First, I want space around my windows only when there are several containers on the same screen, otherwise they will be maximized.
|
||||
#+BEGIN_SRC conf
|
||||
smart_gaps on
|
||||
#+END_SRC
|
||||
|
||||
I also do not want to see any window border, so I will be turning this setting off.
|
||||
#+BEGIN_SRC conf
|
||||
smart_borders on
|
||||
#+END_SRC
|
||||
|
||||
By the way, the default border is invisible, since it is zero pixels wide.
|
||||
#+BEGIN_SRC conf
|
||||
default_border pixel 0
|
||||
#+END_SRC
|
||||
|
||||
Then comes the size of these gaps. I made the outer gap negative so the space between my windows and the border of my screens is smaller than the gap between my containers.
|
||||
#+BEGIN_SRC conf
|
||||
gaps inner 20
|
||||
gaps outer -10
|
||||
#+END_SRC
|
||||
|
||||
Some parameters are also available when it comes to the colors i3 uses. Honestly, we won’t see these colors much, so let’s simply keep the default values.
|
||||
#+BEGIN_SRC conf
|
||||
set_from_resource $fg i3wm.color7 #f0f0f0
|
||||
set_from_resource $bg i3wm.color2 #f0f0f0
|
||||
|
||||
# class border backgr. text indicator child_border
|
||||
client.focused $bg $bg $fg $bg $bg
|
||||
client.focused_inactive $bg $bg $fg $bg $bg
|
||||
client.unfocused $bg $bg $fg $bg $bg
|
||||
client.urgent $bg $bg $fg $bg $bg
|
||||
client.placeholder $bg $bg $fg $bg $bg
|
||||
#+END_SRC
|
||||
|
||||
** Assigning windows to workspaces
|
||||
I decided to bind some windows to some workspaces in order to have a better organization of my desktop.
|
||||
#+NAME: assignment-table
|
||||
| Application | Class | Workspace |
|
||||
|-------------+-------------+-----------|
|
||||
| Emacs | Emacs | 2 |
|
||||
| Chromium | Chromium | 3 |
|
||||
| Firefox | firefox | 3 |
|
||||
| Nemo | Nemo | 4 |
|
||||
| Wonderdraft | Godot | 5 |
|
||||
| Gimp | Gimp* | 6 |
|
||||
| Gnome Boxes | gnome-boxes | 8 |
|
||||
| Steam | Steam | 9 |
|
||||
| Discord | discord | 10 |
|
||||
|
||||
The class table is used in the assignment in the i3 config file. For instance, Gimp’s assignment will look like this:
|
||||
#+BEGIN_SRC conf :tangle no
|
||||
assign [class="Gimp*"] 6
|
||||
#+END_SRC
|
||||
|
||||
#+NAME: generate-workspaces
|
||||
#+BEGIN_SRC emacs-lisp :var workspaces=assignment-table :cache yes
|
||||
(mapconcat (lambda (x) (format "assign [class=\"%s\"] %s" (cadr x) (caddr x)))
|
||||
workspaces
|
||||
"\n")
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS[0995341b013e50227edf78257ab502e46a30bc9a]: generate-workspaces
|
||||
: assign [class="Emacs"] 2
|
||||
: assign [class="Chromium"] 3
|
||||
: assign [class="firefox"] 3
|
||||
: assign [class="Nemo"] 4
|
||||
: assign [class="Godot"] 5
|
||||
: assign [class="Gimp*"] 6
|
||||
: assign [class="gnome-boxes"] 8
|
||||
: assign [class="Steam"] 9
|
||||
: assign [class="discord"] 10
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf :noweb yes
|
||||
<<generate-workspaces()>>
|
||||
#+END_SRC
|
||||
|
||||
And although this is not specifically assigning a window to a workspace, I also want to have the tenth workspace assigned to a specific output in case I have two screens — and since this is the case when I am using only one computer, Marpa, I will be using some EmacsLisp in order to generate a different configuration file from this org file depending on the name of the machine.
|
||||
#+NAME: ws10-output-edp1
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(if (string= system-name "Marpa")
|
||||
"workspace 10 output eDP-1"
|
||||
"")
|
||||
#+END_SRC
|
||||
|
||||
Now I’ll call the above code as a noweb reference that should be executed.
|
||||
#+BEGIN_SRC conf
|
||||
<<ws10-output-edp1()>>
|
||||
#+END_SRC
|
||||
|
||||
** Shortcuts
|
||||
I use *A LOT* of shortcuts when it comes to my workflow. Like, all the time. So, expect this chapter to be a bit long, and I’ll try to make it readable still.
|
||||
|
||||
Shortcuts are set like so:
|
||||
#+BEGIN_SRC conf :tangle no
|
||||
bindsym shortcut command
|
||||
#+END_SRC
|
||||
|
||||
#+NAME: generate-shortcuts
|
||||
#+BEGIN_SRC emacs-lisp :exports none :var table=[] :tangle no
|
||||
(mapconcat (lambda (x) (format "bindsym %s %s" (car x) (cadr x)))
|
||||
table
|
||||
"\n")
|
||||
#+END_SRC
|
||||
|
||||
*** Terminal shortcuts
|
||||
I have a couple of shortcuts which are related to my terminal. For instance, ~$mod+Return~ opens a regular terminal instance while ~$mod+$alt+M~ opens an SSH instance on my Mila host.
|
||||
#+NAME: terminal-shortcuts
|
||||
| shortcut | command | What it does |
|
||||
|-------------------+----------------------+--------------------------------------------------|
|
||||
| $mod+Return | exec $term | Opens a regular terminal console |
|
||||
| $mod+$alt+Return | split h;; exec $term | Opens a terminal console below the current one |
|
||||
| $mod+Shift+Return | split v;; exec $term | Opens a terminal on the right of the current one |
|
||||
| $mod+$alt+m | exec $term ssh Mila | Opens an SSH instance in my Mila host |
|
||||
| $mod+$alt+n | exec $term ssh Naro | Opens an SSH instance in my Naro host |
|
||||
| $mod+Shift+h | exec $term htop | Opens a terminal with ~htop~ |
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=terminal-shortcuts)>>
|
||||
#+END_SRC
|
||||
|
||||
*** i3 shortcuts
|
||||
A couple of shortcuts are dedicated to i3 itself.
|
||||
#+NAME: i3-sh
|
||||
| shortcut | command | what it does |
|
||||
|--------------+---------------------------------+----------------------------------|
|
||||
| $mod+Shift+c | exec yadm alt && i3-msg reload | Reload the i3 configuration file |
|
||||
| $mod+Shift+r | exec yadm alt && i3-msg restart | Restart i3 inplace |
|
||||
| $mod+Shift+e | exec $exiti3 | Quit i3 |
|
||||
|
||||
And although this is not really an i3 shortcut per se, I add here the shortcut for launching pywal, which will set one of my wallpapers as the wallpaper and will generate my system’s color configuration from it.
|
||||
#+NAME: wal-sh
|
||||
| shortcut | command | what it does |
|
||||
|----------+--------------+--------------------------------------------------------------|
|
||||
| $mod+w | exec $walset | Set a random wallpaper and generates a color profile from it |
|
||||
|
||||
We also have some shortcuts to lock our screen, sleep, hibernate and shut down our computer.
|
||||
#+NAME: computer-sh
|
||||
| shortcut | command | what it does |
|
||||
|---------------+----------------------------+------------------------|
|
||||
| $mod+l | exec i3lock -fol | Lock the screen |
|
||||
| $mod+$alt+h | exec "systemctl suspend" | Suspend the computer |
|
||||
| $mod+Ctrl+h | exec "systemctl hibernate" | Hibernate the computer |
|
||||
| $mod+Shift+F4 | exec poweroff | Power off the computer |
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=i3-sh)>>
|
||||
<<generate-shortcuts(table=wal-sh)>>
|
||||
<<generate-shortcuts(table=computer-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
*** Window and workspace management
|
||||
**** Managing how windows will split
|
||||
It is possible to indicate to i3 how windows interact with one another, and especially how they are organized by spawning new windows either to the right or below the current window.
|
||||
#+NAME: split-win-sh
|
||||
| shortcuts | command | what it does |
|
||||
|-----------+---------+--------------------------------------------------------|
|
||||
| $mod+h | split h | Next window to spawn will spawn below the current one |
|
||||
| $mod+v | split v | Next window to spawn will spawn beside the current one |
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=split-win-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Focus windows
|
||||
To change window focus, you can use one of the following shortcuts:
|
||||
#+NAME: window-focus-sh
|
||||
| shortcut | command | what it does |
|
||||
|-------------+-------------+-------------------------------------------|
|
||||
| $mod+$left | focus left | Focus the window left of the current one |
|
||||
| $mod+$down | focus down | Focus the window down of the current one |
|
||||
| $mod+$up | focus up | Focus the window up of the current one |
|
||||
| $mod+$right | focus right | Focus the windof right of the current one |
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=window-focus-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Focus workspaces
|
||||
Just like windows, it is also possible to change focus between workspaces, because let’s be honest, most people won’t have ten screens to display all ten workspaces at the same time, and frankly that would be impractical.
|
||||
#+NAME: ws-focus-sh
|
||||
| shortcut | window | what it does |
|
||||
|----------+--------------+-------------------------|
|
||||
| $mod+1 | workspace 1 | Focus first workspace |
|
||||
| $mod+2 | workspace 2 | Focus second workspace |
|
||||
| $mod+3 | workspace 3 | Focus third workspace |
|
||||
| $mod+4 | workspace 4 | Focus fourth workspace |
|
||||
| $mod+5 | workspace 5 | Focus fifth workspace |
|
||||
| $mod+6 | workspace 6 | Focus sixth workspace |
|
||||
| $mod+7 | workspace 7 | Focus seventh workspace |
|
||||
| $mod+8 | workspace 8 | Focus eighth workspace |
|
||||
| $mod+9 | workspace 9 | Focus ninth workspace |
|
||||
| $mod+0 | workspace 10 | Focus tenth workspace |
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=ws-focus-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Moving windows
|
||||
To move windows, a couple of shortcuts are available:
|
||||
#+NAME: window-move-sh
|
||||
| shortcut | command | what it does |
|
||||
|-------------------+------------+-------------------------------|
|
||||
| $mod+Shift+$left | move left | Move the focused window left |
|
||||
| $mod+Shift+$down | move down | Move the focused window down |
|
||||
| $mod+Shift+$up | move up | Move the focused window up |
|
||||
| $mod+Shift+$right | move right | Move the focused window right |
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=window-move-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Moving containers
|
||||
To move containers between the available screens, you have the following shortcuts:
|
||||
#+NAME: containers-move-sh
|
||||
| shortcut | command | what it does |
|
||||
|------------------+--------------------------------+------------------------------------------------------------|
|
||||
| $mod+Ctrl+$left | move container to output left | Moves the container to the screen left of the current one |
|
||||
| $mod+Ctrl+$down | move container to output down | Moves the container to the screen down of the current one |
|
||||
| $mod+Ctrl+$up | move container to output up | Moves the container to the screen above the current one |
|
||||
| $mod+Ctrl+$right | move container to output right | Moves the container to the screen right of the current one |
|
||||
|
||||
You can also send containers to other workspaces by their number.
|
||||
#+NAME: containers-ws-sh
|
||||
| shortcut | command | what it does |
|
||||
|--------------+--------------------------------+--------------------------------------------|
|
||||
| $mod+Shift+1 | move container to workspace 1 | Move current container to the workspace 1 |
|
||||
| $mod+Shift+2 | move container to workspace 2 | Move current container to the workspace 2 |
|
||||
| $mod+Shift+3 | move container to workspace 3 | Move current container to the workspace 3 |
|
||||
| $mod+Shift+4 | move container to workspace 4 | Move current container to the workspace 4 |
|
||||
| $mod+Shift+5 | move container to workspace 5 | Move current container to the workspace 5 |
|
||||
| $mod+Shift+6 | move container to workspace 6 | Move current container to the workspace 6 |
|
||||
| $mod+Shift+7 | move container to workspace 7 | Move current container to the workspace 7 |
|
||||
| $mod+Shift+8 | move container to workspace 8 | Move current container to the workspace 8 |
|
||||
| $mod+Shift+9 | move container to workspace 9 | Move current container to the workspace 9 |
|
||||
| $mod+Shift+0 | move container to workspace 10 | Move current container to the workspace 10 |
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=containers-move-sh)>>
|
||||
<<generate-shortcuts(table=containers-ws-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Moving workspaces
|
||||
|
||||
It is also possible to move workspaces. The related shortcuts available are the following:
|
||||
|
||||
#+NAME: workspace-move-sh
|
||||
| shortcut | command | what it does |
|
||||
|------------------------+--------------------------------+------------------------------------------------------------|
|
||||
| $mod+Ctrl+Shift+$left | move workspace to output left | Moves the workspace to the screen left of the current one |
|
||||
| $mod+Ctrl+Shift+$down | move workspace to output down | Moves the workspace to the screen down of the current one |
|
||||
| $mod+Ctrl+Shift+$up | move workspace to output up | Moves the workspace to the screen above the current one |
|
||||
| $mod+Ctrl+Shift+$right | move workspace to output right | Moves the workspace to the screen right of the current one |
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=workspace-move-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Close windows
|
||||
To close windows, we have two main shortcuts: Alt+F4 and mod+q. The first one is here due to habits, but I don’t really use it anymore due to my main keyboard which doesn’t have any easy access to the functions keys, hence mod+q.
|
||||
#+NAME: close-win-sh
|
||||
| shortcut | command | what it does |
|
||||
|----------+---------+-------------------------|
|
||||
| $mod+q | kill | kill the current window |
|
||||
| $alt+F4 | kill | kill the current window |
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=close-win-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Manage the size of the current window
|
||||
It is possible to change the size of the current window, even if it is a floating one. The first shortcut that might interest you is $mod+f which switches your current window to fullscreen. But to resize a window, you will need to enter the ~resize~ mode.
|
||||
#+NAME: size-win-sh
|
||||
| shortcut | command | what it does |
|
||||
|----------+-------------------+---------------------------------------------------|
|
||||
| $mod+f | fullscreen toggle | Puts the current window in fullscreen or exits it |
|
||||
| $mod+r | mode "resize" | Enter resize mode |
|
||||
|
||||
When it comes to modes, they are defined as follows:
|
||||
#+BEGIN_SRC conf :tangle no
|
||||
mode "nameofyourmode" {
|
||||
here go your shortcuts
|
||||
}
|
||||
#+END_SRC
|
||||
|
||||
So, all the following shortcuts will be inserted in a mode called ~resize~. Note that not only are the resizing shortcuts bound to the arrow keys, they are also bound to ~ctsr~, which is the bépo equivalent of ~hjkl~.
|
||||
#+NAME: resize-win-sh
|
||||
| shortcut | command | what it does |
|
||||
|----------+-------------------------------------+-------------------------------------------|
|
||||
| $right | resize grow width 20 px or 10 ppt | Increase the width of the current window |
|
||||
| r | resize grow width 20 px or 10 ppt | Increase the width of the current window |
|
||||
| $left | resize shrink width 10 px or 5 ppt | Decrease the width of the current window |
|
||||
| c | resize shrink width 10 px or 5 ppt | Decrease the width of the current window |
|
||||
| $down | resize grow height 10 px or 5 ppt | Increase the height of the current window |
|
||||
| t | resize grow height 10 px or 5 ppt | Increase the height of the current window |
|
||||
| $up | resize shrink height 10 px or 5 ppt | Decrease the height of the current window |
|
||||
| s | resize shrink height 10 px or 5 ppt | Decrease the height of the current window |
|
||||
| Return | mode "default" | Return to the default mode |
|
||||
| Escape | mode "default" | Return to the default mode |
|
||||
If you prefer, you can think of these shortcuts not as increasing or decreasing the width or height of the current window, but rather as how the bottom or right limit of the windows will be moved relative to the top left corner.
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=size-win-sh)>>
|
||||
mode "resize" {
|
||||
<<generate-shortcuts(table=resize-win-sh)>>
|
||||
}
|
||||
#+END_SRC
|
||||
|
||||
**** Manage floating windows
|
||||
As said above, your windows can be floating windows instead of being tiled like they are by default. For this too we have a couple of shortcuts:
|
||||
#+NAME: float-win-sh
|
||||
| shortcut | command | what it does |
|
||||
|------------------+----------------------+------------------------------------------------------|
|
||||
| $mod+Shift+space | floating toggle | Toggles the window between tiled and floating mode |
|
||||
| $mod+space | focus mode_toggle | Toggles the focus between tiled and floating windows |
|
||||
| $mod+Ctrl+c | move position center | Centers the focused floating window |
|
||||
If you want to move around your floating window, you can do it with your mouse while holding down the floating modifier declared [[file:./i3.md#floating-windows][here]].
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=float-win-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Scratchpad and window display
|
||||
You can think of i3’s scratchpad as some sort of extra workspace in which you can hide your windows you are not using, or as if you want to reduce a window to the taskbar of other window managers or desktop environments. You have basically two shortcuts for the scratchpad: one that sends the current window to the scratchpad, and one that cicles through the windows sent to the scratchpad and shows them to you sequencially. If you go through all of them, they will be hidden again. You can get a window out of the scratchpad by tiling it to the current workspace with the shortcut described above.
|
||||
|
||||
You also have the possibility of making a floating window a sticky window. This means not only will it show on all workspaces, it will also be on top of every other window. It can be useful if you have some notes you want to keep an eye on for instance.
|
||||
#+NAME: scratchpad-sh
|
||||
| shortcut | command | what it does |
|
||||
|--------------+-----------------+------------------------------------------------------|
|
||||
| $mod+Shift+s | move scratchpad | Sends the current window to the scratchpad |
|
||||
| $mod+s | scratchpad show | Shows and cycles through windows from the scratchpad |
|
||||
| $mod+Ctrl+s | sticky toggle | Toggles sticky mode on current window |
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=scratchpad-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Gaps management
|
||||
It is possible to dynamically change the gaps between containers if we want to change a bit the appearance of i3. For that, we obviously have some shortcuts.
|
||||
#+NAME: gaps-resize-sh
|
||||
| shortcut | command | what it does |
|
||||
|-------------------+-----------------------------------------------+-----------------------------|
|
||||
| $mod+g | gaps inner current plus 5 | Increase the inner gap size |
|
||||
| $mod+Shift+g | gaps inner current minus 5 | Decrease the inner gap size |
|
||||
| $mod+Ctrl+g | gaps outer current plus 5 | Increase the outer gap size |
|
||||
| $mod+Ctrl+Shift+g | gaps outer current minus 5 | Decrease the outer gap size |
|
||||
| $mod+$alt+g | gaps inner all set 20; gaps outer all set -10 | Reset gaps |
|
||||
|
||||
Here is the corresponding configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=gaps-resize-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
*** Launching software
|
||||
A big part of my i3 shortcuts though are related to launching various software. I’ll try to sort them by category here, but do take a look even at categories which you might not be interested in, they might actually have something useful for you.
|
||||
|
||||
**** Software and command launcher
|
||||
These commands will allow the user to launch applications which provide ~.desktop~ files or user-defined ~.desktop~ files, as well as commands with the help of rofi.
|
||||
#+NAME: launcher-sh
|
||||
| shortcut | command | what it does |
|
||||
|--------------+---------------------------------------+-------------------------------------------------------|
|
||||
| $mod+Shift+d | exec --no-startup-id j4-dmenu-desktop | Launch a registered application |
|
||||
| $mod+d | exec --no-startup-id $rofiexec | Launch a terminal command or a registered application |
|
||||
|
||||
Here is the configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=launcher-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Internet software
|
||||
I have a couple of Internet-related software I can launch easily.
|
||||
#+NAME: internet-sh
|
||||
| shortcut | command | what it does |
|
||||
|--------------+---------------------+-----------------------------|
|
||||
| $mod+b | exec firefox | Launch browser |
|
||||
| $mod+m | exec $mail | Launch Gnus, my mail client |
|
||||
| Ctrl+Shift+d | exec discord-canary | Launch Discord |
|
||||
|
||||
Hence this configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=internet-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Screenshots
|
||||
A couple of shortcuts are available for taking screenshots.
|
||||
#+NAME: screenshot-sh
|
||||
| shortcut | command | what it does |
|
||||
|-------------+-----------------------------------+----------------------------------------------------------|
|
||||
| Print | exec --no-startup-id scrot | Takes a screenshot of the entire desktop |
|
||||
| Ctrl+Print | exec --no-startup-id "scrot -s" | Takes a screenshot of a region or the selected window |
|
||||
| Shift+Print | exec --no-startup-id "scrot -d 3" | takes a screenshot of the desktop three in three seconds |
|
||||
|
||||
This gives us this configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=screenshot-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Screen brightness
|
||||
Here we have four commands for managing our screen’s brightness (this is useful for laptops, not so much with desktops), and two of them are actually duplicates of the other two in case a laptop doesn’t have dedicated keys or we are using a keyboard which doesn’t provide them.
|
||||
#+NAME: brightness-sh
|
||||
| shortcut | command | what it does |
|
||||
|-----------------------+------------------------+---------------------------------------|
|
||||
| XF86MonBrightnessUp | exec xbacklight -inc 5 | Increase the brightness of the screen |
|
||||
| $mod+$alt+Next | exec xbacklight -inc 5 | Increase the brightness of the screen |
|
||||
| XF86MonBrightnessDown | exec xbacklight -dec 5 | Decrease the brightness of the screen |
|
||||
| $mod+$alt+Prev | exec xbacklight -dec 5 | Decrease the brightness of the screen |
|
||||
|
||||
This gives us this configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=brightness-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Media control
|
||||
Some shortcuts are dedicated to media control, especially when it comes to controlling music. All of these media control shortcuts will be calls to ~mpc~ which will in turn send commands to ~mpd~, which is the music server I use on my computers.
|
||||
#+NAME: media-sh
|
||||
| shortcut | command | what it does |
|
||||
|---------------------------+--------------------+--------------------------------|
|
||||
| XF86AudioNext | exec mpc next | Forward to the next track |
|
||||
| $alt+XF86AudioRaiseVolume | exec mpc next | Forward to the next track |
|
||||
| $mod+Next | exec mpc next | Forward to the next track |
|
||||
| XF86AudioPrev | exec mpc prev | Backward to the previous track |
|
||||
| $alt+XF86AudioLowerVolume | exec mpc prev | Backward to the previous track |
|
||||
| $mod+Prior | exec mpc prev | Backward to the previous track |
|
||||
| XF86AudioPlay | exec mpc toggle | Play or pause the music |
|
||||
| $mod+p | exec mpc toggle | Play or pause the music |
|
||||
| $mod+$alt+p | exec mpc stop | Completely stop the music |
|
||||
| XF86AudioStop | exec mpc stop | Completely stop the music |
|
||||
| $alt+XF86AudioPlay | exec mpc stop | Completely stop the music |
|
||||
| $mod+$alt+7 | exec mpc volume +5 | Increase the volume from mpd |
|
||||
| $mod+$alt+8 | exec mpc volume -5 | Decrease the volume from mpd |
|
||||
|
||||
We also have two shortcuts for launching ncmpcpp, my mpd frontend, either with the playlist open by default, or the visualizes open.
|
||||
#+NAME: ncmpcpp-sh
|
||||
| shortcut | command | what it does |
|
||||
|--------------+-----------------------------------+----------------------------------|
|
||||
| $mod+Shift+n | exec $term ncmpcpp -q | Launch ncmpcpp’s playlist editor |
|
||||
| $mod+Shift+v | exec $term ncmpcpp -qs visualizer | Launch ncmpcpp’s visualizer |
|
||||
|
||||
We also have more general shortcuts, like how to manipulate the general volume level.
|
||||
#+NAME: volume-sh
|
||||
| shortcut | command | what it does |
|
||||
|----------------------+----------------------------------------+----------------------|
|
||||
| XF86AudioMute | exec "amixer set Master 1+ toggle" | Mute or unmute audio |
|
||||
| Ctrl+$mod+Prior | exec "amixer -q set Master 2%+ unmute" | Raise volume |
|
||||
| XF86AudioRaiseVolume | exec "amixer -q set Master 2%+ unmute" | Raise volume |
|
||||
| Ctrl+$mod+Next | exec "amixer -q set Master 2%- unmute" | Reduce volume |
|
||||
| XF86AudioLowerVolume | exec "amixer -q set Master 2%- unmute" | Reduce volume |
|
||||
|
||||
This gives us this configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=media-sh)>>
|
||||
<<generate-shortcuts(table=ncmpcpp-sh)>>
|
||||
<<generate-shortcuts(table=volume-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Rofi utilities
|
||||
We also have some utilities I’ve written and which are interfaced with rofi. Here are said shortcuts.
|
||||
#+NAME: rofi-sh
|
||||
| shortcut | command | what it does |
|
||||
|-------------------+-----------------------+---------------------------------------------------------------------|
|
||||
| $mod+Shift+p | exec rofi-pass --type | Types the selected password available from ~pass~ where the cursor is |
|
||||
| $mod+Ctrl+Shift+p | exec rofi-pass | Copies in the clipboard the selected password from ~pass~ for 45 sec |
|
||||
| $mod+Ctrl+m | exec rofi-mount | Volume mounting helper |
|
||||
| $mod+Ctrl+u | exec rofi-umount | Volume unmounting helper |
|
||||
| $mod+$alt+e | exec rofi-emoji | Emoji picker, copies it in the clipboard |
|
||||
| $mod+Ctrl+w | exec wacom-setup | Sets my Wacom Bamboo tablet as being active on the selected screen |
|
||||
| $mod+Shift+w | exec connect-wifi | Connect to an available WiFi network |
|
||||
|
||||
This gives us the following configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=rofi-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Miscellaneous
|
||||
And last but not least, I have some other shortcuts for various software, some of them which I use quite a lot like the shortcut for launching Emacs.
|
||||
#+NAME: misc-sh
|
||||
| shortcut | command | what it does |
|
||||
|-------------+------------------+---------------------------------|
|
||||
| $mod+e | exec $ec | Launch Emacs client |
|
||||
| $mod+n | exec nemo | Launch Nemo (file manager) |
|
||||
| $mod+$alt+c | exec speedcrunch | Launch Speedcrunch (calculator) |
|
||||
| $mod+F3 | exec arandr | Launch arandr |
|
||||
|
||||
This gives us the following configuration:
|
||||
#+BEGIN_SRC conf
|
||||
<<generate-shortcuts(table=misc-sh)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Screen management
|
||||
Additionally, we have a shortcut for entering presentation mode on the additional screen of the computer; on my main computer, Mila, the additional screen is HDMI-1, while it is VGA1 on my travel laptop. We’ll use some Emacs Lisp to determine on the configuration file export which screens names to use.
|
||||
#+NAME: hostname-screen-management
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(cond ((string= system-name "Marpa") "bindsym $mod+Ctrl+p xrandr --output HDMI-1 --mode 1024x768 --right-of eDP-1")
|
||||
((string= system-name "gampo") "bindsym $mod+Ctrl+p xrandr --output VGA1 --mode 1024x768 --right-of LVDS1"))
|
||||
#+END_SRC
|
||||
|
||||
Now, we just have to call this Emacs Lisp code as a noweb reference and execute it.
|
||||
#+BEGIN_SRC conf :noweb yes
|
||||
<<hostname-screen-management()>>
|
||||
#+END_SRC
|
||||
|
||||
** Software autolaunch
|
||||
When i3 is launched, I want it to also launch some software automatically. Here is what we will launch:
|
||||
#+NAME: autolaunch
|
||||
| always execute it? | command | what it is |
|
||||
|--------------------+-------------------------------------------+----------------------------------------|
|
||||
| no | /usr/lib/xfce-polkit/xfce-polkit | Launch the XFCE Polkit |
|
||||
| no | picom --experimental-backends -e 1 | Launch picom |
|
||||
| no | xss-lock -- lock | Launch power management |
|
||||
| no | numlockx on | Activate NumLock |
|
||||
| no | dunst -config ~/.config/dunst/dunstrc | Launch notification manager |
|
||||
| no | nm-applet | NetworkManager system tray |
|
||||
| yes | wal -i "$(< "${HOME}/.cache/wal/wal")" | Sets the wallpaper from last session |
|
||||
| no | xrdb $HOME/.Xresources | Load Xresources files |
|
||||
| yes | polybar-launch | Launch polybar |
|
||||
| no | mpc stop | Stop music from mpd |
|
||||
| no | mpd_discord_richpresence --no-idle --fork | Launch mpd status sharing with Discord |
|
||||
|
||||
#+NAME: generate-autolaunch
|
||||
#+BEGIN_SRC emacs-lisp :exports none :cache yes :var table=autolaunch
|
||||
(mapconcat (lambda (x)
|
||||
(format (concat (if (string= (car x)
|
||||
"yes")
|
||||
"exec_always"
|
||||
"exec")
|
||||
" --no-startup-id %s")
|
||||
(cadr x)))
|
||||
table
|
||||
"\n")
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS[283577fe2e66b30c936b7fcf142713d285db8da6]: generate-autolaunch
|
||||
#+begin_example
|
||||
exec_always --no-startup-id wal -i "$(< "${HOME}/.cache/wal/wal")"
|
||||
exec --no-startup-id xss-lock -- i3lock -fol
|
||||
exec --no-startup-id dunst -config ~/.config/dunst/dunstrc
|
||||
exec --no-startup-id xrdb $HOME/.Xresources
|
||||
exec --no-startup-id compton -F --opengl --config ~/.config/compton.conf -e 1
|
||||
exec_always --no-startup-id polybar-launch
|
||||
exec_always --no-startup-id enable_touch
|
||||
exec --no-startup-id syndaemon -i 1.0 -t -k
|
||||
exec --no-startup-id mpc stop
|
||||
exec --no-startup-id mpd_discord_richpresence --no-idle --fork
|
||||
exec --no-startup-id nm-applet
|
||||
exec --no-startup-id numlockx on
|
||||
#+end_example
|
||||
|
||||
My travel laptop has a fingerprint reader which can be used as an authentification method when the root password is asked. Let’s launch our policy kit manager if that is the case:
|
||||
#+NAME: fingerprint-thinkpad
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(if (string= system-name "gampo")
|
||||
"exec --no-startup-id /usr/lib/mate-polkit/polkit-mate-authentication-agent-1"
|
||||
"")
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC conf
|
||||
<<fingerprint-thinkpad()>>
|
||||
<<generate-autolaunch()>>
|
||||
#+END_SRC
|
||||
BIN
docs/deprecated/img/emacs.png
Normal file
|
After Width: | Height: | Size: 392 KiB |
BIN
docs/deprecated/img/emacs.png.webp
Normal file
|
After Width: | Height: | Size: 91 KiB |
BIN
docs/deprecated/img/neofetch.png
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
docs/deprecated/img/neofetch.png.webp
Normal file
|
After Width: | Height: | Size: 179 KiB |
2540
docs/deprecated/img/org-mode.svg
Normal file
|
After Width: | Height: | Size: 415 KiB |
BIN
docs/deprecated/img/rofi.png
Normal file
|
After Width: | Height: | Size: 2.8 MiB |
BIN
docs/deprecated/img/rofi.png.webp
Normal file
|
After Width: | Height: | Size: 160 KiB |
8
docs/deprecated/index.org
Normal file
@@ -0,0 +1,8 @@
|
||||
#+title: Deprecated configs
|
||||
#+setupfile: ../headers
|
||||
|
||||
* Deprecated configs
|
||||
Here you will find configurations that I no longer use nor maintain. I
|
||||
keep them here for the sake of archiving them, but do not expect them
|
||||
to be up to date with the current state of whichever software they are
|
||||
meant to configure.
|
||||
92
docs/deprecated/nano.org
Normal file
@@ -0,0 +1,92 @@
|
||||
#+TITLE: Nano
|
||||
#+setupfile: ../headers
|
||||
#+PROPERTY: header-args :tangle ~/.config/nano/nanorc
|
||||
|
||||
* Nano
|
||||
#+begin_center
|
||||
*Before proceeding, be aware that I deprecated this nano config on August 28th, 2020, meaning I won’t update it anymore unless I use it again some day in the future. I will keep it on my website though.*
|
||||
#+end_center
|
||||
|
||||
I nowadays rarely use Nano as a text editor, since I mainly rely on Emacs for all sorts of tasks, including quick file editing. However, at times, Emacs won’t work or won’t be available, and I therefore need a lightweight, fast and reliable text editor: Nano. And despite Nano being a simple piece of software, it does offer some customization I cannot refuse. Here is how I configured it:
|
||||
|
||||
** Configuration
|
||||
When saving a file, create a backup file by adding a tilde (=~=) to the file's name. And make and keep not just one backup file, but make and keep a uniquely numbered one every time a file is saved — when backups are enabled with =set backup= or =--backup= or =-B=. The uniquely numbered files are stored in the directory =~/.cache/nano/backups/=.
|
||||
#+BEGIN_SRC conf
|
||||
set backup
|
||||
set backupdir /home/phundrak/.cache/nano/backups/
|
||||
#+END_SRC
|
||||
|
||||
Save a file by default in Unix format. This overrides nano's default behavior of saving a file in the format that it had. (This option has no effect when you also use =set noconvert=.)
|
||||
#+BEGIN_SRC conf
|
||||
set unix
|
||||
#+END_SRC
|
||||
|
||||
*** Keys behavior
|
||||
Make the Home key smarter. When Home is pressed anywhere but at the very beginning of non-whitespace characters on a line, the cursor will jump to that beginning (either forwards or backwards). If the cursor is already at that position, it will jump to the true beginning of the line.
|
||||
#+BEGIN_SRC conf
|
||||
set smarthome
|
||||
#+END_SRC
|
||||
|
||||
*** Search
|
||||
Do case-unsensitive searches by default.
|
||||
#+BEGIN_SRC conf
|
||||
unset casesensitive
|
||||
#+END_SRC
|
||||
|
||||
Do regular-expression searches by default. Regular expressions in =nano= are of the extended type (ERE).
|
||||
#+BEGIN_SRC conf
|
||||
set regexp
|
||||
#+END_SRC
|
||||
|
||||
*** Visual settings
|
||||
Use bold instead of reverse video for the title bar, status bar, key combos, function tags, line numbers, and selected text. This can be overridden by setting the options =titlecolor=, =statuscolor=, =keycolor=, =functioncolor=, =numbercolor=, and =selectedcolor=.
|
||||
#+BEGIN_SRC conf
|
||||
set boldtext
|
||||
#+END_SRC
|
||||
|
||||
Enable soft line wrapping for easier viewing of very long lines.
|
||||
#+BEGIN_SRC conf
|
||||
set softwrap
|
||||
#+END_SRC
|
||||
|
||||
When soft line wrapping is enabled, make it wrap lines at blank characters (tabs and spaces) instead of always at the edge of the screen.
|
||||
#+BEGIN_SRC conf
|
||||
set atblanks
|
||||
#+END_SRC
|
||||
|
||||
Display line numbers to the left of the text area.
|
||||
#+BEGIN_SRC conf
|
||||
set linenumbers
|
||||
#+END_SRC
|
||||
|
||||
Constantly display the cursor position in the status bar. This overrides the option =quickblank=.
|
||||
#+BEGIN_SRC conf
|
||||
set constantshow
|
||||
#+END_SRC
|
||||
|
||||
*** Whitespace settings
|
||||
Convert typed tabs to spaces. Sue me.
|
||||
#+BEGIN_SRC conf
|
||||
set tabstospaces
|
||||
#+END_SRC
|
||||
|
||||
Use a tab size of a certain amount of columns. The value of number must be greater than 0. The default value is 8.
|
||||
#+BEGIN_SRC conf
|
||||
set tabsize 2
|
||||
#+END_SRC
|
||||
|
||||
Automatically indent a newly created line to the same number of tabs and/or spaces as the previous line (or as the next line if the previous line is the beginning of a paragraph).
|
||||
#+BEGIN_SRC conf
|
||||
set autoindent
|
||||
#+END_SRC
|
||||
|
||||
Remove trailing whitespace from wrapped lines when automatic hard-wrapping occurs or when text is justified.
|
||||
#+BEGIN_SRC conf
|
||||
set trimblanks
|
||||
#+END_SRC
|
||||
|
||||
*** Included configuration file
|
||||
Nano gives the opportunity to include some files located elsewhere. This is why I added [[https://github.com/scopatz/nanorc][this repo]] as a submodule of my dotfiles so I can access a lot of them at the same time. Since the submodule is cloned in =~/.config/nanorc=, we can add only one line to include all of the =.nanorc= files.
|
||||
#+BEGIN_SRC conf
|
||||
include ~/.config/nano/nano-syntax/*.nanorc
|
||||
#+END_SRC
|
||||
743
docs/deprecated/polybar.org
Normal file
@@ -0,0 +1,743 @@
|
||||
#+TITLE: Polybar
|
||||
#+setupfile: ../headers
|
||||
#+PROPERTY: header-args :exports none
|
||||
#+PROPERTY: header-args:emacs-lisp :tangle no :exports none
|
||||
#+PROPERTY: header-args:conf-windows :tangle ~/.config/polybar/config :noweb yes :exports code :mkdirp yes
|
||||
|
||||
* Polybar
|
||||
#+begin_center
|
||||
*Before proceeding, be aware that I deprecated this polybar config on August 22nd, 2020, meaning I won’t update it anymore unless I use it again some day in the future. I will keep it on my website though.*
|
||||
#+end_center
|
||||
|
||||
Polybar is a desktop utility for displaying various information in form of bars for GNU/Linux systems. It is often used as a replacement for native bars available in window managers, such as i3. In my case, I use two instances of polybar in order to get two bars displayed on each screen. The information displayed is either related to i3 itself, or it is system information, such as CPU or disk usage. More information will be given and explained below.
|
||||
|
||||
If you want to learn more about how to configure Polybar, you can go to its [[https://github.com/jaagr/polybar][official repository on Github]].
|
||||
|
||||
#+BEGIN_EXPORT latex
|
||||
Be aware that this PDF documents suffers from a couple of issues with some characters such as emojis. If you wish to see everything correctly, I would suggest you to take a look at the online HTML version of this document.
|
||||
#+END_EXPORT
|
||||
|
||||
** General settings
|
||||
Some general settings are available for Polybar, and they are declared under
|
||||
the ~[settings]~ section.
|
||||
#+BEGIN_SRC conf-windows
|
||||
[settings]
|
||||
#+END_SRC
|
||||
Only one setting is used in this configuration though: the ability to relauch
|
||||
polybar on a configuration file rewrite.
|
||||
#+BEGIN_SRC conf-windows
|
||||
screenchange-reload = true
|
||||
#+END_SRC
|
||||
|
||||
Some global settings are also available in order to adjust the
|
||||
~_NET_WM_STRUT_PARTIAL~ top and bottom values:
|
||||
#+BEGIN_SRC conf-windows
|
||||
[global/wm]
|
||||
margin-top = 32
|
||||
margin-bottom = 22
|
||||
#+END_SRC
|
||||
|
||||
** Colors declaration for polybar
|
||||
#+BEGIN_SRC conf-windows :exports none
|
||||
; -*- mode: conf-windows -*-
|
||||
#+END_SRC
|
||||
Like most status bars available, we can declare custom colors to be used in polybar. This part of the configuration file is declared with the following header:
|
||||
#+BEGIN_SRC conf-windows
|
||||
[colors]
|
||||
#+END_SRC
|
||||
As I use pywal as a color scheme generator based on the color of my wallpaper, I need to tell polybar to fetch the colors it will use from xrdb. If such color cannot be used, other colors will be used as fallback colors. First, let’s declare our default background and foreground colors with their alternative option.
|
||||
#+BEGIN_SRC conf-windows
|
||||
background = ${xrdb:color1:#50000000}
|
||||
background-alt = ${xrdb:color2:#444}
|
||||
foreground = ${xrdb:color7:#dfdfdf}
|
||||
foreground-alt = ${xrdb:color6:#555}
|
||||
#+END_SRC
|
||||
Now, we can also declare our primary and secondary colors.
|
||||
#+BEGIN_SRC conf-windows
|
||||
primary = #ffb52a
|
||||
secondary = #e60053
|
||||
#+END_SRC
|
||||
Polybar is also aware of alerts sent by window managers such as i3 when a window opens in an unfocused workspace. For that, let’s declare an alert color.
|
||||
#+BEGIN_SRC conf-windows
|
||||
alert = #bd2c40
|
||||
#+END_SRC
|
||||
|
||||
** Declaration of the bars
|
||||
It is possible in i3 to declare as many bars as we wish, and each of these bars will be named. Naming the bar is done in its module declaration like so:
|
||||
#+BEGIN_SRC conf-windows :tangle no
|
||||
[bar/nameofthebar]
|
||||
#+END_SRC
|
||||
In my configuration, I use two of such bars, one atop of my screen, and one at the bottom.
|
||||
|
||||
*** Top bar declaration
|
||||
As unimaginative as it might seem, I went for a rather explicit name for my bars. The top one is simply named ~top~, as shown below.
|
||||
#+BEGIN_SRC conf-windows
|
||||
[bar/top]
|
||||
#+END_SRC
|
||||
|
||||
**** Positioning
|
||||
We need to set on which screen the bar is to be displayed. Indeed, it is possible to display a bar on only one specific screen if we wish to. Actually, it is even the default behavior of polybar, but as we will see later with the launching script, it is possible to launch bars on multiple outputs at the same time. Here, we simply get the value of the variable ~monitor~ from the launch environment.
|
||||
#+NAME: monitor-bar
|
||||
#+BEGIN_SRC conf-windows
|
||||
monitor = ${env:MONITOR}
|
||||
#+END_SRC
|
||||
We have a few position-related variables that need to be set. We can specify whether or not we want our bar at the bottom of the screen —which is the default behavior of polybar—, its width, its height, the radius for the rounding of its corners and whether the bar should be centered or not. In my case, my bars are rather small height-wise, and it occupies most of the width of my screens. There is some gaps between this bar and the border of the screen, but this is due to a border around the bar itself which acts not only on the width of the bar itself, but also on its height.
|
||||
#+BEGIN_SRC conf-windows
|
||||
bottom = false
|
||||
border-size = 5
|
||||
<<position-bar-top>>
|
||||
#+END_SRC
|
||||
#+NAME: position-bar-top
|
||||
#+BEGIN_SRC conf-windows :exports none :tangle no
|
||||
width = 100%
|
||||
height = 22
|
||||
radius = 10.0
|
||||
fixed-center = true
|
||||
#+END_SRC
|
||||
We also want to add some padding to our bar so our modules are not too close to its edges, especially due to the rounding of the top bar.
|
||||
#+NAME: padding-bar
|
||||
#+BEGIN_SRC conf-windows
|
||||
padding-left = 2
|
||||
padding-right = 4
|
||||
#+END_SRC
|
||||
Each module will have some padding around it, so that modules aren’t glued together and instead have some room to breathe. The padding on the left is a bit less than the padding on the right for aesthetic reasons.
|
||||
#+NAME: module-margin-bar
|
||||
#+BEGIN_SRC conf-windows
|
||||
module-margin-left = 1
|
||||
module-margin-right = 2
|
||||
#+END_SRC
|
||||
The top bar doesn’t include any system tray, so let’s disable that.
|
||||
#+BEGIN_SRC conf-windows
|
||||
tray-position = none
|
||||
#+END_SRC
|
||||
|
||||
**** Colors and display
|
||||
As explained above, we declared some global variables when it comes to colors, and this is where they will be used. The bar’s background will be of the same color as the main background color declared earlier, and the same goes for the foreground.
|
||||
#+NAME: bar-colors
|
||||
#+BEGIN_SRC conf-windows
|
||||
background = ${colors.background}
|
||||
foreground = ${colors.foreground}
|
||||
#+END_SRC
|
||||
|
||||
If we wanted, we could also declare a default color for the underlines under the various modules that will be included in the bar, but in our case this variable is unused. So we will simply add this commented line as a memento this is possible, but it won’t have any effect with this current configuration of polybar. Same goes for the border around the bar, it is a useless variable in this configuration since we want the border to be transparent.
|
||||
#+NAME: line-border-color
|
||||
#+BEGIN_SRC conf-windows
|
||||
line-color = #f00
|
||||
; border-color = #00000000
|
||||
#+END_SRC
|
||||
|
||||
Although the variable for the default line color is not used, we still have to set the default width of the underline of our modules. By default, their underline will be three pixels thick.
|
||||
#+NAME: line-size-bar
|
||||
#+BEGIN_SRC conf-windows
|
||||
line-size = 3
|
||||
#+END_SRC
|
||||
|
||||
**** Fonts and locale
|
||||
Now we can chose which font fill be used in order to display text in this bar, as well as the locale we want. The locale will be useful for displaying information such as date and time, which is a module we will have in this top bar. First, the declaration of the locale is done like so:
|
||||
#+NAME: locale-bar
|
||||
#+BEGIN_SRC conf-windows
|
||||
locale = ja_JP.UTF-8
|
||||
#+END_SRC
|
||||
Now, we can declare the fonts we want to use in Polybar. It is possible to declare several of them, the first one is the one which gets the absolute priority, and the next ones with a larger index are fallback fonts. Font declaration accepts the fontconfig format as well as possible offset[fn:1]. Five fonts are used in my polybar config:
|
||||
#+NAME: fonts-polybar
|
||||
| Font | fontconfig | Vertical offset | Why it’s used |
|
||||
|--------------+----------------------------------------------------+-----------------+-----------------------|
|
||||
| Fira Sans | Fira Sans Book:style=Book:pixelsize=10 | 1 | Text display |
|
||||
| IPA Mincho | IPAMincho:style=regular:pixelsize=6 | 0 | Japanese text display |
|
||||
| Unifont | unifont:fontformat=truetype:size=6:antialias=false | 0 | Fallback font |
|
||||
| NotoEmoji | NotoEmoji:style=Book:scale=16 | 0 | Emoji display |
|
||||
| Siji | Siji:pixelsize=8 | 0 | Symbol display |
|
||||
| Default font | fixed:pixelsize=8 | 0 | Fallback font |
|
||||
#+NAME: font-ws-config
|
||||
#+HEADER: :var text="font"
|
||||
#+BEGIN_SRC emacs-lisp :var table=fonts-polybar[,1:2] :cache yes
|
||||
(setq counter 0)
|
||||
(mapconcat (lambda (font)
|
||||
(setq counter (+ 1 counter))
|
||||
(format "%s-%d = %s;%s"
|
||||
text
|
||||
(- counter 1)
|
||||
(nth 0 font)
|
||||
(nth 1 font)))
|
||||
table
|
||||
"\n")
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS[53fd99d75f6b08e96288fd2a62b455d7ef8b1754]: font-ws-config
|
||||
: font-0 = Fira Sans Book:style=Book:pixelsize=10;1
|
||||
: font-1 = IPAMincho:style=regular:pixelsize=6;0
|
||||
: font-2 = unifont:fontformat=truetype:size=6:antialias=false;0
|
||||
: font-3 = NotoEmoji:style=Book:scale=16;0
|
||||
: font-4 = Siji:pixelsize=8;0
|
||||
: font-5 = fixed:pixelsize=8;0
|
||||
|
||||
Here’s the font configuration:
|
||||
#+BEGIN_SRC conf-windows
|
||||
<<font-ws-config(text="font",table=fonts-polybar)>>
|
||||
#+END_SRC
|
||||
Note that only Fira Sans get a small offset due to the size of the font and the height of the bar itself.
|
||||
|
||||
**** Modules
|
||||
Finally, arguably one of the most important parts of our bar configuration: the module selection. Modules can be positioned in three different parts of our bar: to the right, in middle or to the left. On the left, we want our workspace indicator for i3. In the middle, we’ll get the title of the focused window, and to the left we’ll have the date and time.
|
||||
#+NAME: modules-generate
|
||||
#+BEGIN_SRC emacs-lisp :var table=top-modules :results value :cache yes
|
||||
(setq right '()
|
||||
center '()
|
||||
left '())
|
||||
(dolist (module table)
|
||||
(let* ((module-name (nth 0 module))
|
||||
(module-layout (nth 1 module)))
|
||||
(message "%S" module-layout)
|
||||
(add-to-list (cond
|
||||
((string= "left" module-layout) 'left)
|
||||
((string= "center" module-layout) 'center)
|
||||
(t 'right))
|
||||
module-name)))
|
||||
(concat (concat "modules-left = "
|
||||
(mapconcat #'identity left " ")
|
||||
"\n")
|
||||
(concat "modules-center = "
|
||||
(mapconcat #'identity center " ")
|
||||
"\n")
|
||||
(concat "modules-right = "
|
||||
(mapconcat #'identity right " ")
|
||||
"\n"))
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS[90b932dc0fd32501e1513f14059b92de09a7b59e]: modules-generate
|
||||
: modules-left = i3
|
||||
: modules-center = xwindow
|
||||
: modules-right = date
|
||||
|
||||
Here is the list of modules used:
|
||||
#+NAME: top-modules
|
||||
| Module name | Position | Brief description |
|
||||
|-------------+----------+----------------------------|
|
||||
| i3 | left | i3 workspace indicator |
|
||||
| xwindow | center | Name of the focused window |
|
||||
| date | right | Date and time |
|
||||
|
||||
#+BEGIN_SRC conf-windows :cache yes
|
||||
<<modules-generate(table=top-modules)>>
|
||||
#+END_SRC
|
||||
|
||||
Each module will be described in details later in this document.
|
||||
|
||||
*** Bottom bar declaration
|
||||
As described above, we will once again have to declare our bar with an equally unimaginative but explicit name.
|
||||
#+BEGIN_SRC conf-windows
|
||||
[bar/bottom]
|
||||
#+END_SRC
|
||||
|
||||
**** Positioning
|
||||
The variables are the same as above, but two of them will be slightly modified:
|
||||
#+BEGIN_SRC conf-windows
|
||||
bottom = true
|
||||
border-size = 0
|
||||
<<position-bar-bottom>>
|
||||
#+END_SRC
|
||||
|
||||
#+NAME: position-bar-bottom
|
||||
#+BEGIN_SRC conf-windows :exports none :tangle no
|
||||
width = 100%
|
||||
height = 22
|
||||
radius = 0.0
|
||||
fixed-center = true
|
||||
#+END_SRC
|
||||
When it comes to the bottom bar, I prefer to have it fit my outputs, without any margin around it. And of course, I have to declare it as being at the bottom of the screen, hence these modifications. As regards the padding of our modules, their own margins, and the screen output, they aren’t modified.
|
||||
#+BEGIN_SRC conf-windows
|
||||
<<padding-bar>>
|
||||
<<module-margin-bar>>
|
||||
<<monitor-bar>>
|
||||
#+END_SRC
|
||||
However, we do display the system tray on this bottom bar at its right. It has no padding and it is not detached from the bar (this allows the bar to be displayed under the icons of the system tray), and their maximum size was chosen so they are well visible without being too big.
|
||||
#+BEGIN_SRC conf-windows
|
||||
tray-position = right
|
||||
tray-padding = 0
|
||||
tray-detached = false
|
||||
tray-maxsize = 15
|
||||
#+END_SRC
|
||||
|
||||
**** Colors and display
|
||||
Nothing changes from the top bar, all the variables stay with the same values. See [[file:./polybar.md#colors-and-display][Colors and display]] of the top bar for more information.
|
||||
#+BEGIN_SRC conf-windows
|
||||
<<bar-colors>>
|
||||
<<line-border-color>>
|
||||
<<line-size-bar>>
|
||||
#+END_SRC
|
||||
|
||||
**** Fonts and locale
|
||||
Again, nothing changes from the top bar, so for more info on what’s going on, see [[file:./polybar.md#fonts-and-locale][Fonts and locale]] of the top bar.
|
||||
#+BEGIN_SRC conf-windows
|
||||
<<locale-bar>>
|
||||
<<font-ws-config(text="font",table=fonts-polybar)>>
|
||||
#+END_SRC
|
||||
|
||||
**** Modules
|
||||
Now, we can get to something interesting again: modules. This bar has a lot more modules than the top bar. Here is the list of the modules we have on the bottom bar:
|
||||
#+NAME: table-modules-bottom
|
||||
| Module name | Position | Brief description |
|
||||
|----------------+----------+---------------------------------|
|
||||
| mpd | left | MPD status indicator |
|
||||
| filesystem | right | Free storage in our filesystem |
|
||||
| wlan | right | Name of the active WiFi network |
|
||||
| eth | right | Local address on Ethernet |
|
||||
| volume | right | System volume |
|
||||
| backlight-acpi | right | Screen backlight |
|
||||
| cpu | right | CPU usage |
|
||||
| memory | right | RAM usage |
|
||||
| temperature | right | CPU temperature |
|
||||
| custom-battery | right | Battery usage |
|
||||
Here’s the corresponding configuration:
|
||||
#+ATTR_LATEX: :options breaklines
|
||||
#+BEGIN_SRC conf-windows
|
||||
<<modules-generate(table=table-modules-bottom)>>
|
||||
#+END_SRC
|
||||
All these modules will be explained below.
|
||||
|
||||
As you may have noticed, no modules will be displayed in the middle of this bar.
|
||||
|
||||
** Modules
|
||||
Before we begin to describe the different modules, I would like to point out something that will be repeated multiple times if I don’t talk about it right now: for each module, it is possible to declare the foreground and background color of the prefix of the modules, as well as the underline color and the padding of the module. I like these parameters to be rather consistent, so the code block you will see below will often be reused. The colors refer to the colors declared earlier, and the padding is minimal.
|
||||
#+NAME: mod-prefix-col
|
||||
#+BEGIN_SRC conf-windows :tangle no
|
||||
format-prefix-foreground = ${colors.foreground-alt}
|
||||
format-prefix-underline = ${colors.secondary}
|
||||
format-underline = ${colors.secondary}
|
||||
format-padding = 1
|
||||
#+END_SRC
|
||||
|
||||
*** Hardware
|
||||
**** Battery
|
||||
This module allows the user to get a battery widget among the polybar modules that will also send a notification to the user if the battery level drops below a certain value. This module relies on ~polybar-another-battery~ ([[https://github.com/drdeimos/polybar_another_battery][link]]) and its generated binary ~polybar-ab~ which should be in the ~$PATH~.
|
||||
|
||||
The first line of the module declaration lets the user name the module however they want. In this case, the name is ~custom-battery~.
|
||||
#+BEGIN_SRC conf-windows
|
||||
[module/custom-battery]
|
||||
#+END_SRC
|
||||
Since it is not a core module, we have to declare it as a custom script so polybar knows what to do with it.
|
||||
#+BEGIN_SRC conf-windows
|
||||
type = custom/script
|
||||
#+END_SRC
|
||||
We now can specify the script execution, and whether or not the script will be continuously outputting something. In our case, the answer to this last question is yes.
|
||||
#+BEGIN_SRC conf-windows
|
||||
exec = polybar-ab -polybar -thr 10
|
||||
tail = true
|
||||
#+END_SRC
|
||||
The ~-thr 10~ specifies the threshold for polybar-ab at which it should warn the user about the battery level of the computer.
|
||||
|
||||
Of course, users on desktop computers won’t need this module which is aimed at laptop users. Feel free to remove it if you do not need it.
|
||||
|
||||
**** Filesystem
|
||||
This module allows to display information about our filesystem, including (and this is what I use this module for) displaying the used space and remaining space on different mount points. This module is an internal module to polybar, so let’s declare it as such:
|
||||
#+BEGIN_SRC conf-windows
|
||||
[module/filesystem]
|
||||
type = internal/fs
|
||||
#+END_SRC
|
||||
We can specify how often the filesystem is to be checked with the variable ~interval~. I prefer it not to check it too often in order to not ping too often my drives, but I want it to be often enough so it is somewhat responsive. This is why I settled on a 20 seconds interval.
|
||||
#+BEGIN_SRC conf-windows
|
||||
interval = 20
|
||||
#+END_SRC
|
||||
We now have to indicate where our different filesystems are mounted. In the case of my main computer /Marpa/, I have two partitions, the root partition and the home partition. But on my travel laptop, I only have the root partition, hence the usage of the below Elisp code that determines based on the computer it is running whether or not the second mount point to my home partition should be included.
|
||||
#+NAME: include-home-partition
|
||||
#+BEGIN_SRC emacs-lisp :tangle no :exports code
|
||||
(if (string= system-name "Marpa")
|
||||
"mount-1 = /home")
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC conf-windows
|
||||
mount-0 = /
|
||||
<<include-home-partition()>>
|
||||
#+END_SRC
|
||||
Now we can set the format of our module. There are two mains formats, one for mounted and one for unmounted mountpoints. For both, we’ll simply use their label.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format-mounted = <label-mounted>
|
||||
format-unmounted = <label-unmounted>
|
||||
#+END_SRC
|
||||
When it comes to the mounted partition, we want to display the name of the mountpoint and how used it is, both in terms of gigabytes and percentage.
|
||||
#+BEGIN_SRC conf-windows
|
||||
label-mounted = 💽 %mountpoint%: %used%/%total% (%percentage_used%%)
|
||||
label-mounted-foreground = ${colors.foreground}
|
||||
label-mounted-underline = ${colors.secondary}
|
||||
#+END_SRC
|
||||
If the volume is unmounted (which should be worrying considering the mountpoints chosen), then we’ll simply have a message telling us about that, and the foreground color will use the alternative foreground color described earlier.
|
||||
#+BEGIN_SRC conf-windows
|
||||
label-unmounted = %mountpoint% not mounted
|
||||
label-unmounted-foreground = ${colors.foreground-alt}
|
||||
#+END_SRC
|
||||
|
||||
**** Xbacklight
|
||||
This module is used in order to display the level of brightness of a screen. It is not used by itself, but rather by other modules, such as [[file:./polybar.md#acpi-backlight][ACPI backlight]]. First of all, this module is an internal module for xbacklight. It will also display the brightness percentage, prefixed by a sun emoji. Lastly, it will be underlined by a green line.
|
||||
#+BEGIN_SRC conf-windows
|
||||
[module/xbacklight]
|
||||
type = internal/xbacklight
|
||||
format = <label>
|
||||
label = %percentage%%
|
||||
format-prefix = "🌞 "
|
||||
format-underline = #9f78e1
|
||||
#+END_SRC
|
||||
|
||||
**** ACPI backlight
|
||||
This module indicates the backlight level of a screen thanks to the ACPI Linux module. There isn’t much to tell about the module itself other than it inherits the module described above, [[file:./polybar.md#xbacklight][Xbacklight]]. It also sets which driver should be used, in this case the ~intel_backlight~ driver.
|
||||
#+BEGIN_SRC conf-windows
|
||||
[module/backlight-acpi]
|
||||
inherit = module/xbacklight
|
||||
type = internal/backlight
|
||||
card = intel_backlight
|
||||
#+END_SRC
|
||||
|
||||
**** CPU
|
||||
This module indicates how much of the CPU is being used. As shown below, I made it so we can see the load on each core. The first thing to do is to declare the module as an internal module dedicated to the CPU.
|
||||
#+BEGIN_SRC conf-windows
|
||||
[module/cpu]
|
||||
type = internal/cpu
|
||||
#+END_SRC
|
||||
|
||||
Now, we can set the refresh rate in seconds of the module. I like it at two seconds:
|
||||
#+BEGIN_SRC conf-windows
|
||||
interval = 2
|
||||
#+END_SRC
|
||||
|
||||
Now, let’s declare what will be displayed. The format will be a computer emoji followed by ramp characters.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format = <label> <ramp-coreload>
|
||||
format-prefix = "💻 "
|
||||
label = %percentage%%
|
||||
ramp-coreload-0 = ▁
|
||||
ramp-coreload-1 = ▂
|
||||
ramp-coreload-2 = ▃
|
||||
ramp-coreload-3 = ▄
|
||||
ramp-coreload-4 = ▅
|
||||
ramp-coreload-5 = ▆
|
||||
ramp-coreload-6 = ▇
|
||||
ramp-coreload-7 = █
|
||||
#+END_SRC
|
||||
|
||||
Finally, this module will be underlined in red.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format-underline = #f90000
|
||||
#+END_SRC
|
||||
|
||||
**** Memory
|
||||
Similarly to the CPU module, it is possible for Polybar to display the RAM load of the computer. As above, let’s declare this module as an internal module to Polybar:
|
||||
#+BEGIN_SRC conf-windows
|
||||
[module/memory]
|
||||
type = internal/memory
|
||||
#+END_SRC
|
||||
|
||||
As the CPU module still, the refresh rate will be of two seconds.
|
||||
#+BEGIN_SRC conf-windows
|
||||
interval = 2
|
||||
#+END_SRC
|
||||
|
||||
Its format will be the percentage of used RAM, prefixed by a disk emoji.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format = <label>
|
||||
format-prefix = "💿 "
|
||||
label = %gb_used%
|
||||
#+END_SRC
|
||||
|
||||
Lastly, it will be underlined in green.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format-underline = #4bffdc
|
||||
#+END_SRC
|
||||
|
||||
**** Wlan
|
||||
It is possible for Polybar to display the name of the current WiFi network the computer is connected to. For that, we first need to declare the Wlan module as an internal module of Polybar.
|
||||
#+BEGIN_SRC conf-windows
|
||||
[module/wlan]
|
||||
type = internal/network
|
||||
#+END_SRC
|
||||
|
||||
Now, we should set the name of the interface. As this depends on the hardware I am using, I am going to rely on the machine’s hostname and on some Elisp code to get this setting right.
|
||||
#+NAME: name-wlan-interface
|
||||
#+BEGIN_SRC emacs-lisp :exports code :tangle no
|
||||
(cond ((string= system-name "Marpa") "wlp8s0")
|
||||
((string= system-name "gampo") "wlp3s0"))
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC conf-windows
|
||||
interface = <<name-wlan-interface()>>
|
||||
#+END_SRC
|
||||
|
||||
The name of the current WiFi network will be refreshed every three seconds.
|
||||
#+BEGIN_SRC conf-windows
|
||||
interval = 3.0
|
||||
#+END_SRC
|
||||
|
||||
The format of the module when connected to a network will the the display of the antenna emoji, followed by the name of the network. When disconnected, the module will simply be empty.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format-connected = <label-connected>
|
||||
format-connected-prefix = "📶 "
|
||||
label-connected = %essid%
|
||||
#+END_SRC
|
||||
|
||||
**** Ethernet
|
||||
Just like any other module, the ethernet module has to be declared as an internal module.
|
||||
#+BEGIN_SRC conf-windows
|
||||
[module/eth]
|
||||
type = internal/network
|
||||
#+END_SRC
|
||||
|
||||
And just like the Wlan module, it requires an interface which can vary depending on the machine I am using, hence this piece of Elisp:
|
||||
#+NAME: name-eth-interface
|
||||
#+BEGIN_SRC emacs-lisp :exports code :tangle no
|
||||
(cond ((string= system-name "Marpa") "enp9s0")
|
||||
((string= system-name "gampo") "enp0s25"))
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC conf-windows
|
||||
interface = <<name-eth-interface()>>
|
||||
#+END_SRC
|
||||
|
||||
The format of this module will be the local address of the computer on the network, and it will be prefixed by a desktop computer emoji. Meanwhile, when disconnected, the module won’t be visible.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format-connected = <<label-connected>>
|
||||
format-connected-prefix = "🖥 "
|
||||
label-connected = %local_ip%
|
||||
format-disconnected =
|
||||
#+END_SRC
|
||||
|
||||
The module will be underlined in green.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format-connected-underline = #55aa55
|
||||
#+END_SRC
|
||||
|
||||
**** Volume
|
||||
The volume module in Polybar is linked to its internal bindings to ALSA. Let’s declare it accordingly.
|
||||
#+BEGIN_SRC conf-windows
|
||||
[module/volume]
|
||||
type = internal/alsa
|
||||
#+END_SRC
|
||||
|
||||
Its format is quite simple: if the audio is not muted, it is then prefixed with a speaker emoji, followed by the volume percentage.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format-volume = <label-volume>
|
||||
format-volume-prefix = "🔈 "
|
||||
label-volume = %percentage%%
|
||||
#+END_SRC
|
||||
|
||||
If the audio is muted, then the only thing the user will see is the muted speaker emoji followed by the text “muted”.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format-muted-prefix = "🔇 "
|
||||
label-muted = muted
|
||||
#+END_SRC
|
||||
|
||||
In any case, it will be underlined in green.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format-volume-underline = #55aa55
|
||||
#+END_SRC
|
||||
|
||||
**** Temperature
|
||||
The temperature module checks the temperature of the CPU, and warns the user above a certain threshold of heat, in my case if my CPU is above 60°C.
|
||||
#+BEGIN_SRC conf-windows
|
||||
[module/temperature]
|
||||
type = internal/temperature
|
||||
thermal-zone = 0
|
||||
warn-temperature = 60
|
||||
#+END_SRC
|
||||
|
||||
The format of the module is the thermometer emoji followed by the temperature of the CPU. If the CPU becomes too hot, the text will change color for the secondary foreground color.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format = <label>
|
||||
format-underline = #f50a4d
|
||||
format-warn = <label-warn>
|
||||
format-warn-underline = ${self.format-underline}
|
||||
format-prefix = "🌡 "
|
||||
format-warn-prefix = "🌡 "
|
||||
|
||||
label = %temperature-c%
|
||||
label-warn = %temperature-c%
|
||||
label-warn-foreground = ${colors.secondary}
|
||||
#+END_SRC
|
||||
|
||||
*** Software
|
||||
**** Window title
|
||||
This module’s aim is to simply provide the name of the currently focused window given by Xorg. This module is an internal module to polybar, that is to say it is built-in, and is of the type ~xwindow~. So, let’s declare the module accordingly, including the piece of common code declared at the beginning of the chapter:
|
||||
#+BEGIN_SRC conf-windows
|
||||
[module/xwindow]
|
||||
type = internal/xwindow
|
||||
<<mod-prefix-col>>
|
||||
#+END_SRC
|
||||
|
||||
Now we can take care of the label, which is the actual text that will be displayed. In our case, we want the label to be the title of the current X window, hence the value of ~label~, and we don’t want it to be too long, though I’m not sure I’ve often seen window titles longer than 70 characters.
|
||||
#+BEGIN_SRC conf-windows
|
||||
label = %title%
|
||||
label-maxlen = 70
|
||||
#+END_SRC
|
||||
|
||||
**** i3
|
||||
Now comes the module for i3 interaction. Thanks to this module, it is possible to show which workspaces are active and focused, and it is possible to change workspaces by clicking on the ones displayed in the bar. First, let’s declare it; it is an internal module by the way.
|
||||
#+BEGIN_SRC conf-windows
|
||||
[module/i3]
|
||||
type = internal/i3
|
||||
#+END_SRC
|
||||
|
||||
Now, let’s display only the workspaces that are on the current output. This means if a workspace is either inactive or on another screen or output, it won’t be displayed.
|
||||
#+BEGIN_SRC conf-windows
|
||||
pin-workspaces = true
|
||||
#+END_SRC
|
||||
|
||||
We also want our workspaces to be sorted by number rather than by output.
|
||||
#+BEGIN_SRC conf-windows
|
||||
index-sort = true
|
||||
#+END_SRC
|
||||
|
||||
I don’t want to be able to scroll through the workspaces when my mouse is hovering the module: when it happens, most of the time it was done accidentally. So let’s deactivate that. However, I sometimes like to click on them to switch from one another, so we’ll keep that activated.
|
||||
#+BEGIN_SRC conf-windows
|
||||
enable-scroll = false
|
||||
wrapping-scroll = false
|
||||
reverse-scroll = false
|
||||
enable-click = true
|
||||
#+END_SRC
|
||||
|
||||
This parameters splits the workspaces’ name on ~:~. Let’s deactivate that.
|
||||
#+BEGIN_SRC conf-windows
|
||||
strip-wsnumbers = false
|
||||
#+END_SRC
|
||||
|
||||
An on the topic of workspaces’ name, ~fuzzy-match~ allows the user to use fuzzy search for workspaces’ name when we will be applying custom names below. Not really useful since I only use the default workspaces’ name, but it’s good to have it enabled by default.
|
||||
#+BEGIN_SRC conf-windows
|
||||
fuzzy-match = true
|
||||
#+END_SRC
|
||||
|
||||
The label format is described first by its label, but also by one of its three possible modes: focused, visible or unfocused. These will be discussed later, but for now let’s simply set our format.
|
||||
#+begin_src conf-windows
|
||||
format = <label-state> <label-mode>
|
||||
#+end_src
|
||||
|
||||
We also wand to set the label mode to be whichever mode the workspace described by polybar is in. This label will also have a padding of 2 pixels, and the text will be written in white.
|
||||
#+begin_src conf-windows
|
||||
label-mode = %mode%
|
||||
label-mode-padding = 2
|
||||
label-mode-foreground = #000
|
||||
#+end_src
|
||||
|
||||
***** Workspace icons
|
||||
Now, let’s name our workspaces. We can give them whatever name we want them to have, but I just like the aesthetics of Japanese characters, so let’s go with the kanji equivalent of the number of the workspaces.
|
||||
#+NAME: ws-names
|
||||
| workspace number | name |
|
||||
|------------------+------|
|
||||
| 1 | 一 |
|
||||
| 2 | 二 |
|
||||
| 3 | 三 |
|
||||
| 4 | 四 |
|
||||
| 5 | 五 |
|
||||
| 6 | 六 |
|
||||
| 7 | 七 |
|
||||
| 8 | 八 |
|
||||
| 9 | 九 |
|
||||
| 0 | 十 |
|
||||
|
||||
Here are the corresponding configuration lines:
|
||||
#+BEGIN_SRC conf-windows
|
||||
<<font-ws-config(text="ws",table=ws-names)>>
|
||||
#+END_SRC
|
||||
|
||||
In case we create a workspace which isn’t named from ~0~ to ~9~, I want it to appear as is.
|
||||
#+begin_src conf-windows
|
||||
ws-icon-default = %index%
|
||||
#+end_src
|
||||
|
||||
***** Focused workspaces
|
||||
Now we can define the label itself. First, we will need to define the label when the workspace is focused. We’ll simply take the alternative background for the focused label, and the underline will be defined from Xrdb’s 8th color, with yellow as the fallback color. It will also have a two pixels padding. The text itself will be the dynamic icons declared above.
|
||||
#+begin_src conf-windows
|
||||
label-focused = %icon%
|
||||
label-focused-background = ${colors.background-alt}
|
||||
label-focused-underline = ${xrdb:color8:#ffff00}
|
||||
label-focused-padding = 2
|
||||
#+end_src
|
||||
|
||||
***** Visible workspaces
|
||||
The ~visible~ label is related to the ~focused~ labels since it is describing workspaces that can be seen, but are not currently focused, i.e. a workspace that appears on another screen than the one currently used so it is visible, but it isn’t focused. The difference with the ~unfocused~ workspaces is that the latter are neither focused nor visible. As you can see, we are simply using all of the declarations from above for the focused labels so we can ensure they appear the same way the focused labels do.
|
||||
#+begin_src conf-windows
|
||||
label-visible = ${self.label-focused}
|
||||
label-visible-background = ${self.label-focused-background}
|
||||
label-visible-underline = ${self.label-focused-underline}
|
||||
label-visible-padding = ${self.label-focused-padding}
|
||||
#+end_src
|
||||
|
||||
***** Unfocused workspaces
|
||||
When it comes to the unfocused label, there won’t be any custom background or underline, so we’ll just copy the two remaining lines from the focused labels for unfocused labels.
|
||||
#+begin_src conf-windows
|
||||
label-unfocused = %icon%
|
||||
label-unfocused-padding = 2
|
||||
#+end_src
|
||||
|
||||
***** Urgent workspaces
|
||||
Lastly, we get our urgent workspaces: workspaces in which most of the time it’s just a popup that appeared or a software that finally launched itself while working on something else on another workspace. To make it a bit more unique, let’s declare its background as being the color 0 from xrdb, with some dark red as the fallback color. And as the other labels, the text will be the icon and it will have a two pixels padding.
|
||||
#+begin_src conf-windows
|
||||
label-urgent = %icon%
|
||||
label-urgent-background = ${xrdb:color0:#bd2c40}
|
||||
label-urgent-padding = 2
|
||||
#+end_src
|
||||
|
||||
**** Mpd
|
||||
Mpd is a music server for GNU/Linux systems that interfaces will several front-ends, including ncmpcpp (the main one I use), ncmpcpp and mpc. It also interfaces with polybar thanks to some built in commands.
|
||||
|
||||
First, let’s declare our module as an internal module.
|
||||
#+BEGIN_SRC conf-windows
|
||||
[module/mpd]
|
||||
type = internal/mpd
|
||||
#+END_SRC
|
||||
|
||||
The next thing we want to do is set the label for the module: we will display both the title and the name of the artist of the song playing. The maximum length will be 70 characters.
|
||||
#+BEGIN_SRC conf-windows
|
||||
label-song = %title% - %artist%
|
||||
label-song-maxlen = 70
|
||||
label-song-ellipsis = true
|
||||
#+END_SRC
|
||||
|
||||
While Mpd is online, the format of the module should be the control icons and then the song label.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format-online = <icon-prev> <toggle> <icon-next> <label-song>
|
||||
icon-prev = ⏭
|
||||
icon-stop = ⏹
|
||||
icon-play = ▶
|
||||
icon-pause = ⏸
|
||||
icon-next = ⏭
|
||||
#+END_SRC
|
||||
|
||||
If Mpd is offline, then I would like to display a short messages that tells the user so.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format-offline = <label-offline>
|
||||
label-offline = 🎵 mpd is offline
|
||||
#+END_SRC
|
||||
|
||||
**** Date
|
||||
This module is really simple: it gives the current date. It is an internal module, and as declared below, it updates every second:
|
||||
#+BEGIN_SRC conf-windows
|
||||
[module/date]
|
||||
type = internal/date
|
||||
interval = 1
|
||||
#+END_SRC
|
||||
|
||||
The main date and time format is the standard one, following the ISO-8601 standard.
|
||||
#+BEGIN_SRC conf-windows
|
||||
date = %Y-%m-%d
|
||||
time = %H-%M-%S
|
||||
#+END_SRC
|
||||
|
||||
It also has an alternative format which I occasionally use, which displays the date and time in the Japanese format.
|
||||
#+BEGIN_SRC conf-windows
|
||||
date-alt = %A %d, %B
|
||||
time-alt = %H:%M:%S
|
||||
#+END_SRC
|
||||
|
||||
The format is quite simple: a clock emoji preceding the date and time.
|
||||
#+BEGIN_SRC conf-windows
|
||||
format-prefix = "🕑 "
|
||||
label = %date% %time%
|
||||
#+END_SRC
|
||||
|
||||
This module is underlined in blue:
|
||||
#+BEGIN_SRC conf-windows
|
||||
format-underline = #0a6cf5
|
||||
#+END_SRC
|
||||
|
||||
** Footnotes
|
||||
|
||||
[fn:1] [[https://github.com/polybar/polybar/wiki/Fonts][https://github.com/polybar/polybar/wiki/Fonts]]
|
||||
|
||||
# LocalWords: Siji pixelsize Fira Mincho IPAMincho Unifont unifont fontformat
|
||||
# LocalWords: truetype antialias xwindow wlan eth acpi cpu
|
||||