update theme
This commit is contained in:
480
polybar.org
480
polybar.org
@@ -52,7 +52,7 @@ line-size = 2
|
||||
border-size = 0
|
||||
|
||||
padding-left = 2
|
||||
padding-right = 12
|
||||
padding-right = 16
|
||||
|
||||
module-margin-left = 1
|
||||
module-margin-right = 1
|
||||
@@ -62,7 +62,7 @@ font-1 = unifont:fontformat=truetype:size=8:antialias=false;0
|
||||
|
||||
modules-left = i3 xwindow
|
||||
modules-center =
|
||||
modules-right = pulseaudio drive_monochromator drive_tmp drive_homelab drive_groupshare drive_data_id21 drive_unix_home dunst cursor unread_mail calendar battery date
|
||||
modules-right = mpd pulseaudio tunnel_homelab tunnel_esrf dunst cursor unread_mail calendar timer battery date
|
||||
|
||||
# wm-restack = i3
|
||||
|
||||
@@ -128,7 +128,7 @@ label-urgent-padding = 1
|
||||
#+BEGIN_SRC conf
|
||||
[module/mpd]
|
||||
type = internal/mpd
|
||||
format-online = <icon-prev> <toggle> <icon-next> %{A1:$TERMINAL -e ncmpcpp &:}<label-song>%{A}
|
||||
format-online = <toggle> %{A1:$TERMINAL -e tmux new-session -A -s ncmpcpp ncmpcpp:}<label-song>%{A}
|
||||
|
||||
format-online-spacing = 0
|
||||
format-online-padding = 0
|
||||
@@ -141,13 +141,13 @@ 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 = 凌
|
||||
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
|
||||
@@ -189,7 +189,7 @@ interval = 2
|
||||
format-prefix-foreground = ${colors.fg}
|
||||
format-underline = ${colors.bg}
|
||||
|
||||
label = %{A1:$TERMINAL -e htop &:} %percentage:2%%%{A}
|
||||
label = %{A1:$TERMINAL -e htop &:} %percentage:2%%%{A}
|
||||
#+END_SRC
|
||||
|
||||
* Date
|
||||
@@ -221,7 +221,7 @@ format-volume =%{A1:pavucontrol &:}<label-volume> <bar-volume>%{A}
|
||||
label-volume = %percentage%%
|
||||
label-volume-foreground = ${root.foreground}
|
||||
|
||||
label-muted = ﱝ muted
|
||||
label-muted = muted
|
||||
|
||||
bar-volume-width = 10
|
||||
bar-volume-foreground-0 = ${colors.green}
|
||||
@@ -291,6 +291,7 @@ ramp-foreground = ${colors.fg}
|
||||
#+end_src
|
||||
|
||||
* Unread Mails
|
||||
** Module
|
||||
#+BEGIN_SRC conf
|
||||
[module/unread_mail]
|
||||
type = custom/script
|
||||
@@ -310,12 +311,12 @@ interval = 2
|
||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||
:END:
|
||||
#+begin_src bash
|
||||
mail_nb=`du -a ~/.mail/*/Inbox/new/* 2>/dev/null | wc -l`
|
||||
mail_nb=`du -a ~/.local/share/mails/*/Inbox/new/* 2>/dev/null | wc -l`
|
||||
|
||||
if [ "$mail_nb" -eq "0" ]; then
|
||||
echo "";
|
||||
echo "";
|
||||
else
|
||||
echo "%{F#859900} $mail_nb%{F-}";
|
||||
echo "%{F#859900} $mail_nb%{F-}";
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
@@ -326,11 +327,11 @@ fi
|
||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||
:END:
|
||||
#+begin_src bash
|
||||
notify-send --hint=string:x-dunst-stack-tag:YpqAgorv "Mails " "Syncing...";
|
||||
dunstify --replace=98465 "Mails " "Syncing...";
|
||||
checkmail -q && \
|
||||
mail_nb=`du -a ~/.mail/*/Inbox/new/* 2>/dev/null | wc -l` && \
|
||||
mail_nb=`du -a ~/.local/share/mails/*/Inbox/new/* 2>/dev/null | wc -l` && \
|
||||
if [ "$mail_nb" -eq "0" ]; then
|
||||
notify-send --hint=string:x-dunst-stack-tag:YpqAgorv "Mails " "No new mail";
|
||||
dunstify --replace=98465 "Mails " "No new mail";
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
@@ -344,65 +345,8 @@ checkmail -q && \
|
||||
$TERMINAL -e tmux new-session -A -s neomutt neomutt
|
||||
#+end_src
|
||||
|
||||
* Unread News
|
||||
#+BEGIN_SRC conf
|
||||
[module/unread_news]
|
||||
type = custom/script
|
||||
|
||||
format-underline = ${colors.bg}
|
||||
click-left = ~/.config/polybar/scripts/news-open.sh >/dev/null 2>%1 &
|
||||
click-right = ~/.config/polybar/scripts/news-refresh.sh >/dev/null 2>%1 &
|
||||
format = <label>
|
||||
exec = ~/.config/polybar/scripts/news-status.sh
|
||||
interval = 60
|
||||
#+END_SRC
|
||||
|
||||
** Unread News Scripts
|
||||
:PROPERTIES:
|
||||
:header-args: :tangle ~/.config/polybar/scripts/news-status.sh
|
||||
:header-args+: :comments both :mkdirp yes
|
||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||
:END:
|
||||
#+begin_src bash
|
||||
news_nb=`newsboat -x print-unread 2>/dev/null | cut -d " " -f1`
|
||||
|
||||
if [ -z "$news_nb" ] || [ "$news_nb" -eq "0" ]; then
|
||||
echo "";
|
||||
else
|
||||
echo "%{F#859900} $news_nb%{F-}";
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
** Refresh News Scripts
|
||||
:PROPERTIES:
|
||||
:header-args: :tangle ~/.config/polybar/scripts/news-refresh.sh
|
||||
:header-args+: :comments both :mkdirp yes
|
||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||
:END:
|
||||
#+begin_src bash
|
||||
notify-send --hint=string:x-dunst-stack-tag:4z5CvV6G "Newsboat " "Reloading...";
|
||||
|
||||
if pgrep -x "newsboat" >/dev/null; then
|
||||
# If newsboat is already running, try to refresh in the tmux session
|
||||
tmux send-keys -t newsboat R
|
||||
else
|
||||
newsboat -x reload && /
|
||||
news_nb=`newsboat -x print-unread | cut -d " " -f1` && \
|
||||
notify-send --hint=string:x-dunst-stack-tag:4z5CvV6G "Newsboat " "$news_nb Unread News";
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
** Open Newsboat
|
||||
:PROPERTIES:
|
||||
:header-args: :tangle ~/.config/polybar/scripts/news-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 newsboat newsboat
|
||||
#+end_src
|
||||
|
||||
* Calendar
|
||||
** Module
|
||||
#+BEGIN_SRC conf
|
||||
[module/calendar]
|
||||
type = custom/script
|
||||
@@ -458,6 +402,7 @@ $TERMINAL --title=khal -e ikhal
|
||||
#+end_src
|
||||
|
||||
* Redshift
|
||||
** Module
|
||||
#+BEGIN_SRC conf
|
||||
[module/redshift]
|
||||
type = custom/script
|
||||
@@ -477,9 +422,9 @@ interval = 2
|
||||
:END:
|
||||
#+begin_src bash
|
||||
if pgrep -x "redshift" >/dev/null; then
|
||||
echo "望";
|
||||
echo "";
|
||||
else
|
||||
echo "盛";
|
||||
echo "";
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
@@ -492,76 +437,15 @@ fi
|
||||
#+begin_src bash
|
||||
if pgrep -x "redshift" >/dev/null; then
|
||||
killall redshift && \
|
||||
notify-send --hint=string:x-dunst-stack-tag:EKFLpst1 "Redshift 望" "Turned off";
|
||||
dunstify --replace=36492 "Redshift " "Turned off";
|
||||
else
|
||||
nohup redshift > /dev/null 2>&1 &
|
||||
notify-send --hint=string:x-dunst-stack-tag:EKFLpst1 "Redshift 望" "Starting...";
|
||||
dunstify --replace=36492 "Redshift " "Starting...";
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
* Packages
|
||||
#+BEGIN_SRC conf
|
||||
[module/packages]
|
||||
type = custom/script
|
||||
|
||||
format-underline = ${colors.bg}
|
||||
click-left = ~/.config/polybar/scripts/packages-update.sh >/dev/null 2>%1 &
|
||||
click-right = ~/.config/polybar/scripts/packages-refresh.sh >/dev/null 2>%1 &
|
||||
format = <label>
|
||||
exec = ~/.config/polybar/scripts/packages-status.sh
|
||||
interval = 600
|
||||
#+END_SRC
|
||||
|
||||
** Packages Status script
|
||||
:PROPERTIES:
|
||||
:header-args: :tangle ~/.config/polybar/scripts/packages-status.sh
|
||||
:header-args+: :comments both :mkdirp yes
|
||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||
:END:
|
||||
#+BEGIN_SRC bash
|
||||
paru -Sy > /dev/null 2>&1 && \
|
||||
package_nb=`paru -Qu 2> /dev/null | wc -l` || \
|
||||
package_nb=0
|
||||
|
||||
|
||||
if [ "$package_nb" -eq "0" ]; then
|
||||
echo "";
|
||||
else
|
||||
echo "%{F#859900} $package_nb%{F-}";
|
||||
fi
|
||||
#+END_SRC
|
||||
|
||||
** Refresh New Packages script
|
||||
:PROPERTIES:
|
||||
:header-args: :tangle ~/.config/polybar/scripts/packages-refresh.sh
|
||||
:header-args+: :comments both :mkdirp yes
|
||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||
:END:
|
||||
#+BEGIN_SRC bash
|
||||
notify-send --hint=string:x-dunst-stack-tag:SE5nDEVA 'Packages ' "Refreshing..."
|
||||
|
||||
paru -Sy > /dev/null 2>&1 && \
|
||||
package_nb=$(paru -Qu 2> /dev/null | wc -l) || \
|
||||
package_nb=0
|
||||
|
||||
if [ "$package_nb" -eq "0" ]; then
|
||||
notify-send --hint=string:x-dunst-stack-tag:SE5nDEVA 'Packages ' "No upgrade available"
|
||||
else
|
||||
notify-send --hint=string:x-dunst-stack-tag:SE5nDEVA 'Packages ' "$package_nb upgrade(s) available"
|
||||
fi
|
||||
#+END_SRC
|
||||
|
||||
** Packages Update
|
||||
:PROPERTIES:
|
||||
:header-args: :tangle ~/.config/polybar/scripts/packages-update.sh
|
||||
:header-args+: :comments both :mkdirp yes
|
||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||
:END:
|
||||
#+BEGIN_SRC bash
|
||||
$TERMINAL -e paru
|
||||
#+END_SRC
|
||||
|
||||
* Dunst
|
||||
** Module
|
||||
#+BEGIN_SRC conf
|
||||
[module/dunst]
|
||||
type = custom/script
|
||||
@@ -605,9 +489,9 @@ tmpfile="/tmp/dunststatus";
|
||||
if [ -f $tmpfile ] && grep -q "off" $tmpfile ; then
|
||||
killall -SIGUSR2 dunst && \
|
||||
echo "on" > $tmpfile;
|
||||
notify-send --hint=string:x-dunst-stack-tag:KLJ63nVo "Notifications " "Activated";
|
||||
dunstify --replace=16549 "Notifications " "Activated";
|
||||
else
|
||||
notify-send --hint=string:x-dunst-stack-tag:KLJ63nVo "Notifications " "Deactivated";
|
||||
dunstify --replace=16549 "Notifications " "Deactivated";
|
||||
sleep 1 && \
|
||||
killall -SIGUSR1 dunst && \
|
||||
echo "off" > $tmpfile;
|
||||
@@ -615,6 +499,7 @@ fi
|
||||
#+END_SRC
|
||||
|
||||
* Lock Screen
|
||||
** Module
|
||||
#+BEGIN_SRC conf
|
||||
[module/lockscreen]
|
||||
type = custom/script
|
||||
@@ -653,14 +538,15 @@ fi
|
||||
#+begin_src bash
|
||||
if pgrep -x "xautolock" >/dev/null ; then
|
||||
pkill xautolock && \
|
||||
notify-send --hint=string:x-dunst-stack-tag:tH6bxvvv 'Lock Screen ' 'Desactivated'
|
||||
dunstify --replace=13602 'Lock Screen ' 'Desactivated'
|
||||
else
|
||||
xautolock -locker "~/.local/bin/lockscreen" -detectsleep -time 30 -notify 60 -notifier "notify-send -u --hint=string:x-dunst-stack-tag:tH6bxvvv critical -t 10000 -- 'Locking Screen' '60 seconds'" &
|
||||
notify-send --hint=string:x-dunst-stack-tag:tH6bxvvv 'Lock Screen ' 'Activated'
|
||||
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
|
||||
@@ -717,17 +603,18 @@ isdevicedown=$(nmcli device status | grep ^$1 | grep disconnected)
|
||||
|
||||
if [ -z "$isdevicedown" ]
|
||||
then
|
||||
notify-send --hint=string:x-dunst-stack-tag:EfjAHGgu "$1" "Disconnecting..." && \
|
||||
dunstify --replace=84847 "$1" "Disconnecting..." && \
|
||||
nmcli device disconnect $1 && \
|
||||
notify-send --hint=string:x-dunst-stack-tag:EfjAHGgu "$1" "Disconnected"
|
||||
dunstify --replace=84847 "$1" "Disconnected"
|
||||
else
|
||||
notify-send --hint=string:x-dunst-stack-tag:EfjAHGgu "$1" "Connection..." && \
|
||||
dunstify --replace=84847 "$1" "Connection..." && \
|
||||
nmcli device connect $1 && \
|
||||
notify-send --hint=string:x-dunst-stack-tag:EfjAHGgu "$1" "Connected"
|
||||
dunstify --replace=84847 "$1" "Connected"
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
* Bluetooth
|
||||
** Module
|
||||
#+BEGIN_SRC conf
|
||||
[module/bluetooth]
|
||||
type = custom/script
|
||||
@@ -766,7 +653,7 @@ isconnected=$(bluetoothctl show $controllerid | grep Powered | grep yes)
|
||||
|
||||
if [ -z "$isconnected" ]
|
||||
then
|
||||
echo ""
|
||||
echo ""
|
||||
else
|
||||
echo "%{F#859900}%{F-}"
|
||||
fi
|
||||
@@ -787,14 +674,15 @@ isconnected=$(bluetoothctl show $controllerid | grep Powered | grep yes)
|
||||
if [ -z "$isconnected" ]
|
||||
then
|
||||
bluetoothctl power on && \
|
||||
notify-send --hint=string:x-dunst-stack-tag:kidF4g53 "Bluetooth" "Power ON"
|
||||
dunstify --replace=88498 "Bluetooth" "Power ON"
|
||||
else
|
||||
bluetoothctl power off && \
|
||||
notify-send --hint=string:x-dunst-stack-tag:kidF4g53 "Bluetooth" "Power OFF"
|
||||
dunstify --replace=88498 "Bluetooth" "Power OFF"
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
* NordVPN
|
||||
** Module
|
||||
#+BEGIN_SRC conf
|
||||
[module/nordvpn]
|
||||
type = custom/script
|
||||
@@ -817,9 +705,9 @@ interval = 2
|
||||
tmpfile="/tmp/vpnstatus";
|
||||
|
||||
if [ -f $tmpfile ] && grep -q "on" $tmpfile; then
|
||||
echo "%{F#859900}%{F-}";
|
||||
echo "%{F#859900}%{F-}";
|
||||
else
|
||||
echo "";
|
||||
echo "";
|
||||
fi
|
||||
#+END_SRC
|
||||
|
||||
@@ -827,9 +715,62 @@ fi
|
||||
|
||||
The script is accessible [[file:binaries.org::#nordvpn-toggle][here]].
|
||||
|
||||
* High cursor
|
||||
This is using this program: module/
|
||||
* 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
|
||||
@@ -850,9 +791,9 @@ interval = 2
|
||||
:END:
|
||||
#+begin_src bash
|
||||
if pgrep -x "highlight-point" >/dev/null; then
|
||||
echo "%{F#859900}%{F-}";
|
||||
echo "%{F#859900}%{F-}";
|
||||
else
|
||||
echo "";
|
||||
echo "";
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
@@ -864,16 +805,16 @@ fi
|
||||
:END:
|
||||
#+begin_src bash
|
||||
if pgrep -x "highlight-point" >/dev/null; then
|
||||
killall highlight-point && \
|
||||
notify-send --hint=string:x-dunst-stack-tag:kidF4g53 "Cursor" "Turned off";
|
||||
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 &
|
||||
notify-send --hint=string:x-dunst-stack-tag:kidF4g53 "Cursor" "Highlight...";
|
||||
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
|
||||
@@ -954,18 +895,223 @@ interval = 5
|
||||
:END:
|
||||
#+begin_src bash
|
||||
if mountpoint -q ~/mnt/$1; then
|
||||
echo "%{F#859900}$2 歷%{F-}";
|
||||
echo "%{F#859900}$2 %{F-}";
|
||||
else
|
||||
echo "$2 轢";
|
||||
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 = ""
|
||||
content = ""
|
||||
click-left = ~/.local/bin/screenshot >/dev/null 2>%1 &
|
||||
#+END_SRC
|
||||
|
||||
|
||||
Reference in New Issue
Block a user