From 6a4dcadfba57c4d9c4edddf6e9825bfd7868519d Mon Sep 17 00:00:00 2001 From: marc Date: Wed, 6 Mar 2024 23:35:51 +0100 Subject: [PATCH] Added eww bluetooth module --- config/eww/bars/top-bar.scss | 13 +++++++++++++ config/eww/bars/top-bar.yuck | 2 ++ config/eww/widgets/bluetooth.yuck | 29 +++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 config/eww/widgets/bluetooth.yuck diff --git a/config/eww/bars/top-bar.scss b/config/eww/bars/top-bar.scss index feb4bc9..a55df74 100644 --- a/config/eww/bars/top-bar.scss +++ b/config/eww/bars/top-bar.scss @@ -38,6 +38,19 @@ tooltip label { color: $base02; } +/** Bluetooth **/ +.bluetooth { + color: $base0D; +} + +.bluetooth.icon { + padding-right: 4px; +} + +.bluetooth-text { + padding-left: 8px; +} + /** Wifi **/ .wifi { color: $base0D; diff --git a/config/eww/bars/top-bar.yuck b/config/eww/bars/top-bar.yuck index 6da05ea..5a57f4e 100644 --- a/config/eww/bars/top-bar.yuck +++ b/config/eww/bars/top-bar.yuck @@ -1,6 +1,7 @@ (include "./widgets/common.yuck") (include "./widgets/battery.yuck") +(include "./widgets/bluetooth.yuck") (include "./widgets/clock.yuck") (include "./widgets/volume.yuck") (include "./widgets/workspaces.yuck") @@ -35,6 +36,7 @@ (box :halign "end" :orientation "h" :space-evenly "false" + (bluetooth-module) (wifi-module) (battery-module) (volume-module) diff --git a/config/eww/widgets/bluetooth.yuck b/config/eww/widgets/bluetooth.yuck new file mode 100644 index 0000000..dc98cfd --- /dev/null +++ b/config/eww/widgets/bluetooth.yuck @@ -0,0 +1,29 @@ +(defvar bluetooth-reveal false) +(defpoll bluetooth-status + :initial "" + :interval "10s" + "bluetoothctl show | grep -q \"Powered: yes\" && { [[ $(bluetoothctl devices Connected) ]] && echo \"connected\" || echo \"on\"; } || echo \"off\"") +(defpoll bluetooth-devices + :initial "" + :interval "20s" + "for device in $(bluetoothctl devices Connected | grep Device | cut -d ' ' -f 2); do bluetoothctl info $device | grep \"Alias\" | cut -d ' ' -f 2-; done;") + + +(defwidget bluetooth-module [] + (eventbox :onhover "${EWW_CMD} update bluetooth-reveal=true" + :onhoverlost "${EWW_CMD} update bluetooth-reveal=false" + :onclick "$HOME/.config/rofi/menus/bluetooth/bluetooth.sh" + (box :class "module bluetooth" + :orientation "h" + :space-evenly "false" + :tooltip {bluetooth-status == "connected" ? bluetooth-devices : + bluetooth-status == "on" ? "Bluetooth: On" : "Bluetooth: Off"} + (label :text {bluetooth-status == "connected" ? "󰂱" : + bluetooth-status == "on" ? "󰂯" : "󰂲"} + :class "bluetooth icon") + (revealer :transition "slideleft" + :duration "750ms" + :reveal {bluetooth-reveal && winfo.connected} + (label :class "bluetooth-text" + :text {bluetooth-status == "connected" ? "Connected" : + bluetooth-status == "on" ? "On" : "Off"})))))