pinwheel: Add module for mullvad

This commit is contained in:
Alexander Heldt
2023-09-20 23:33:28 +02:00
parent ece82c9ad5
commit a07b1d58a1
3 changed files with 59 additions and 1 deletions

View File

@@ -33,6 +33,52 @@ let
fi
'';
mullvad = pkgs.writeShellScript "mullvad" ''
STATUS_DISCONNECTING="Disconnecting"
STATUS_DISCONNECTED="Disconnected"
STATUS_CONNECTING="Connecting"
STATUS_CONNECTED="Connected"
status() {
STATUS=$(${pkgs.mullvad}/bin/mullvad status | awk '{print $1}')
echo $STATUS
}
output() {
case $(status) in
$STATUS_DISCONNECTED)
echo '{ "text": "" }' ;;
$STATUS_CONNECTING)
echo '{ "text": "", "tooltip": "Connecting" }' ;;
$STATUS_CONNECTED)
TOOLTIP=$(${pkgs.mullvad}/bin/mullvad status)
echo "{ \"text\": \"\", \"tooltip\":\"$TOOLTIP\" }" ;;
$STATUS_DISCONNECTING)
echo '{ "text": "", "tooltip": "Disconnecting" }' ;;
*)
echo '{ "text": "", "tooltip": "Status unknown" }' ;;
esac
}
toggle() {
CURRENT_STATUS=$(status)
case "$CURRENT_STATUS" in
$STATUS_DISCONNECTED)
${pkgs.mullvad}/bin/mullvad connect --wait > /dev/null && notify-send "Connected to VPN";;
$STATUS_CONNECTED)
${pkgs.mullvad}/bin/mullvad disconnect --wait > /dev/null && notify-send "Disconnected from VPN";;
esac
}
case $1 in
--toggle)
toggle ;;
--output)
output ;;
esac
'';
toggle-bt-power = pkgs.writeShellScript "toggle-bt-power" ''
POWERED_ON=$(bluetoothctl show | grep "Powered: yes")
if [ -z "$POWERED_ON" ]; then
@@ -58,7 +104,7 @@ in
output = [ "eDP-1" ];
modules-left = [ "hyprland/workspaces" ];
modules-right = [ "custom/spotify" "custom/dunst" "bluetooth" "wireplumber" "network" "battery" "clock" ];
modules-right = [ "custom/spotify" "custom/dunst" "custom/mullvad" "bluetooth" "wireplumber" "network" "battery" "clock" ];
"custom/spotify" = {
exec = spotify-status;
@@ -74,6 +120,13 @@ in
tooltip = false;
};
"custom/mullvad" = {
exec = "${mullvad} --output";
return-type = "json";
on-click-right = "${mullvad} --toggle";
interval = 1;
};
bluetooth = {
"format-off" = "󰂲";
"format-on" = "";