feat(eww): use gnome-like workspaces in bar

This commit is contained in:
João Dias
2024-11-24 15:21:20 -03:00
parent 825b57a8f2
commit ef9c6b9d00
5 changed files with 52 additions and 38 deletions
+28 -17
View File
@@ -1,28 +1,39 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Note: $SCROLL is defined by eww default_value="5"
audio_sink="@DEFAULT_AUDIO_SINK@"
current_volume=$(wpctl get-volume $audio_sink)
DEFAULT_INCREASE='5'
Guess_increase_decrease() { get_volume() {
CURRENT_VOL=$(Translate_volume_to_int) echo $(wpctl get-volume $audio_sink)
}
if [[ $SCROLL == "up" ]]; then get_json_loop() {
if [[ $(awk "BEGIN { ($CURRENT_VOL+$DEFAULT_INCREASE) }") > 100 ]]; then while true; do
echo "1.00" if ! [[ $current_volume == get_volume ]]; then
else echo "{ \"volume\": $(translate_volume $current_volume) }"
echo "$DEFAULT_INCREASE%+" current_volume=$(get_volume)
fi fi
done
}
set_volume() {
wpctl set-volume $audio_sink $1
}
translate_volume() {
echo "$($1 | sed -e 's/Volume: //' -e 's/^1\./1/' -e 's/^0.//' -e 's/^00/0/')"
}
increase_vol() {
if (($(translate_volume $current_volume)+$default_value >= 100)); then
set_volume "1.00"
else else
echo "$DEFAULT_INCREASE%-" set_volume "$default_value%+"
fi fi
} }
Update_volume() { decrease_vol() {
UPDATED_VOL=$(Guess_increase_decrease) set_volume "$default_value%-"
wpctl set-volume "@DEFAULT_AUDIO_SINK@" "$UPDATED_VOL"
}
Translate_volume_to_int() {
echo $(wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed -e 's/Volume: //' -e 's/^1\./1/' -e 's/^0.//' -e 's/^00/0/')
} }
+17 -14
View File
@@ -80,36 +80,39 @@ menu {
} }
.workspaces { .workspaces {
padding: 2px 6px; padding: 2px 0px;
border-radius: 16px; border-radius: 10px;
& > button { & > button {
padding: 0 0; padding: 0 0;
border-radius: 16px; border-radius: 16px;
margin: 0 2px; margin: 0 2px;
background: darken($color1, 20); background: $color1;
font-weight: 500; transition: ease-in 80ms;
transition-property: all;
&.active { &.active {
background: $color1; padding: 0 22px;
font-weight: 600; background: $foreground;
padding: 0 24px;
} }
&:not(.active) { &.default {
padding: 0 10px; padding: 0 12px;
} }
} }
} }
.workspaces button:hover {
color: $color1;
}
.distro-logo { .distro-logo {
padding: 0 16px; padding: 0 14px;
& label { & > button {
padding: 0;
margin: 0;
}
& > label {
font-size: 15px; font-size: 15px;
padding-right: 2px;
} }
} }
+4 -5
View File
@@ -1,11 +1,10 @@
(defpoll output_volume :interval "500ms" (deflisten volume_out :initial '{ "volume": "100%" }'
`echo "$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed -e 's/Volume: //' -e 's/^1\./1/' -e 's/^0.//' -e 's/^00/0/')%"`) `sh -c "source './scripts/volume.sh'; get_json_loop"`)
(defwidget audio [] (defwidget audio []
(eventbox (eventbox
:onscroll `sh -c "SCROLL='{}'; source './scripts/volume.sh'; Update_volume"` :onscroll `[[ {} == "up" ]]; sh -c "source './scripts/volume.sh'; increase_vol" || sh -c "source './scripts/volume.sh'; decrease_vol"`
(button "󰕾 ${volume_out.volume}")
(button :class "audio" "󰕾 ${output_volume}")
) )
) )
+1 -1
View File
@@ -1,6 +1,6 @@
(deflisten active_window :initial "" (deflisten active_window :initial ""
`sh ./scripts/window.sh`) `sh ./scripts/active-window.sh`)
(defwidget window [] (defwidget window []
(button :visible { active_window.class == "null" ? false : true } (button :visible { active_window.class == "null" ? false : true }
+2 -1
View File
@@ -8,10 +8,11 @@
(defwidget workspaces [] (defwidget workspaces []
(eventbox :onscroll "[[ {} == up ]] && hyprctl dispatch workspace e+1 || hyprctl dispatch workspace e-1" (eventbox :onscroll "[[ {} == up ]] && hyprctl dispatch workspace e+1 || hyprctl dispatch workspace e-1"
(box :class "workspaces" (box :class "workspaces"
:space-evenly false
(for workspace in json_workspaces (for workspace in json_workspaces
(button :onclick "hyprctl dispatch workspace ${workspace.id}" (button :onclick "hyprctl dispatch workspace ${workspace.id}"
:class "${ json_active_workspace.id == workspace.id ? "active" : "default" }" :class "${ json_active_workspace.id == workspace.id ? "active" : "default" }"
"${workspace.id}") "")
) )
) )
) )