feat: get volume using pactl

This commit is contained in:
hesam-init 2024-06-28 12:32:34 +03:30
parent 347db5657b
commit 49f4f95661
10 changed files with 137 additions and 104 deletions

View file

@ -19,7 +19,7 @@
:vexpand true
(user)
(chooser)
;; (weather)
; (weather)
(coolmpd :h 150 :permashow true)
(box
:orientation "h"

@ -0,0 +1 @@
Subproject commit 594295d5c0203c1c067a7c8004cf1d6fe835234b

View file

@ -1,5 +1,5 @@
@import "./colors.scss";
@import "./bar/bar.scss";
@import "./src/bar/styles.scss";
// @import "./bottom_bar/bar.scss";
@import "./control_panel/control_panel.scss";
@import "./dashboard/dashboard.scss";

View file

@ -1,62 +1,50 @@
(defpoll thour :initial "0" :interval "60s" "date +'%I'")
(defpoll tmin :initial "0" :interval "60s" "date +'%M'")
(defpoll tpm :initial "0" :interval "60s" "date +'%p'")
(defpoll volumemute :initial "false" :interval "1s" "pamixer --get-mute")
(defpoll volume :initial "0" :interval "1s" "pamixer --get-volume")
(defpoll brightness :initial "0" :interval "2s" "brightnessctl -m | awk -F, '{print substr($4, 0, length($4)-1)}' | tr -d '%'")
(defpoll wifi_icon :initial "" :interval "30s" "./scripts/wifi --ICON")
(defpoll wifi_essid :initial "" :interval "30s" "./scripts/wifi --ESSID")
(defpoll wifi_radio :initial "off" :interval "2s" "nmcli radio wifi")
(defpoll calendar_day :initial "1" :interval "20h" "date '+%d'")
(defpoll calendar_year :initial "2000" :interval "20h" "date '+%Y'")
(defpoll bat0 :initial "0" :interval "30s" "bash ./scripts/sys_info --bat")
;; (defpoll baticon :initial "" :interval "30s" "bash ./scripts/sys_info --baticon")
;; (defpoll batstat :interval "30s" "cat /sys/class/power_supply/BAT0/status")
(defpoll homedir :initial "" :interval "24h" "echo ~")
(include "./src/utils/_revealer.yuck")
(include "./src/_pollers.yuck")
(include "./src/_variables.yuck")
(deflisten workspacejson
(deflisten workspacejson
:initial '[{"focused": true, "empty": false, "name": 1}, {"focused": false, "empty": true, "name": 2}, {"focused": false, "empty": true, "name": 3}, {"focused": false, "empty": true, "name": 4}, {"focused": false, "empty": true, "name": 5}]'
"./scripts/workspace.py")
"./scripts/workspace.py")
;; used mainly in control panel and dashboard
(defpoll hostname :initial "idk" :interval "24h" 'echo "$(whoami)"')
(defpoll uptime :initial "idk" :interval "1m" "uptime -p")
(defpoll weatherjson
(defpoll weatherjson
:initial '{
"FeelsLikeC": "0",
"FeelsLikeF": "0",
"cloudcover": "0",
"humidity": "0",
"localObsDateTime": "2000-00-00 07:27 AM",
"observation_time": "07:27 AM",
"precipInches": "0.0",
"precipMM": "0.0",
"pressure": "0",
"pressureInches": "0",
"temp_C": "0",
"temp_F": "0",
"uvIndex": "0",
"visibility": "0",
"visibilityMiles": "0",
"weatherCode": "727",
"weatherDesc": [{"value": "Idk"}],
"weatherIconUrl": [{"value": ""}],
"winddir16Point": "",
"winddirDegree": "0",
"windspeedKmph": "0",
"windspeedMiles": "0",
"icon": "idk",
"hourly": []
"FeelsLikeC": "0",
"FeelsLikeF": "0",
"cloudcover": "0",
"humidity": "0",
"localObsDateTime": "2000-00-00 07:27 AM",
"observation_time": "07:27 AM",
"precipInches": "0.0",
"precipMM": "0.0",
"pressure": "0",
"pressureInches": "0",
"temp_C": "0",
"temp_F": "0",
"uvIndex": "0",
"visibility": "0",
"visibilityMiles": "0",
"weatherCode": "727",
"weatherDesc": [{"value": "Idk"}],
"weatherIconUrl": [{"value": ""}],
"winddir16Point": "",
"winddirDegree": "0",
"windspeedKmph": "0",
"windspeedMiles": "0",
"icon": "idk",
"hourly": []
}'
:interval "1h"
:run-while revealcontrolpanel
"./scripts/weather.py")
:interval "1h"
:run-while revealcontrolpanel
"./scripts/weather.py")
(defpoll datehour :initial "12" :interval "30m" "date +'%H'")
(defpoll notesc :interval "2s" :run-while reveal4 "cat -s ~/Documents/fuck.txt")
(deflisten timerdis `./scripts/timer.py subscribe`)
(defpoll quotejson :interval "1h" `./scripts/quote.py`)
(deflisten timerdis `./scripts/timer.py subscribe`)
;; dock
;; dock
(deflisten tasksjson :initial "[]" "./scripts/tasklist.py")
(defvar revealdock false)
@ -73,12 +61,12 @@
; Notifications
(deflisten notifications :initial '{
"count": 0,
"dnd": false,
"notifications": [],
"popups": []
}'
"./scripts/notifCatch"
"count": 0,
"dnd": false,
"notifications": [],
"popups": []
}'
"./scripts/notifCatch"
)
;; cava pipe ("borrowed from tail-r")
@ -89,11 +77,11 @@
(deflisten partist "playerctl metadata --format '{{ artist }}' -F")
(deflisten pcover "./scripts/pollcover.sh")
(deflisten pstatus "playerctl status -F")
(deflisten ptime
(deflisten ptime
:initial '{
"position": 0,
"duration": 0,
"readable": "0:00"
"position": 0,
"duration": 0,
"readable": "0:00"
}'
"playerctl -F metadata -f '{ \"position\": {{position/1000000}}, \"duration\": {{mpris:length/1000000}}, \"readable\": \"{{duration(position)}}/{{duration(mpris:length)}}\" }'")
;; (deflisten pside "playerctl -F metadata -f '{ \"volume\": {{volume*100}}, \"shuffle\": \"{{shuffle}}\", \"loop\": \"{{loop}}\" }'")
@ -104,20 +92,9 @@
;; windows for workspace switching
(defvar windows "[[], [], [], [], []]")
(defvar reveal1 false)
(defvar reveal2 false)
(defvar reveal3 false)
(defvar reveal4 false)
(defvar reveal5 false)
(defvar reveal6 false)
(defvar revealweather false)
(defvar revealsystray false)
(defvar revealcontrolpanel false)
(defpoll theme :interval "24h" "./scripts/toggletheme")
(include "./bar/bar.yuck")
(include "./src/bar/main.yuck")
;; (include "./bottom_bar/bar.yuck")
(include "./control_panel/control_panel.yuck")
(include "./dashboard/dashboard.yuck")

