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

@@ -38,6 +38,19 @@ tooltip label {
color: $base02; color: $base02;
} }
/** Bluetooth **/
.bluetooth {
color: $base0D;
}
.bluetooth.icon {
padding-right: 4px;
}
.bluetooth-text {
padding-left: 8px;
}
/** Wifi **/ /** Wifi **/
.wifi { .wifi {
color: $base0D; color: $base0D;

View File

@@ -1,6 +1,7 @@
(include "./widgets/common.yuck") (include "./widgets/common.yuck")
(include "./widgets/battery.yuck") (include "./widgets/battery.yuck")
(include "./widgets/bluetooth.yuck")
(include "./widgets/clock.yuck") (include "./widgets/clock.yuck")
(include "./widgets/volume.yuck") (include "./widgets/volume.yuck")
(include "./widgets/workspaces.yuck") (include "./widgets/workspaces.yuck")
@@ -35,6 +36,7 @@
(box :halign "end" (box :halign "end"
:orientation "h" :orientation "h"
:space-evenly "false" :space-evenly "false"
(bluetooth-module)
(wifi-module) (wifi-module)
(battery-module) (battery-module)
(volume-module) (volume-module)

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