Files
literate-dotfiles/polybar.org
2023-10-13 12:30:13 +02:00

1118 lines
27 KiB
Org Mode

#+TITLE: Polybar Configuration
#+SETUPFILE: ./setup/org-setup-file.org
#+PROPERTY: header-args :comments no
#+PROPERTY: header-args+ :mkdirp yes
#+PROPERTY: header-args+ :tangle ~/.config/polybar/config.ini
* Colors
#+begin_src conf
[colors]
bg = ${xrdb:background}
red = ${xrdb:color1}
green = ${xrdb:color2}
yellow = ${xrdb:color3}
blue = ${xrdb:color4}
purple = ${xrdb:color5}
aqua = ${xrdb:color6}
gray = ${colors.color7}
darkgray = ${colors.color8}
darkred = ${xrdb:color9}
darkgreen = ${xrdb:color10}
darkyellow = ${xrdb:color11}
darkblue = ${xrdb:color12}
darkpurple = ${xrdb:color13}
darkaqua = ${xrdb:color14}
fg = ${xrdb:foreground}
#+end_src
* VM
#+begin_src conf
[global/wm]
margin-top = 0
margin-bottom = 0
#+end_src
* Top Bar
#+BEGIN_SRC conf
[bar/top]
enable-ipc = true
# override-redirect = false
bottom = false
fixed-center = false
width = 100%
height = 27
radius = 0.0
background = ${colors.bg}
foreground = ${colors.fg}
line-size = 2
border-size = 0
padding-left = 2
padding-right = 16
module-margin-left = 1
module-margin-right = 1
font-0 = Hack Nerd Font:style=Regular:pixelsize=10;1
font-1 = unifont:fontformat=truetype:size=8:antialias=false;0
modules-left = i3 xwindow
modules-center =
modules-right = mpd pulseaudio tunnel_homelab tunnel_esrf dunst cursor unread_mail calendar timer battery date
# wm-restack = i3
tray-position = right
tray-detached = true
tray-padding = 0
tray-background = ${colors.bg}
#+END_SRC
* Show Windows Title
#+BEGIN_SRC conf
[module/xwindow]
type = internal/xwindow
label = %title:0:30:...%
#+END_SRC
* I3 - Information about workspaces and active one
#+BEGIN_SRC conf
[module/i3]
type = internal/i3
enable-scroll = false
wrapping-scroll = false
#+END_SRC
#+BEGIN_SRC conf
format = <label-state> <label-mode>
index-sort = true
#+END_SRC
#+BEGIN_SRC conf
label-mode-foreground = ${colors.bg}
label-mode-background = ${colors.fg}
label-mode-padding = 1
# focused = Active workspace on focused monitor
label-focused = %icon% %index%
label-focused-foreground = ${colors.fg}
label-focused-background = ${colors.bg}
label-focused-underline = ${colors.aqua}
label-focused-padding = 1
# unfocused = Inactive workspace on any monitor
label-unfocused = %icon% %index%
label-unfocused-foreground = ${colors.fg}
label-unfocused-background = ${colors.bg}
label-unfocused-underline = ${colors.bg}
label-unfocused-padding = 1
# visible = Active workspace on unfocused monitor
label-visible = %icon% %index%
label-visible-background = ${colors.bg}
label-visible-underline = ${colors.aqua}
label-visible-padding = 1
# urgent = Workspace with urgency hint set
label-urgent = %icon% %index%
label-urgent-background = ${colors.red}
label-urgent-padding = 1
#+END_SRC
* Music using MPD
#+BEGIN_SRC conf
[module/mpd]
type = internal/mpd
format-online = <toggle> %{A1:$TERMINAL -e tmux new-session -A -s ncmpcpp ncmpcpp:}<label-song>%{A}
format-online-spacing = 0
format-online-padding = 0
label-offline = mpd is offline
format-offline = <label-offline>
format-offline-foreground = #777
label-song = %artist% - %title%
label-song-maxlen = 30
label-song-ellipsis = true
icon-prev = 󰒮
icon-stop = 
icon-play = 
icon-pause = 
icon-next = 󰒭
icon-random = 
icon-repeat = 
# Used to display the state of random/repeat/repeatone/single
# Only applies if <icon-[random|repeat|repeatone|single]> is used
toggle-on-foreground = ${colors.fg}
toggle-off-foreground = ${colors.gray}
bar-progress-width = 15
bar-progress-indicator = |
bar-progress-fill = ─
bar-progress-empty = ─
#+END_SRC
* Backlight level
#+BEGIN_SRC conf
[module/xbacklight]
type = internal/xbacklight
format = <ramp>
ramp-0 = 
ramp-1 = 
ramp-2 = 
ramp-3 = 
ramp-4 = 
ramp-5 = 
ramp-6 = 
ramp-7 = 
ramp-8 = 
ramp-9 = 
ramp-10 = 
ramp-11 = 
#+END_SRC
* CPU Usage
#+BEGIN_SRC conf
[module/cpu]
type = internal/cpu
interval = 2
format-prefix-foreground = ${colors.fg}
format-underline = ${colors.bg}
label = %{A1:$TERMINAL -e htop &:} %percentage:2%%%{A}
#+END_SRC
* Date
#+BEGIN_SRC conf
[module/date]
type = internal/date
interval = 1
# Open google calendar on left right
date = %{A1:$TERMINAL --title khal -e ikhal &:} %d-%m%{A}
date-alt = "%{A1:$TERMINAL --title khal -e ikhal &:} %d-%m-%Y%{A}"
time =  %H:%M
time-alt =  %H:%M:%S
label = %date% %time%
#+END_SRC
* Sound Volume
#+BEGIN_SRC conf
[module/pulseaudio]
type = internal/pulseaudio
sink = alsa_output.pci-0000_00_1f.3-platform-sof_sdw.HiFi__hw_sofsoundwire_2__sink
# Open pavucontrol on left right
format-volume =%{A1:pavucontrol &:}<label-volume> <bar-volume>%{A}
label-volume = %percentage%%
label-volume-foreground = ${root.foreground}
label-muted =  muted
bar-volume-width = 10
bar-volume-foreground-0 = ${colors.green}
bar-volume-foreground-1 = ${colors.green}
bar-volume-foreground-2 = ${colors.blue}
bar-volume-foreground-3 = ${colors.blue}
bar-volume-foreground-4 = ${colors.red}
bar-volume-foreground-5 = ${colors.red}
bar-volume-foreground-6 = ${colors.red}
bar-volume-gradient = false
bar-volume-indicator = |
bar-volume-indicator-font = 2
bar-volume-fill = ─
bar-volume-fill-font = 2
bar-volume-empty = ─
bar-volume-empty-font = 2
bar-volume-empty-foreground = ${colors.fg}
#+END_SRC
* Battery
#+BEGIN_SRC conf
[module/battery]
type = internal/battery
battery = BAT0
adapter = AC
full-at = 95
format-charging = %{A1:xfce4-power-manager-settings &:}<ramp-capacity> <label-charging>%{A}
format-charging-underline = ${colors.blue}
format-discharging = %{A1:xfce4-power-manager-settings &:}<ramp-capacity> <label-discharging>%{A}
format-discharging-underline = ${colors.red}
label-full = %{A1:xfce4-power-manager-settings &:} %{A}
format-full-underline = ${colors.bg}
ramp-capacity-0 = 
ramp-capacity-1 = 
ramp-capacity-2 = 
ramp-capacity-3 = 
ramp-capacity-4 = 
#+END_SRC
* Temperature
#+begin_src conf
[module/temperature]
type = internal/temperature
interval = 2
thermal-zone = 0
base-temperature = 50
warn-temperature = 80
hwmon-path = /sys/class/thermal/thermal_zone10/temp
units = false
format = %{A1:$TERMINAL --title="Sensors" -e watch sensors &:}<ramp> <label>%{A}
format-warn = <ramp> <label-warn>
label = %temperature-c%°C
label-warn = %temperature-c%°C
label-warn-foreground = ${colors.fg}
format-warn-underline = ${colors.red}
ramp-0 = 
ramp-1 = 
ramp-2 = 
ramp-3 = 
ramp-4 = 
ramp-foreground = ${colors.fg}
#+end_src
* Unread Mails
** Module
#+BEGIN_SRC conf
[module/unread_mail]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.config/polybar/scripts/mail-open.sh >/dev/null 2>%1 &
click-right = ~/.config/polybar/scripts/mail-refresh.sh >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/mail-status.sh
interval = 2
#+END_SRC
** Unread Mail Scripts
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/mail-status.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
mail_nb=`du -a ~/.local/share/mails/*/Inbox/new/* 2>/dev/null | wc -l`
if [ "$mail_nb" -eq "0" ]; then
echo "";
else
echo "%{F#859900} $mail_nb%{F-}";
fi
#+end_src
** Refresh Mail Scripts
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/mail-refresh.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
dunstify --replace=98465 "Mails " "Syncing...";
checkmail -q && \
mail_nb=`du -a ~/.local/share/mails/*/Inbox/new/* 2>/dev/null | wc -l` && \
if [ "$mail_nb" -eq "0" ]; then
dunstify --replace=98465 "Mails " "No new mail";
fi
#+end_src
** Open Mails
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/mail-open.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
$TERMINAL -e tmux new-session -A -s neomutt neomutt
#+end_src
* Calendar
** Module
#+BEGIN_SRC conf
[module/calendar]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.config/polybar/scripts/calendar-open.sh >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/calendar-status.sh
interval = 5
#+END_SRC
** Calendar Status Scripts
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/calendar-status.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
next_events=$(khal list "$(date +"%H:%M")" 23:59 --format "{start-time} - {title}" -df 'SKIPME' | grep -v 'SKIPME' | grep -v 'No events')
cal_icon=""
cal_nb=""
cal_desc=""
if [ -n "$next_events" ]; then
events_number="$(echo "$next_events" | wc -l)"
if [ "$events_number" -gt "1" ]; then
cal_nb=" ($events_number)"
fi
next_timed_events=$(echo "$next_events" | sed -e '/^[^0-9]/d')
if [ -z "$next_timed_events" ]; then
# Only full day events
cal_desc=" $(echo "$next_events" | sed -e '/^[0-9]/d;s/^ - //' | head -n 1 | cut -c 1-15)"
else
cal_desc=" $(echo "$next_timed_events" | head -n 1 | cut -c 1-20)"
fi
fi
echo "${cal_icon}${cal_nb}${cal_desc}"
#+end_src
** Open Calendar
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/calendar-open.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
$TERMINAL --title=khal -e ikhal
#+end_src
* Redshift
** Module
#+BEGIN_SRC conf
[module/redshift]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.config/polybar/scripts/redshift-toggle.sh >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/redshift-status.sh
interval = 2
#+END_SRC
** Redshift - Status
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/redshift-status.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
if pgrep -x "redshift" >/dev/null; then
echo "";
else
echo "󰖨";
fi
#+end_src
** Toggle Redshift
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/redshift-toggle.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
if pgrep -x "redshift" >/dev/null; then
killall redshift && \
dunstify --replace=36492 "Redshift " "Turned off";
else
nohup redshift > /dev/null 2>&1 &
dunstify --replace=36492 "Redshift " "Starting...";
fi
#+end_src
* Dunst
** Module
#+BEGIN_SRC conf
[module/dunst]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.config/polybar/scripts/dunst-toggle.sh >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/dunst-status.sh
interval = 2
#+END_SRC
** Dunst Status script
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/dunst-status.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+BEGIN_SRC bash
tmpfile="/tmp/dunststatus";
if [ -f $tmpfile ]; then
if grep -q "on" $tmpfile; then
echo "";
elif grep -q "off" $tmpfile; then
echo "";
fi
else
echo "";
fi
#+END_SRC
** Dunst Toggle
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/dunst-toggle.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+BEGIN_SRC bash
tmpfile="/tmp/dunststatus";
if [ -f $tmpfile ] && grep -q "off" $tmpfile ; then
killall -SIGUSR2 dunst && \
echo "on" > $tmpfile;
dunstify --replace=16549 "Notifications " "Activated";
else
dunstify --replace=16549 "Notifications " "Deactivated";
sleep 1 && \
killall -SIGUSR1 dunst && \
echo "off" > $tmpfile;
fi
#+END_SRC
* Lock Screen
** Module
#+BEGIN_SRC conf
[module/lockscreen]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.config/polybar/scripts/lockscreen-toggle.sh >/dev/null 2>%1 &
click-right = ~/.local/bin/lockscreen >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/lockscreen-status.sh
interval = 2
#+END_SRC
** Lock screen Status script
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/lockscreen-status.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+BEGIN_SRC bash
if pgrep -x "xautolock" >/dev/null
then
echo "";
else
echo "";
fi
#+END_SRC
** Toggle Automatic Lock Screen
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/lockscreen-toggle.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
if pgrep -x "xautolock" >/dev/null ; then
pkill xautolock && \
dunstify --replace=13602 'Lock Screen ' 'Desactivated'
else
xautolock -locker "~/.local/bin/lockscreen" -detectsleep -time 30 -notify 60 -notifier "dunstify --replace=31846 -u critical -t 10000 -- 'Locking Screen' '60 seconds'" &
dunstify --replace=13602 'Lock Screen ' 'Activated'
fi
#+end_src
* Network
** Modules
#+begin_src conf
[module/wired-network]
type = internal/network
interface = enp57s0u2u4u4
label-connected = %{A3:bash ~/.config/polybar/scripts/connection-manager.sh >/dev/null 2>%1 &:}%{A1:bash ~/.config/polybar/scripts/connection-toggle.sh enp57s0u2u4u4 >/dev/null 2>%1 &:} %local_ip%%{A}%{A}
label-connected-foreground = ${colors.fg}
label-disconnected = %{A3:bash ~/.config/polybar/scripts/connection-manager.sh >/dev/null 2>%1 &:}%{A1:bash ~/.config/polybar/scripts/connection-toggle.sh enp57s0u2u4u4 >/dev/null 2>%1 &:}%{A}%{A}
label-disconnected-foreground = #777
#+end_src
#+begin_src conf
[module/wireless-network]
type = internal/network
interface = wlp2s0
format-connected = <label-connected>
format-disconnected = <label-disconnected>
label-connected = %{A3:bash ~/.config/polybar/scripts/connection-manager.sh >/dev/null 2>%1 &:}%{A1:bash ~/.config/polybar/scripts/connection-toggle.sh wlp2s0 >/dev/null 2>%1 &:}直 %essid%%{A}%{A}
label-connected-foreground = ${colors.fg}
label-disconnected = %{A3:bash ~/.config/polybar/scripts/connection-manager.sh >/dev/null 2>%1 &:}%{A1:bash ~/.config/polybar/scripts/connection-toggle.sh wlp2s0 >/dev/null 2>%1 &:}直%{A}%{A}
label-disconnected-foreground = #777
#+end_src
** Run Network Manager
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/connection-manager.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
$TERMINAL -e sudo nmtui
#+end_src
** Toggle Wifi or Ethernet
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/connection-toggle.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
# Check if an argument is passed
if [ -z "$1" ]
then
exit 1
fi
isdevicedown=$(nmcli device status | grep ^$1 | grep disconnected)
if [ -z "$isdevicedown" ]
then
dunstify --replace=84847 "$1" "Disconnecting..." && \
nmcli device disconnect $1 && \
dunstify --replace=84847 "$1" "Disconnected"
else
dunstify --replace=84847 "$1" "Connection..." && \
nmcli device connect $1 && \
dunstify --replace=84847 "$1" "Connected"
fi
#+end_src
* Bluetooth
** Module
#+BEGIN_SRC conf
[module/bluetooth]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.config/polybar/scripts/bluetooth-toggle.sh >/dev/null 2>%1 &
click-right = ~/.config/polybar/scripts/bluetooth-run.sh >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/bluetooth-status.sh
interval = 2
#+END_SRC
** =bluetooth-run.sh= - Bluetooth Run Manager
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/bluetooth-run.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
blueman-manager && pkill blueman-applet
#+end_src
** =bluetooth-status.sh= - Bluetooth Connection Status
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/bluetooth-status.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
controllerid="9C:B6:D0:96:6E:C0"
isconnected=$(bluetoothctl show $controllerid | grep Powered | grep yes)
if [ -z "$isconnected" ]
then
echo ""
else
echo "%{F#859900}%{F-}"
fi
#+end_src
** =bluetooth-toggle.sh= - Toggle Bluetooth Connection
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/bluetooth-toggle.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
controllerid="9C:B6:D0:96:6E:C0"
isconnected=$(bluetoothctl show $controllerid | grep Powered | grep yes)
if [ -z "$isconnected" ]
then
bluetoothctl power on && \
dunstify --replace=88498 "Bluetooth" "Power ON"
else
bluetoothctl power off && \
dunstify --replace=88498 "Bluetooth" "Power OFF"
fi
#+end_src
* NordVPN
** Module
#+BEGIN_SRC conf
[module/nordvpn]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.local/bin/nordvpn-toggle >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/nordvpn-status.sh
interval = 2
#+END_SRC
** Nordvpn Status script
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/nordvpn-status.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+BEGIN_SRC bash
tmpfile="/tmp/vpnstatus";
if [ -f $tmpfile ] && grep -q "on" $tmpfile; then
echo "%{F#859900}󰲀%{F-}";
else
echo "󰲀";
fi
#+END_SRC
** Nordvpn Toggle
The script is accessible [[file:binaries.org::#nordvpn-toggle][here]].
* Wireguard
** Module
#+BEGIN_SRC conf
[module/wireguard]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.config/polybar/scripts/wireguard-toggle.sh >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/wireguard-status.sh
interval = 2
#+END_SRC
** Wireguard Connection Status
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/wireguard-status.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
config="homelab"
connection=$(sudo wg show "$config" 2>/dev/null | head -n 1 | awk '{print $NF }')
if [ "$connection" = "$config" ]; then
echo "%{F#859900}󰒄%{F-}"
else
echo "󰒄"
fi
#+end_src
** Toggle Wireguard Connection
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/wireguard-toggle.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
config="homelab"
connection=$(sudo wg show "$config" 2>/dev/null | head -n 1 | awk '{print $NF }')
if [ "$connection" = "$config" ]; then
sudo wg-quick down "$config" && \
dunstify --replace=83244 "Wireguard" "Disconnected from $config"
else
sudo wg-quick up "$config" && \
dunstify --replace=83244 "Wireguard" "Connected to $config"
fi
#+end_src
* Highlight cursor
** Module
#+BEGIN_SRC conf
[module/cursor]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.config/polybar/scripts/cursor-toggle.sh >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/cursor-status.sh
interval = 2
#+END_SRC
** Cursor - Status
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/cursor-status.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
if pgrep -x "highlight-point" >/dev/null; then
echo "%{F#859900}%{F-}";
else
echo "";
fi
#+end_src
** Toggle Cursor
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/cursor-toggle.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
if pgrep -x "highlight-point" >/dev/null; then
killall highlight-pointer && \
dunstify --replace=22111 --hint=string:x-dunst-stack-tag:kidF4g53 "Cursor" "Turned off";
else
nohup highlight-pointer -r 10 > /dev/null 2>&1 &
dunstify --replace=22111 --hint=string:x-dunst-stack-tag:kidF4g53 "Cursor" "Highlight...";
fi
#+end_src
* Mounted Drives
** Modules
#+BEGIN_SRC conf
[module/drive_tmp]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.local/bin/mount-dir tmp_14_days >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/drive-status.sh tmp_14_days T
interval = 5
#+END_SRC
#+BEGIN_SRC conf
[module/drive_groupshare]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.local/bin/mount-dir groupshare >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/drive-status.sh groupshare G
interval = 5
#+END_SRC
#+BEGIN_SRC conf
[module/drive_homelab]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.local/bin/mount-dir homelab >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/drive-status.sh homelab H
interval = 5
#+END_SRC
#+BEGIN_SRC conf
[module/drive_unix_home]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.local/bin/mount-dir unix_home >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/drive-status.sh unix_home U
interval = 5
#+END_SRC
#+BEGIN_SRC conf
[module/drive_monochromator]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.local/bin/mount-dir monochromators >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/drive-status.sh monochromators M
interval = 5
#+END_SRC
#+BEGIN_SRC conf
[module/drive_data_id21]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.local/bin/mount-dir data_id21 >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/drive-status.sh data_id21 D
interval = 5
#+END_SRC
** Drive - Status
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/drive-status.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
if mountpoint -q ~/mnt/$1; then
echo "%{F#859900}$2 󰡰%{F-}";
else
echo "$2 󰲁";
fi
#+end_src
* Tunnel Status
** Module
#+BEGIN_SRC conf
[module/tunnel_esrf]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.config/polybar/scripts/systemd-service-toggle.sh esrf-tunnel E >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/systemd-service-status.sh esrf-tunnel E
interval = 2
#+END_SRC
#+BEGIN_SRC conf
[module/tunnel_homelab]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.config/polybar/scripts/systemd-service-toggle.sh homelab-tunnel H >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/systemd-service-status.sh homelab-tunnel H
interval = 2
#+END_SRC
** Tunnel - Status
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/systemd-service-status.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
SERVICE_NAME="$1"
if [ "$(systemctl --user is-active "$SERVICE_NAME")" != "active" ]
then
echo "$2 󰢭";
else
echo "%{F#859900}$2 󰢭%{F-}";
fi
#+end_src
** Tunnel - Toggle
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/systemd-service-toggle.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
SERVICE_NAME="$1"
if [ "$(systemctl --user is-active $SERVICE_NAME)" != "active" ]
then
systemctl --user start $SERVICE_NAME
else
systemctl --user stop $SERVICE_NAME
fi
#+end_src
* Timer
** Module
#+BEGIN_SRC conf
[module/timer]
type = custom/script
format = <label>
exec = ~/.config/polybar/scripts/timer.sh tail 'TIMER' 5
tail = true
click-left = ~/.config/polybar/scripts/timer.sh new 25 'Pomo session' 'Paused' 'notify-send "Session finished"' ; ~/.config/polybar/scripts/timer.sh update %pid%
click-middle = ~/.config/polybar/scripts/timer.sh cancel ; ~/.config/polybar/scripts/timer.sh update %pid%
click-right = ~/.config/polybar/scripts/timer.sh togglepause ; ~/.config/polybar/scripts/timer.sh update %pid%
scroll-up = ~/.config/polybar/scripts/timer.sh increase 60 || ~/.config/polybar/scripts/timer.sh new 1 'TIMER' 'PAUSED' 'notify-send -u critical "Timer expired."' ; ~/.config/polybar/scripts/timer.sh update %pid%
scroll-down = ~/.config/polybar/scripts/timer.sh increase -60 ; ~/.config/polybar/scripts/timer.sh update %pid%
interval = 2
#+END_SRC
** Timer
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/timer.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
### AUTHOR: Johann Birnick (github: jbirnick)
### PROJECT REPO: https://github.com/jbirnick/polybar-timer
## FUNCTIONS
now () { date --utc +%s; }
killTimer () { rm -rf /tmp/polybar-timer ; }
timerSet () { [ -e /tmp/polybar-timer/ ] ; }
timerPaused () { [ -f /tmp/polybar-timer/paused ] ; }
timerExpiry () { cat /tmp/polybar-timer/expiry ; }
timerLabelRunning () { cat /tmp/polybar-timer/label_running ; }
timerLabelPaused () { cat /tmp/polybar-timer/label_paused ; }
timerAction () { cat /tmp/polybar-timer/action ; }
secondsLeftWhenPaused () { cat /tmp/polybar-timer/paused ; }
minutesLeftWhenPaused () { echo $(( ( $(secondsLeftWhenPaused) + 59 ) / 60 )) ; }
secondsLeft () { echo $(( $(timerExpiry) - $(now) )) ; }
minutesLeft () { echo $(( ( $(secondsLeft) + 59 ) / 60 )) ; }
printExpiryTime () { dunstify -u low -r -12345 "Timer expires at $( date -d "$(secondsLeft) sec" +%H:%M)" ;}
printPaused () { dunstify -u low -r -12345 "Timer paused" ; }
removePrinting () { dunstify -C -12345 ; }
updateTail () {
# check whether timer is expired
if timerSet
then
if { timerPaused && [ $(minutesLeftWhenPaused) -le 0 ] ; } || { ! timerPaused && [ $(minutesLeft) -le 0 ] ; }
then
eval $(timerAction)
killTimer
removePrinting
fi
fi
# update output
if timerSet
then
if timerPaused
then
echo "$(timerLabelPaused) $(minutesLeftWhenPaused)"
else
echo "$(timerLabelRunning) $(minutesLeft)"
fi
else
echo "${STANDBY_LABEL}"
fi
}
## MAIN CODE
case $1 in
tail)
STANDBY_LABEL=$2
trap updateTail USR1
while true
do
updateTail
sleep ${3} &
wait
done
;;
update)
kill -USR1 $(pgrep --oldest --parent ${2})
;;
new)
killTimer
mkdir /tmp/polybar-timer
echo "$(( $(now) + 60*${2} ))" > /tmp/polybar-timer/expiry
echo "${3}" > /tmp/polybar-timer/label_running
echo "${4}" > /tmp/polybar-timer/label_paused
echo "${5}" > /tmp/polybar-timer/action
printExpiryTime
;;
increase)
if timerSet
then
if timerPaused
then
echo "$(( $(secondsLeftWhenPaused) + ${2} ))" > /tmp/polybar-timer/paused
else
echo "$(( $(timerExpiry) + ${2} ))" > /tmp/polybar-timer/expiry
printExpiryTime
fi
else
exit 1
fi
;;
cancel)
killTimer
removePrinting
;;
togglepause)
if timerSet
then
if timerPaused
then
echo "$(( $(now) + $(secondsLeftWhenPaused) ))" > /tmp/polybar-timer/expiry
rm -f /tmp/polybar-timer/paused
printExpiryTime
else
secondsLeft > /tmp/polybar-timer/paused
rm -f /tmp/polybar-timer/expiry
printPaused
fi
else
exit 1
fi
;;
*)
echo "Please read the manual at https://github.com/jbirnick/polybar-timer ."
;;
esac
#+end_src
* Screenshot
#+BEGIN_SRC conf
[module/screenshot]
type = custom/text
content = ""
click-left = ~/.local/bin/screenshot >/dev/null 2>%1 &
#+END_SRC