View file

@ -0,0 +1,16 @@
(defpoll thour :initial "0" :interval "60s" "date +'%I'")
(defpoll tmin :initial "0" :interval "60s" "date +'%M'")
(defpoll tpm :initial "0" :interval "60s" "date +'%p'")
(defpoll volumemute :initial "false" :interval "1s" "pamixer --get-mute")
(defpoll volume :initial "0" :interval "1s" "pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}' | tr -d '%'")
(defpoll mic_volume :initial "0" :interval "1s" "pactl get-source-volume @DEFAULT_SOURCE@ | awk '{print $5}' | tr -d '%'")
(defpoll brightness :initial "0" :interval "2s" "brightnessctl -m | awk -F, '{print substr($4, 0, length($4)-1)}' | tr -d '%'")
(defpoll wifi_icon :initial "" :interval "30s" "./scripts/wifi --ICON")
(defpoll wifi_essid :initial "" :interval "30s" "./scripts/wifi --ESSID")
(defpoll wifi_radio :initial "off" :interval "2s" "nmcli radio wifi")
(defpoll calendar_day :initial "1" :interval "20h" "date '+%d'")
(defpoll calendar_year :initial "2000" :interval "20h" "date '+%Y'")
(defpoll bat0 :initial "0" :interval "30s" "bash ./scripts/sys_info --bat")
;; (defpoll baticon :initial "" :interval "30s" "bash ./scripts/sys_info --baticon")
;; (defpoll batstat :interval "30s" "cat /sys/class/power_supply/BAT0/status")
(defpoll homedir :initial "" :interval "24h" "echo ~")

