Add status bar idle inhibitor module

This commit is contained in:
Kiana Sheibani 2024-05-13 23:04:40 -04:00
parent 9e28e6eebc
commit e304f05642
3 changed files with 55 additions and 21 deletions

View file

@ -39,7 +39,7 @@ tooltip {
}
.bar-sep {
margin: 0px 5px;
margin: 0px 4px;
color: $background-alt;
font-size: 22;
}
@ -182,6 +182,8 @@ scale trough {
.bar-brightness {
@include scale-color(#e0af68);
margin-right: 4px;
.symbol {
margin-right: 7px;
font-size: 14;
@ -189,8 +191,8 @@ scale trough {
}
.bar-internet {
margin-left: 7px;
margin-right: 10px;
margin-left: 5px;
margin-right: 9px;
font-family: "JetBrains Mono";
color: #bb9af7;
font-size: 12;
@ -205,7 +207,7 @@ scale trough {
}
.bar-bluetooth {
margin: 0px 5px;
margin: 0px 3px;
font-size: 15;
color: #7aa2f7;
@ -216,7 +218,7 @@ scale trough {
.bar-circular {
margin: 0px 4px;
margin: 0px 3px;
font-size: 15;
.back {
@ -245,3 +247,13 @@ scale trough {
margin-right: 1px;
}
}
.bar-idleinhibit {
margin-left: 3px;
margin-right: 4px;
color: $disabled;
&.active {
color: #f7768e;
}
}

View file

@ -106,13 +106,13 @@
(defwidget bar_scale [?class reveal-name reveal value symbol onchange ?onclick]
(eventbox :onhover "${EWW_CMD} update ${reveal_name}=true"
:onhoverlost "${EWW_CMD} update ${reveal_name}=false"
(eventbox :onhover "${EWW_CMD} update ${reveal-name}=true"
:onhoverlost "${EWW_CMD} update ${reveal-name}=false"
:onclick onclick
(box :class "bar-scale ${class}"
:space-evenly false
(eventbox :onclick onclick
(label :class "symbol"
:text symbol))
:text symbol)
(revealer :transition "slideright"
:reveal reveal
:duration "400ms"
@ -225,6 +225,16 @@
(box :class "bar-bluetooth ${bluetooth == "{}" ? "disabled" : ""}"
(label :text {bluetooth != "{}" ? "󰂯" : "󰂲"})))
;; Idle Inhibitor
(defpoll idleinhibit :interval "1s" :initial "0"
"pgrep -c -f wayland\"\"-idle-inhibitor || true")
(defwidget bar_idleinhibit []
(eventbox :onclick "~/.config/eww/scripts/toggle-idle-inhibit"
(box :class "bar-idleinhibit ${idleinhibit > 0 ? "active" : ""}"
(label :text {idleinhibit > 0 ? "󰈈" : "󰛑"}))))
;; Separator
(defwidget bar_sep []
@ -236,7 +246,7 @@
;; Bar Layout
(defwidget bar_left_edge []
(defwidget laptop_bar_left_edge []
(box :orientation "h"
:space-evenly false
:halign "start"
@ -244,17 +254,17 @@
(bar_window :class-limit 60
:title-limit 55)))
(defwidget bar_left_wing []
(defwidget laptop_bar_left_wing []
(box :orientation "h"
:space-evenly false
:halign "end"
:hexpand true
(bar_time :width 195)))
(defwidget bar_center []
(defwidget laptop_bar_center []
(bar_workspaces))
(defwidget bar_right_wing []
(defwidget laptop_bar_right_wing []
(box :orientation "h"
:space-evenly false
:hexpand true
@ -275,7 +285,9 @@
(bar_sep)
(bar_storage)
(bar_ram)
(bar_battery)))
(bar_battery)
(bar_sep)
(bar_idleinhibit)))
(defwidget laptop_bar_layout []
(centerbox :class "bar"
@ -283,12 +295,12 @@
(box :orientation "h"
:space-evenly false
:hexpand true
(bar_left_edge)
(bar_left_wing))
(bar_center)
(laptop_bar_left_edge)
(laptop_bar_left_wing))
(laptop_bar_center)
(box :orientation "h"
:space-evenly false
(bar_right_wing)
(laptop_bar_right_wing)
(laptop_bar_right_edge))))
@ -305,7 +317,7 @@
:space-evenly false
:halign "end"
:hexpand true
(bar_time)))
(bar_time :width 195)))
(defwidget desktop_bar_center []
(bar_workspaces))
@ -314,7 +326,9 @@
(box :orientation "h"
:space-evenly false
:hexpand true
(bar_music)))
(bar_music :width 195
:artist-limit 30
:title-limit 25)))
(defwidget desktop_bar_right_edge []
(box :orientation "h"
@ -345,6 +359,7 @@
(defwindow laptop_bar
:monitor 0
:geometry (geometry :width "100%"
:height "3%"
:anchor "top center")
@ -355,6 +370,7 @@
(laptop_bar_layout))
(defwindow desktop_bar
:monitor 0
:geometry (geometry :width "100%"
:height "3%"
:anchor "top center")

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
if pkill -0 -f wayland-idle-inhibitor; then
pkill -f wayland-idle-inhibitor
else
wayland-idle-inhibitor &
fi