fix: Hyprland config update, eww bar integration #15

Merged
aniva merged 15 commits from wayland/hypr into main 2024-09-03 13:15:08 -07:00
3 changed files with 68 additions and 61 deletions
Showing only changes of commit c601a17ae9 - Show all commits

View File

@ -14,7 +14,9 @@ $weather: rgba(180, 220, 235, 0.8);
$weather_end: rgba(171, 233, 179, 0.8); $weather_end: rgba(171, 233, 179, 0.8);
$clock: rgba(171, 233, 179, 1.0); $clock: rgba(171, 233, 179, 1.0);
$media-progress-bg: #333333;
$media: rgba(224, 232, 224, 0.7); $media: rgba(224, 232, 224, 0.7);
$media-paused: rgba(224, 200, 200, 0.7);
$tray_bg: rgba(204, 204, 204, 0.1); $tray_bg: rgba(204, 204, 204, 0.1);
$tray: #c9cbff; $tray: #c9cbff;
@ -25,7 +27,9 @@ $audio: #fae3b0;
$backlight: #f8bd96; $backlight: #f8bd96;
$bluetooth: #caa9c7; $bluetooth: #caa9c7;
$network: #bd93f9; $network: #bd93f9;
$cpu_bg: #333333;
$cpu: #96cdfb; $cpu: #96cdfb;
$memory_bg: #333333;
$memory: #88bbeb; $memory: #88bbeb;
$temperature: #ddb6f2; $temperature: #ddb6f2;
$temperature_critical: #ff6666; $temperature_critical: #ff6666;
@ -114,15 +118,10 @@ box .weather {
color: mix($weather_end, $weather, 100%); color: mix($weather_end, $weather, 100%);
} }
} }
.audio-scale { //.audio-scale .audio .audio-icon {
color: $audio; // background-color: transparent;
} // color: $audio;
.audio { //}
all: unset;
border: none;
background-color: transparent;
color: $audio;
}
scale { scale {
border-radius: 5px; border-radius: 5px;
min-height: 80px; min-height: 80px;
@ -134,18 +133,19 @@ scale {
color: $audio; color: $audio;
} }
box .cpu { box .cpu {
background-color: $cpu_bg;
color: $cpu; color: $cpu;
padding: 6pt; padding: 5pt;
} }
box .memory { box .memory {
background-color: $memory_bg;
color: $memory; color: $memory;
padding: 6pt; padding: 5pt;
} }
box .clock { box .clock {
background-color: $widget_bg; background-color: transparent;
border-radius: 5; border-radius: 5;
color: $clock; color: $clock;
margin-bottom: 30px;
padding: 2pt 2pt 2pt 2pt; padding: 2pt 2pt 2pt 2pt;
} }
@ -158,7 +158,17 @@ box .clock {
color: $media; color: $media;
border: none; border: none;
} }
.media-playing {
background-color: $media-progress-bg;
color: $media;
}
.media-paused {
background-color: $media-progress-bg;
color: $media-paused;
}
.media-text-paused {
color: $media-paused;
}
.status { .status {
font-family: monospace; font-family: monospace;
} }

View File