View file

@ -0,0 +1,13 @@
(defvar revealVolume false)
(defvar revealMicrophone false)
(defvar revealBrightness false)
(defvar reveal1 false)
(defvar reveal2 false)
(defvar reveal3 false)
(defvar reveal4 false)
(defvar reveal5 false)
(defvar reveal6 false)
(defvar revealweather false)
(defvar revealsystray false)
(defvar revealcontrolpanel false)

View file

@ -3,10 +3,8 @@
:geometry (geometry
:x "0%"
:y "0%"
:width "42"
:height "1080"
:anchor "center left")
;; :reserve (struts :distance "60" :side "left")
; :reserve (struts :distance "60" :side "left")
;; :stacking "bg"
:exclusive true
:monitor 0
@ -65,7 +63,7 @@
:class "bottom_modules"
:vexpand false
:hexpand false
(stray)
; (stray)
(sliders)
(clock)
; (battery)
@ -216,7 +214,7 @@
(label :class "picon" :text "󰒭"))
)))
(defwidget sliders []
(defwidget sliders []
(box
:class "widget"
:orientation "v"
@ -227,8 +225,8 @@
(label :class "icon" :style "font-size: 18px;" :text wifi_icon))
(reveal_on_hover
:revealval reveal1
:revealvalstr "reveal1"
:var revealVolume
:varname "revealVolume"
(box
:orientation "v"
:space-evenly false
@ -247,8 +245,8 @@
:flipped true))
(reveal_on_hover
:revealval reveal2
:revealvalstr "reveal2"
:var revealMicrophone
:varname "revealMicrophone"
(box
:orientation "v"
:space-evenly false
@ -258,17 +256,17 @@
)
(scale
:class "volslide"
:value volume
:value mic_volume
:onchange "pactl set-source-volume @DEFAULT_SOURCE@ {}%"
:orientation "v"
:tooltip "${volume}%"
:max 100
:tooltip "${mic_volume}%"
:max 101
:min 0
:flipped true))
(reveal_on_hover
:revealval reveal5
:revealvalstr "reveal5"
:var revealBrightness
:varname "revealBrightness"
(box
:orientation "v"
:space-evenly false
@ -285,25 +283,6 @@
:flipped true))
))
(defwidget reveal_on_hover [revealval revealvalstr ?class ?transition]
(box
:class "reveal_on_hover ${class}"
:orientation "v"
:space-evenly false
:valign "end"
(eventbox
:onhover `${EWW_CMD} update ${revealvalstr}=true`
:onhoverlost `${EWW_CMD} update ${revealvalstr}=false`
(box
:space-evenly false
:orientation "v"
(children :nth 0)
(revealer
:reveal revealval
:transition {transition ?:"slidedown"}
:duration "500ms"
(children :nth 1))))))
;; other windows
(defwindow calendar
:geometry (geometry :x "0"

View file

@ -0,0 +1,47 @@
(defwidget hovered-sign [var]
(box :space-evenly false
(revealer :reveal {!var}
:duration "100ms"
:transition "slideleft"
(children :nth 0))
(revealer :reveal {var}
:duration "100ms"
:transition "slideleft"
(children :nth 1))))
(defwidget reveal_on_hover [var varname ?class ?duration ?transition]
(box
:class "reveal_on_hover ${class}"
:orientation "v"
:space-evenly false
:valign "end"
(eventbox
:onhover `${EWW_CMD} update ${varname}=true`
:onhoverlost `${EWW_CMD} update ${varname}=false`
(box
:space-evenly false
:orientation "v"
(children :nth 0)
(revealer
:reveal var
:transition {transition ?:"slidedown"}
:duration "500ms"
(children :nth 1))))))
(defwidget clickbox [var varname ?class ?duration ?transition]
(box :class "${class} clickbox" :orientation "h" :space-evenly false
(button :onclick "eww update ${varname}=${ var ? false : true }"
(children :nth 0)
)
(revealer :reveal var
:transition {transition ?: "slideleft"}
:duration {duration ?: "500ms"}
(box :class "${class}"
:space-evenly false
(children :nth 1)
(button :onclick "eww update ${varname}=false" :class "close" (label :text "Close"))
)
)
)
)