Since switching to Artix as my daily driver, I’ve been slowly filling in the little gaps that a desktop environment fills - really, the lack of settings utilities like a graphical network connection manager cause the most headache. I tend to figure out how to connect to a network one time, go on with my life, and by the next time it comes up I’ve completely forgotten, or I’m recalling vestiges of a slightly different terminal application that I used in the past to connect to a network, and I end up wasting 20 minutes.
I didn’t have a grand design in mind, but over the last few months I’ve put together a few polybar modules that fit my specific niche. Since I wrote - more adapted, I should say - the scripts for them, they’re easier to use than a graphical environment would be (and infinitely more satisfying).
Volume
One of the first things I figured out with polybar was binding left and right click to modules. This is super useful. Most commonly, I’ll use left-click to toggle something, and right-click to launch a program. For volume, I bound this to pavu-control. I may find a suitable TUI interface for volume, but I’m tired of figuring out the Linux audio stack (it’s changed since I’ve been away). It’s not something I wrote about here, as I was in a funk when I was figuring it all out, but I’ll probably regret it and come back to write about it later.
Tailscale
Honestly, this one I implemented pretty early on (probably before the volume), as Tailscale is my default entry point to manage all of my servers, and non-negotiable on a computer I planned to be my daily driver. It was easy to get up and running, but aggravating that I couldn’t see my connection status at a glance nor toggle it at the click of a button.
I sourced this one from here, and I think the only edit I made was to change the icons.
https://github.com/mbugert/tailscale-polybar-rofi
Wireguard
With the Tailscale one under my belt, I poked around for a Wireguard script. Found it here: https://github.com/mil-ad/polybar-wireguard/blob/main/polybar-wireguard
Made only minor edits to the one-liner to use ip instead of networkctl, since my distro isn’t systemd-based, and to sub dmenu with rofi for the configuration file selection.
connected_interface=$(ip link | grep wg | awk '{print $2}' | cut -d: -f1)Note that for this to work, wg-quick needs to be added as a passwordless sudo command, or you need to have a standalone password prompt (yet another one of those little desktop environment features I have yet to implement - though I used to have one that used dmenu).
Wi-Fi network selector
Turns out this Wireguard script was a perfect base for other ones. Our internet went down one day, and I found myself completely stuck unable to connect to my phone hotspot, because I was still connected to my WAP (despite having no internet, the WLAN was working just fine). I reviewed how to generate configuration files for wpa_supplicant, figured out I could store them in separate files instead of one big massive file, and turn them on and off at will. Decided I should just make it easy to switch between them, and my mind went back to the wireguard script.
#!/usr/bin/env sh
# configs_path="/etc/wpa_supplicant"
configs_path="$HOME/.config/wpa"
interface_name="wlan0"
connect() {
selected_config=$(ls $configs_path/*.conf | xargs basename -a -s .conf | rofi -dmenu)
[[ $selected_config ]] && sudo wpa_supplicant -B -i $interface_name -c "$configs_path"/"$selected_config".conf
}
disconnect() {
sudo killall wpa_supplicant
}
toggle() {
if [[ $(pgrep wpa_supplicant) ]]
then
disconnect
else
connect
fi
}
case "$1" in
--connect)
connect
;;
--disconnect)
disconnect
;;
--toggle)
toggle
;;
*)
esacSome notes:
wpa_supplicantandkillall wpa_supplicantboth need to be added as passwordlesssudocommands.- The command to generate a new network configuration file is this:
wpa_passphrase <SSID> <password> >> /path/to/config/dir/config_file. - Dependencies:
wpa_supplicantandwpa_supplicant-openrc, with thewpa_supplicantservice running at boot level. (This assumes thatwpa_supplicantis your primary means of connecting to wireless networks, and that OpenRC is your init system.)rofi
- The polybar module is a little bit weird, as instead of it being a custom script, it is adapting a built-in module. I don’t remember why exactly it needed to be done this way. Including the module below. Left click toggles wifi - if on, it turns it off; if off, it prompts you to select a network that you’ve previously created a configuration file for.
[module/wlan]
type = internal/network
interface = wlan0
interval = 3.0
label-connected = %{A1:$HOME/.local/bin/polybar-wifi --toggle:} %local_ip{A}
label-disconnected-foreground = ${colors.lightgray}Bluetooth
This one is what spurred me to make this post, and is what is going to convince me to find and bind an appropriate TUI to every polybar module (e.g. bind htop to right click on the CPU and/or RAM usage modules).
It’s not much of a logical extension to the preceding. This one doesn’t even bother with particular devices, it just toggles Bluetooth and shows a connected device name. I didn’t even try to see what would happen if I connected multiple devices - I only ever have one connected, my headphones, so I haven’t bothered. I’m sure it will break.
#!/usr/bin/env sh
bluetooth_status=$(bluetooth | cut -d= -f2 | tr -d ' ')
paired_device=$(bluetoothctl devices Paired | cut -d ' ' -f3-)
on() {
bluetooth on
}
off() {
bluetooth off
}
toggle() {
bluetooth toggle
}
print() {
if [[ $bluetooth_status = on ]]
then
echo %{u"$green"}%{+u}%{T4}%{F"$green"}%{T-}%{F-} "$paired_device"
else
echo %{T4} bt%{T-}
fi
}
case "$1" in
--on)
on
;;
--off)
off
;;
--toggle)
toggle
;;
*)
print
;;
esacDependencies:
tlp(for thebluetoothcommand -tlpI already had installed as part of my initial setup, to provide power saving for my laptop)bluezandbluez-openrcfor the Bluetooth servicebluez-utilsfor thebluetoothctlcommandbluetuiif you want the nifty TUI to pop up on right-click
Associated polybar module:
[module/bluetooth]
type = custom/script
exec = $HOME/.local/bin/bar-scripts/polybar-bluetooth
tail = false
interval = 1
click-left = $HOME/.local/bin/bar-scripts/polybar-bluetooth --toggle &
click-right = exec $TERMINAL -e bluetui &Wrap
Maybe eventually I will go through and clean up my full polybar configuration and add all those nifty TUIs on right-click for all the modules.
It’d be nice to finalize everything and get together a full list of packages, config files, and maybe even an install script, but I take some sort of morbid pleasure in knowing that my system is a special snowflake. I also tend to change it on a whim.
EOF