feat: use eww as bar!

This commit is contained in:
João Dias
2024-11-23 10:10:28 -03:00
parent 1f08358b10
commit fb7b91699e
18 changed files with 349 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
* {
all: unset;
transition: 120ms linear;
font-size: 12px;
}
@import "../../.cache/wal/colors.scss";
@import './styles/bar.scss';
@import './styles/calendar.scss';
@import './styles/control-center.scss';
+51
View File
@@ -0,0 +1,51 @@
; Windows
(include "./windows/calendar.yuck")
(include "./windows/control-center.yuck")
; Widgets
(include "./widgets/workspaces.yuck")
(include "./widgets/clock.yuck")
(include "./widgets/notifications.yuck")
(include "./widgets/audio.yuck")
(include "./widgets/media.yuck")
(include "./widgets/logo.yuck")
(include "./widgets/window.yuck")
(defwindow bar
:monitor 0
:geometry (geometry :width "100%"
:height "44px"
:anchor "top center")
:stacking "fg"
:exclusive true
:namespace "eww-bar"
(centerbox :orientation "h"
(box :class "widgets-left"
:halign "start"
:space-evenly false
(logo)
(workspaces)
)
(box :class "widgets-center"
:halign "center"
:space-evenly false
(clock)
(window)
)
(box :class "widgets-right"
:halign "end"
:space-evenly false
(systray :spacing 5
:orientation "h"
:space-evenly false
:icon-size 14
:prepend-new true
:class "systray"
)
(audio)
(notifications)
)
)
)
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
if [[ $(eww get calendar_state) == "show" ]]; then
eww close calendar
eww update calendar_state="hidden"
else
eww open calendar
eww update calendar_state="show"
fi
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
WP_VOLUME=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed -e 's/^Volume: //')
formatted_volume() {
if ! [ $WP_VOLUME == "1.00" ]; then
echo "${WP_VOLUME#0.}%"
else
echo "100%"
fi
}
formatted_volume
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
ACTIVE_WINDOW=$(hyprctl -j activewindow)
WINDOW_TITLE=$(echo $ACTIVE_WINDOW | jq '.title' | sed -e 's/^\"//' -e 's/\"$//')
WINDOW_CLASS=$(echo $ACTIVE_WINDOW | jq '.class' | sed -e 's/^\"//' -e 's/\"$//')
if ! [[ $WINDOW_CLASS == "null" ]]; then
echo "$WINDOW_CLASS: $WINDOW_TITLE"
eww update widget_window_visible=true
else
echo ""
eww update widget_window_visible=false
fi
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Note: $SCROLL is defined by eww
$DEFAULT_INCREASE='5'
Guess_increase_decrease() {
local $CURRENT_VOL=$(wpctl get-volume "@DEFAULT_AUDIO_SINK@")
}
Update_volume() {
local $UPDATED_VOL=$(Guess_increase_decrease)
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")
}
+117
View File
@@ -0,0 +1,117 @@
.bar {
background: transparent;
padding: 4px;
}
/* Styles .widgets-[left/center/right] */
.widgets-left,
.widgets-center,
.widgets-right {
background: rgba($background, 0.6);
border-radius: 18px;
padding: 6px;
& > * {
margin: 0 3px;
}
& > *:first-child {
margin-left: 0;
}
& > *:last-child {
margin-right: 0;
}
}
button {
padding: 6px 10px;
border-radius: 12px;
}
button:hover {
background: darken($color: $color1, $amount: 5);
}
button:active {
background: darken($color: $color1, $amount: 20)
}
button label {
color: $foreground;
}
menu {
background: $background;
border-radius: 14px;
padding: 2px;
& > menuitem {
padding: 8px 24px;
border-radius: 5px;
&:hover {
background: $color1;
}
&:first-child {
border-top-left-radius: inherit;
border-top-right-radius: inherit;
}
&:last-child {
border-bottom-left-radius: inherit;
border-bottom-right-radius: inherit;
}
label {
font-weight: 600;
color: $foreground;
}
}
& > separator {
background: lighten($color: $background, $amount: 5);
margin: .5px 10px;
padding: 1px 0;
border-radius: 1px;
}
}
.workspaces {
padding: 2px 6px;
border-radius: 16px;
& > button {
padding: 0 9px;
border-radius: 50%;
margin: 0 2px;
background: darken($color1, 20);
}
}
.workspaces button:hover {
color: $color1;
}
.distro-logo {
padding: 0 16px;
& label {
font-size: 15px;
}
}
.systray {
margin: 0 6px;
& > * > * {
margin: 0 4px
}
}
.notifications button {
padding-left: 11px;
padding-right: 11px;
}
+9
View File
@@ -0,0 +1,9 @@
.widget-calendar {
padding: 24px;
background: rgba($background, 0.6);
border-radius: 16px;
& > .title {
background: $color1;
}
}
+5
View File
@@ -0,0 +1,5 @@
.control-center {
background: green;
border-radius: 16px;
}
+11
View File
@@ -0,0 +1,11 @@
(defpoll output_volume :interval "500ms"
`echo "$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed -e 's/Volume: //' -e 's/^1\./1/' -e 's/^0.//' -e 's/^00/0/')%"`)
(defwidget audio []
(eventbox
:onscroll `sh -c "SCROLL='{}'; source './scripts/volume.sh'; Update_volume"`
(button :class "audio" "󰕾 ${output_volume}")
)
)
+12
View File
@@ -0,0 +1,12 @@
(defpoll datetime :interval "10s"
"date +'%A %d, %H:%M'")
(defvar calendar_state "hidden")
(defwidget clock []
(box :class "clock"
(button :onclick "sh ./scripts/display-calendar.sh"
"${datetime}")
)
)
+4
View File
@@ -0,0 +1,4 @@
(defwidget logo []
(button :class "distro-logo"
"")
)
View File
+5
View File
@@ -0,0 +1,5 @@
(defwidget notifications []
(box :class "notifications"
(button :onclick "swaync-client -t" "")
)
)
+10
View File
@@ -0,0 +1,10 @@
(defpoll windowInfo :interval "250ms"
"sh ./scripts/get-window.sh")
(defvar widget_window_visible true)
(defwidget window []
(button :visible "${widget_window_visible}"
"${windowInfo}")
)
+15
View File
@@ -0,0 +1,15 @@
(deflisten json_workspaces
:initial "[{1: {}, 2:{}}]"
`hyprctl -j workspaces`)
(defwidget workspaces []
(eventbox :onscroll "[[ {} =~ up ]] && hyprctl dispatch workspace e+1 || hyprctl dispatch workspace e-1"
(box :class "workspaces"
(for i in json_workspaces
(button :onclick "hyprctl dispatch workspace ${i}"
"${i[0].num}")
)
)
)
)
+22
View File
@@ -0,0 +1,22 @@
(defwindow calendar
:monitor 0
:geometry (geometry :width 300
:height 250
:anchor "top center"
)
:stacking "fg"
:exclusive false
:namespace "eww-calendar"
(box
(cal)
)
)
(defwidget cal []
(box :class "widget-calendar"
(box :class "month-calendar"
(button :class "day"
1)
)
)
)
+24
View File
@@ -0,0 +1,24 @@
(defwindow control-center []
:monitor 0
:geometry (geometry :width "500px"
:height "90%"
:anchor "center right")
:stacking "overlay"
:exclusive false
:namespace "eww-cc"
(box
(toggles)
)
)
(defwidget toggles []
(box :class "row"
(button :onclick "notify-send 'stop internet!'"
(box
(label :class "title" :text "Internet >")
(label :class "extra" :text "Caique Wifi")
)
)
)
)