Added eww bluetooth module

This commit is contained in:
marc
2024-03-06 23:35:51 +01:00
parent f2b20c7acd
commit 6a4dcadfba
3 changed files with 44 additions and 0 deletions

View File

@@ -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"})))))