eww: add new features and fix issues

This commit is contained in:
retrozinndev
2024-12-07 16:43:37 -03:00
parent adf8b7d9ba
commit e9258d04e4
26 changed files with 882 additions and 207 deletions
+10 -5
View File
@@ -1,10 +1,15 @@
;(deflisten volume_out :initial '{ "volume": "100%" }'
;`sh -c "source './scripts/volume.sh'; get_json_loop"`)
(deflisten json_audio :initial `{ "output": 35, "source": 80 }`
`sh ./scripts/get-volume-watch.sh`)
(defwidget audio []
(eventbox
:onscroll `[[ {} == "up" ]]; sh -c "source './scripts/volume.sh'; increase_vol" || sh -c "source './scripts/volume.sh'; decrease_vol"`
(button "󰕾 ")
(eventbox :onclick "eww open --toggle audio-popup"
:class "audio-eventbox"
(box :class "audio"
(eventbox :onscroll `[ {} == "up" ] && wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ || wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-`
(label :text "${ json_audio.output != 0 ? '󰕾' : '󰝟' } ${json_audio.output}%"))
(eventbox :onscroll `[ {} == "up" ] && wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 5%+ || wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 5%-`
(label :text "${ json_audio.source != 0 ? '󰍬' : '󰍭' } ${json_audio.source}%"))
)
)
)
+6
View File
@@ -0,0 +1,6 @@
(defwidget battery [ ?device ]
(box :class "battery"
:visible { EWW_BATTERY != "" ? true : false }
(label :text "󰁹 ${EWW_BATTERY}%")
)
)
+7
View File
@@ -0,0 +1,7 @@
(defwidget control-center-toggle []
(box :class "control-center-toggle"
(button :onclick "eww open --toggle control-center"
" ")
)
)
+33 -25
View File
@@ -1,40 +1,48 @@
(defvar media_reveal_controls false)
(deflisten media :initial "{}"
(deflisten json_media :initial "{}"
`python3 ./scripts/mediaplayer.py`)
(defwidget media []
(eventbox :onhover "eww update media_reveal_controls=true"
:onhoverlost "eww update media_reveal_controls=false"
(box :class "mediaplayer ${ media_reveal_controls ? 'revealed' : '' }"
:space-evenly false
:visible { media.title == "null" && media.artist == "null" ?
:visible { json_media.title == "null" && json_media.artist == "null" ?
false
:
"${ active_window.class =~ media.player || active_window.title =~ media.title ? false : true }"
"${ active_window.class =~ json_media.player || active_window.title =~ json_media.title ? false : true }"
}
(box :class "mediaplayer ${ media_reveal_controls ? 'revealed' : '' }"
:space-evenly false
(label :class "media-title"
:text "${media.title}")
(label :class "media-artist"
:text "${media.artist}")
(revealer :class "media-controls-revealer"
:reveal { media_reveal_controls ? true : false }
:transition "slideright"
:duration "180ms"
(box
(button :class "previous"
:onclick "playerctl previous --player=${media.player}"
"󰒮")
(button :class "toggle play-pause"
:onclick "playerctl play-pause --player=${media.player}"
{ media.status == "playing" ? "󰏤" : "󰐊" })
(button :class "next"
:onclick "playerctl next --player=${media.player}"
"󰒭")
)
)
(box :class "media"
:space-evenly false
(label :class "player"
:text { json_media.player == "spotify" ? " " : "󰎇 " })
(label :class "media-title"
:text "${json_media.title}"
:limit-width 40)
(box :class "separator")
(label :class "media-artist"
:text "${json_media.artist}"
:limit-width 25)
)
(revealer :class "media-controls-revealer"
:reveal { media_reveal_controls ? true : false }
:transition "slideright"
:duration "180ms"
(box :class "media-controls"
(button :class "previous"
:onclick "playerctl previous --player=${json_media.player}"
"󰒮")
(button :class "toggle play-pause"
:onclick "playerctl play-pause --player=${json_media.player}"
{ json_media.status == "playing" ? "󰏤" : "󰐊" })
(button :class "next"
:onclick "playerctl next --player=${json_media.player}"
"󰒭")
)
)
)
)
)
+1 -1
View File
@@ -1,4 +1,4 @@
(defpoll connection_status :interval "2s"
(defpoll connection_status :interval "5s"
`nmcli n c`)
(defwidget network []
-10
View File
@@ -1,10 +0,0 @@
(deflisten json_notifications :initial "{ \"text\": 0, \"class\": [\"notification\"] }"
`swaync-client -swb`)
(defwidget notifications []
(box :class "notifications"
(button :onclick "swaync-client -t"
:class { json_notifications.class =~ "cc-open" ? 'open' : '' }
{ json_notifications.alt == "dnd-notification" ? " " : '${ json_notifications.text == 0 ? " " : " " }' })
)
)
+15 -7
View File
@@ -3,17 +3,25 @@
`sh ./scripts/active-window.sh`)
(defwidget window []
(eventbox
(box :class "window"
:visible { active_window.class == "null" ? false : true }
:vexpand false
:space-evenly false
:orientation { active_window.title == "" ? "horizontal" : "vertical" }
(box :class "window"
:visible { active_window.class == "null" ? false : true }
:vexpand false
:space-evenly false
:orientation "horizontal"
(image :class "icon"
:icon "${active_window.initialClass}"
:icon-size "toolbar")
(box :class "info"
:orientation { active_window.title == "" ? "horizontal" : "vertical" }
:space-evenly false
(label :class "window-class"
:text "${active_window.class}")
(label :class "window-title"
:text "${active_window.title}"
:visible { active_window.title != "" ? true : false })
:visible { active_window.title != "" ? true : false }
:limit-width 45)
)
)
)
+1 -1
View File
@@ -6,7 +6,7 @@
`sh ./scripts/active-workspace.sh`)
(defwidget workspaces []
(eventbox :onscroll "[[ {} == up ]] && hyprctl dispatch workspace e+1 || hyprctl dispatch workspace e-1"
(eventbox :onscroll "[[ {} == up ]] && hyprctl dispatch workspace e+1 >> /dev/null || hyprctl dispatch workspace e-1 >> /dev/null"
(box :class "workspaces"
:space-evenly false
(for workspace in json_workspaces