/i3-scripts

Various bits and bobs related to i3-wm

Primary LanguagePythonMIT LicenseMIT

i3 Scripts

This repository contains a number of different utility scripts used by my i3-wm configuration.

i3-list-workspaces.py

i3-list-workspaces.py outputs all existing workspaces when called. It’s primarily used with the below two bindings that allow switching between named workspaces.

The key choice reflects the German QWERTZ keyboard I use, as dead_circumflex is to the left of the 1 key. On a QWERTY keyboard, this key would be dead_grave.

bindsym $mod+dead_circumflex exec "i3-list-workspaces | dmenu | xargs i3-msg workspace"
bindsym $mod+Shift+dead_circumflex exec "i3-list-workspaces | dmenu | xargs i3-msg move container to workspace"
  1. Pipes list of workspaces into dmenu, and switches to selected workspace. If non-existing workspace is entered, it creates that workspace instead.
  2. Same principle, but moves active container to workspace instead.

Requires the i3ipc-python package.

i3rec.py

i3rec.py is a script to allow ffmpeg x11grab to record the currently focused container in i3. It is designed to be bound to an i3 keybinding. Calling the script once will start the recording, calling the script again will stop it.

> i3rec <output.mp4> [options] 

If no output file path is given, i3rec will save the file as yy-mm-dd(1).mp4 in the default directory specified within the script. If only a filename or path is given, i3rec will fill the missing value with its defaults.

OptionBehaviour
--draw_mouseDraw the mouse pointer (default=false)
--show_regionShow border around recording region (default=false)
--framerate <num>Set video framerate (default=25)
--display <display>Set x11 display to record from (default=0:0)
bindsym $mod+Print exec i3rec --show_region
bindsym $mod+Shift+Print exec "echo | dmenu | xargs i3rec --show_region"  
  1. Executes i3rec on $mod+Print with region outline
  2. Specify filename via dmenu

Requires the i3ipc-python package and ffmpeg.

i3blocks

The i3blocks folder contains scripts I use to render my i3 modeline images/i3bar.png

system_monitor.py

Outputs:

  • Disk Usage
  • Memory Usage
  • Max Processor Utilisation
  • Average Processor Utilisation
  • Battery Status
[comp_status]
command=/path/to/system_monitor.py
interval=1
markup=pango
color=#FFFFFF

Requires mpstat, Font Awesome 5.

network_monitor.py

Displays up and download rates on specific interface, with color highlighting.

There are 3 variables in the script that need to be set

  • RX_MAX : “Maximum” download speed (in Bytes/s)
  • TX_MAX : “Maximum” upload speed (in Bytes/s)
  • INTERFACE : Interface to track
[network_monitor]
min_width="<span font='Font Awesome Heavy'>&#xf106;</span><span foreground='#3e3e3e'>·82B</span> <span font='Font Awesome Heavy'>&#xf107;</span><span foreground='#484848'>372B</span>"
command=/home/user/scripts/i3blocks/network_monitor.py
interval=persist
markup=pango
color=#FFFFFF

Requires ifstat.

mpc_title.py

Renders currently playing song title as a marquee scroll

[mpc_title]
full_text=" <span font='8'>                    </span>"
command=/home/user/scripts/i3blocks/mpc_title.py 20
interval=persist
markup=pango

Requires mpd.

mpc_select.py

Button to select mpd playlists or songs via dmenu.

Mouse Button Mappings

  • Button 1: Replace current playlist with selected playlist
  • Button 2: Append selected playlist to current playlist
  • Button 3: Select song and play it

Note: As this script fetches a clientside representation of mpds song database to pipe into dmenu, it may struggle with large music databases

[mpc_playlist]
full_text=""
command=/home/user/scripts/i3blocks/mpc_select.py 

Requires mpd, dmenu.

volume_slider.py

Renders interactive volume slider out of unicode box fill characters

[volume-slider]
command=/home/user/scripts/i3blocks/volume_slider.py 30
interval=1
markup=pango

Requires amixer.

mpc_toggle, volume_toggle.py

Toggle mpd playback and alsa master volume respectively.

[mpc_toggle]
command=/home/user/scripts/i3blocks/mpc_toggle.py 
interval=once
color=#EEEEEE

[mute]
command=/home/user/scratch/i3blocks/volume_toggle.py
interval=once
color=#AFAFAF

Require Font Awesome 5.