@ -8,7 +8,7 @@
:x "0%" :x "0%"
:y "0%" :y "0%"
:width "20px" :width "20px"
:height "100%" :height "99%"
:anchor "center left" :anchor "center left"
) )
:reserve (struts :side "left" :distance "20px") :reserve (struts :side "left" :distance "20px")
@ -24,7 +24,6 @@
(widget-workspaces) (widget-workspaces)
) )
(widget-media) (widget-media)
;(widget-weather :orientation "v")
(box :orientation "v" :space-evenly false :valign "end" (box :orientation "v" :space-evenly false :valign "end"
(widget-tray) (widget-tray)
(widget-audio) (widget-audio)
@ -104,45 +103,49 @@
:orientation "v" :orientation "v"
:space-evenly false :space-evenly false
:valign "center" :valign "center"
(eventbox
:onclick "playerctl play-pause"
(circular-progress (circular-progress
:class "media" :class { media-status == "Paused" ? "media-paused" : "media-playing" }
:width 20 :width 20
:height 20 :height 20
:thickness 5 :thickness 5
;:tooltip {music_listener_position} :tooltip {media-position-text}
:tooltip "${music_position} / ${music_length}" :value {100.0 * media-position / (media-length / 1000000.0)}
:value {100.0 * music_position / (music_length / 1000000.0)} :visible {media-current != "" && media-length != 1}
:visible {music_listener != "" && music_length != 1} ))
)
; Add play and pause buttons here?
(label (label
:class { media-status == "Paused" ? "media-text-paused" : "media-text-playing" }
:angle 270 :angle 270
:xalign 0.5 :xalign 0.5
:yalign 0.5 :yalign 0.5
:justify "center" :justify "center"
:text {music_listener != "" ? "『${music_listener}』" : "『』"}) :text {media-current != "" ? "『${media-current}』" : "『』"})
)) ))
(deflisten music_listener :initial ""
(deflisten media-current :initial ""
"playerctl --follow metadata --format '{{ artist }} / {{album}} / {{ title }}' || true") "playerctl --follow metadata --format '{{ artist }} / {{album}} / {{ title }}' || true")
(deflisten music_listener_position :initial "" (deflisten media-position-text :initial ""
"playerctl --follow metadata --format '{{duration(position)}} / {{duration(mpris:length)}}' || true") "playerctl --follow metadata --format '{{duration(position)}} / {{duration(mpris:length)}}' || true")
(defpoll music_position :interval "1s" (defpoll media-position :interval "1s"
"playerctl position") "playerctl position")
(deflisten music_length :initial 1 (deflisten media-length :initial 1
"playerctl --follow metadata mpris:length") "playerctl --follow metadata mpris:length")
(deflisten media-status :initial "Stopped"
"playerctl --follow status")
(defwidget widget-audio [] (defwidget widget-audio []
(eventbox (eventbox
:class "audio" :class "audio"
:onhover "${eww} update show_audio=true" :onhover "${eww} update show-audio=true"
:onhoverlost "${eww} update show_audio=false" :onhoverlost "${eww} update show-audio=false"
(box (box
:class "audio" :class "audio"
:orientation "v" :orientation "v"
:space-evenly "false" :space-evenly "false"
:spacing "2" :spacing "2"
(revealer :transition "slideup" :reveal show_audio (revealer :transition "slideup" :reveal show-audio
(scale (scale
:class "audio-scale" :class "audio-scale"
:value current-volume :value current-volume
@ -153,13 +156,15 @@
:max 101 :max 101
:min 0 :min 0
:onchange "amixer -D pulse sset Master {}%" )) :onchange "amixer -D pulse sset Master {}%" ))
(button (label
:class "audio" :class "audio-icon"
:onclick "scripts/popup audio" :width 20 :height 20
:xalign 0.5 :yalign 0.5
:noindent true
:tooltip "Volume: ${current-volume}%" :tooltip "Volume: ${current-volume}%"
:class "volume-icon" "")))) :text { current-volume == 0 ? "" : (current-volume > 80 ? "" : "") }))))
(defpoll current-volume :interval "1s" "amixer -D pulse sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }' | tr -d '%'") (defpoll current-volume :interval "1s" "amixer -D pulse sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }' | tr -d '%'")
(defvar show_audio false) (defvar show-audio false)
(defwidget widget-cpu [] (defwidget widget-cpu []
(circular-progress (circular-progress
@ -194,7 +199,7 @@
:orientation "v" :orientation "v"
:valign "end" :valign "end"
:spacing 1 :spacing 1
:width 25 :width 20
(box :class "icon" "") (box :class "icon" "")
"${clock.m}" "${clock.d}" "${clock.m}" "${clock.d}"
(box :class "icon" "") (box :class "icon" "")
@ -231,23 +236,6 @@
(defpoll calendar_year :interval "10h" (defpoll calendar_year :interval "10h"
"date '+%Y'") "date '+%Y'")
; Unused widgets
;(defwidget widget_status []
; (box
; :class "status"
; :orientation "v"
; :space-evenly false
; :valign "end"
; (metric :label ""
; :value volume
; :onchange "amixer -D pulse sset Master {}%")
; (metric :label ""
; :value {EWW_RAM.used_mem_perc}
; :onchange "")
; (widget_clock)))
(defwidget metric [label value onchange] (defwidget metric [label value onchange]
(box (box
:orientation "v" :orientation "v"

View File

@ -121,10 +121,19 @@ class HyprlandHandler(CompositorHandler):
return return
prefix = b"activewindow>>" prefix = b"activewindow>>"
if not data.startswith(prefix): payload = next((l[len(prefix):]
for l in reversed(data.split(b'\n'))
if l.startswith(prefix)), None)
if payload is None:
return return
title = data[len(prefix):]
if b',' in payload:
_, title = payload.decode('utf-8').split(',', 1)
print(title, flush=True) print(title, flush=True)
else:
print("", flush=True)
self.listen(callback) self.listen(callback)
@override @override