From 8c57a511a35702ddf354f3cb52e04228a36bee82 Mon Sep 17 00:00:00 2001 From: Ryan Schanzenbacher Date: Thu, 9 Jul 2026 22:38:13 -0400 Subject: fix simplebar bugs --- users/ryan/modules/simple-bar/default.nix | 2 +- .../lib/components/data/battery.jsx | 4 ++-- .../lib/components/data/sound.jsx | 22 ++++++++++++---------- users/ryan/modules/simple-bar/simplebarrc | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/users/ryan/modules/simple-bar/default.nix b/users/ryan/modules/simple-bar/default.nix index a309f61..e05fe08 100644 --- a/users/ryan/modules/simple-bar/default.nix +++ b/users/ryan/modules/simple-bar/default.nix @@ -4,7 +4,7 @@ with lib; let cfg = config.ryan.simple-bar; - "simple-bar-upstream" = ./simple-bar-source + "simple-bar-upstream" = ./simple-bar-source; in { options.ryan.simple-bar.enable = mkEnableOption "simple-bar"; diff --git a/users/ryan/modules/simple-bar/simple-bar-source/lib/components/data/battery.jsx b/users/ryan/modules/simple-bar/simple-bar-source/lib/components/data/battery.jsx index 1f08af6..bfef8f0 100755 --- a/users/ryan/modules/simple-bar/simple-bar-source/lib/components/data/battery.jsx +++ b/users/ryan/modules/simple-bar/simple-bar-source/lib/components/data/battery.jsx @@ -68,7 +68,7 @@ export const Widget = React.memo(() => { `pmset -g batt | head -1 | grep -q 'AC Power' && echo 'AC' || echo 'Batt'`, refresh, ), - Uebersicht.run(`pgrep caffeinate -d`), + Uebersicht.run(`pgrep caffeinate`), Utils.cachedRun( `pmset -g | awk '/lowpowermode|powermode/ {print $2; exit}'`, refresh, @@ -172,7 +172,7 @@ function getTransform(value) { */ async function toggleCaffeinate(system, caffeinate, option, pushMissive) { const command = - system === "x86_64" ? "caffeinate" : "arch -arch arm64 caffeinate"; + system === "x86_64" ? "caffeinate -d" : "arch -arch arm64 caffeinate -d"; if (caffeinate.length === 0) { Uebersicht.run(`${command} ${option} &`); Utils.notification("Enabling caffeinate...", pushMissive); diff --git a/users/ryan/modules/simple-bar/simple-bar-source/lib/components/data/sound.jsx b/users/ryan/modules/simple-bar/simple-bar-source/lib/components/data/sound.jsx index 7301426..a3c5cab 100755 --- a/users/ryan/modules/simple-bar/simple-bar-source/lib/components/data/sound.jsx +++ b/users/ryan/modules/simple-bar/simple-bar-source/lib/components/data/sound.jsx @@ -58,7 +58,7 @@ export const Widget = React.memo(() => { `osascript -e 'set v to get volume settings' -e 'output volume of v & output muted of v'`, refresh, ); - const parts = Utils.cleanupOutput(output).split(","); + const parts = Utils.cleanupOutput(output).split(", "); setState({ volume: parts[0], muted: parts[1], @@ -71,11 +71,6 @@ export const Widget = React.memo(() => { // Refresh the widget at the specified interval. useWidgetRefresh(visible, getSound, refresh); - // Update the sound settings when dragging ends. - React.useEffect(() => { - if (!dragging) setSound(volume); - }, [dragging, volume]); - // Update the volume state when the fetched volume changes. React.useEffect(() => { setVolume((currentVolume) => { @@ -106,8 +101,14 @@ export const Widget = React.memo(() => { setVolume(value); }; - const onMouseDown = () => setDragging(true); - const onMouseUp = () => setDragging(false); + const onInteractionEnd = (e) => { + setDragging(false); + const finalVolume = parseInt(e.target.value, 10); + setSound(finalVolume); + }; + + // const onMouseDown = () => setDragging(true); + // const onMouseUp = () => setDragging(false); const formattedVolume = `${volume.toString().padStart(2, "0")}%`; @@ -133,8 +134,9 @@ export const Widget = React.memo(() => { step="1" value={volume} className="sound__slider" - onMouseDown={onMouseDown} - onMouseUp={onMouseUp} + onMouseDown={() => setDragging(true)} + onMouseUp={onInteractionEnd} + onKeyUp={onInteractionEnd} onChange={onChange} /> diff --git a/users/ryan/modules/simple-bar/simplebarrc b/users/ryan/modules/simple-bar/simplebarrc index 5c5153d..1494208 100644 --- a/users/ryan/modules/simple-bar/simplebarrc +++ b/users/ryan/modules/simple-bar/simplebarrc @@ -179,7 +179,7 @@ "showMic": true }, "soundWidgetOptions": { - "refreshFrequency": 20000, + "refreshFrequency": 5000, "showOnDisplay": "", "showIcon": true }, -- cgit v1.3