From 76d8a54c0d9e188fad09573a17b95e0018460e65 Mon Sep 17 00:00:00 2001 From: Chintan Patel <216989679+Chintanpatel24@users.noreply.github.com> Date: Wed, 21 Oct 2026 23:06:44 +0530 Subject: [PATCH 1/3] feat(sounds): fix sound playback engine and wire full desktop audio feedback - Replace dynamic Process allocation/destruction in SoundService with persistent 4-slot Process pool - Add direct PipeWire (pw-play) and PulseAudio (paplay) execution with search path fallbacks - Add battery state transitions to SystemInfoService: battery-charge on plug-in, battery-warning on unplug and 20% threshold, battery-low at 10% - Wire widget-placed and widget-removed for standalone windows (Settings, PackageManager) in WidgetLoader - Add Audition Sound Theme 'Test Sound' button to EffectsSettings - Add confirm audio chime on custom shortcut addition --- .../agility/Core/Services/SoundService.qml | 57 ++++++++++--------- .../Core/Services/SystemInfoService.qml | 36 ++++++++++++ .../agility/Core/Windows/WidgetLoader.qml | 5 +- .../EffectsSettings/EffectsSettings.qml | 47 +++++++++++++++ .../InputAndClipboardSettings.qml | 1 + 5 files changed, 117 insertions(+), 29 deletions(-) diff --git a/quickshell/agility/Core/Services/SoundService.qml b/quickshell/agility/Core/Services/SoundService.qml index 79602627..41061b8c 100644 --- a/quickshell/agility/Core/Services/SoundService.qml +++ b/quickshell/agility/Core/Services/SoundService.qml @@ -9,9 +9,18 @@ Item { id: root property var _lastPlayed: ({}) + property int _procIdx: 0 - function play(soundName, minIntervalMs = 70) { - if (!SettingsService.soundEffectsEnabled) + // Pool of static Process runners for zero-latency, concurrent audio playback + Process { id: p0 } + Process { id: p1 } + Process { id: p2 } + Process { id: p3 } + + readonly property var _procs: [p0, p1, p2, p3] + + function play(soundName, minIntervalMs = 60) { + if (!soundName || !SettingsService.soundEffectsEnabled) return; let now = Date.now(); @@ -19,31 +28,23 @@ Item { return; _lastPlayed[soundName] = now; - let proc = soundComp.createObject(root, { - "soundName": soundName - }); - if (proc) { - proc.running = true; - } - } - - Component { - id: soundComp - - Process { - id: procItem - property string soundName: "" - - command: [ - "sh", "-c", - "if command -v agl >/dev/null 2>&1; then agl sound play " + soundName + "; elif command -v pw-play >/dev/null 2>&1; then for d in ~/.config/agility-shell/sounds /usr/share/agility-shell/sounds ./sounds; do [ -f \"$d/" + soundName + ".wav\" ] && exec pw-play \"$d/" + soundName + ".wav\"; done; elif command -v paplay >/dev/null 2>&1; then for d in ~/.config/agility-shell/sounds /usr/share/agility-shell/sounds ./sounds; do [ -f \"$d/" + soundName + ".wav\" ] && exec paplay \"$d/" + soundName + ".wav\"; done; fi" - ] - - onRunningChanged: { - if (!running) { - procItem.destroy(); - } - } - } + let soundFile = soundName + ".wav"; + let proc = _procs[_procIdx % _procs.length]; + _procIdx++; + + proc.command = [ + "sh", "-c", + "for p in \"$HOME/.config/agility-shell/sounds/" + soundFile + "\" \"/usr/share/agility-shell/sounds/" + soundFile + "\" \"" + Quickshell.shellDir + "/../../sounds/" + soundFile + "\"; do " + + " if [ -f \"$p\" ]; then " + + " if command -v pw-play >/dev/null 2>&1; then exec pw-play \"$p\"; " + + " elif command -v paplay >/dev/null 2>&1; then exec paplay \"$p\"; " + + " elif command -v aplay >/dev/null 2>&1; then exec aplay -q \"$p\"; fi; " + + " break; " + + " fi; " + + "done; " + + "if command -v agl >/dev/null 2>&1; then exec agl sound play " + soundName + " >/dev/null 2>&1; fi" + ]; + proc.running = false; + proc.running = true; } } diff --git a/quickshell/agility/Core/Services/SystemInfoService.qml b/quickshell/agility/Core/Services/SystemInfoService.qml index 9e8b7d1d..5d79837a 100644 --- a/quickshell/agility/Core/Services/SystemInfoService.qml +++ b/quickshell/agility/Core/Services/SystemInfoService.qml @@ -2,6 +2,7 @@ import QtQuick import Quickshell import Quickshell.Io import qs.Core +import qs.Core.Services pragma Singleton Item { @@ -35,6 +36,41 @@ Item { property int batteryLevel: 100 readonly property string batteryPercentage: batteryLevel + "%" property string batteryStatus: "" + property string _prevBatteryStatus: "" + property int _prevBatteryLevel: -1 + property bool _batteryInitialized: false + + onBatteryStatusChanged: { + if (!_batteryInitialized) { + if (batteryStatus !== "") { + _batteryInitialized = true; + _prevBatteryStatus = batteryStatus; + _prevBatteryLevel = batteryLevel; + } + return; + } + + if (batteryStatus !== _prevBatteryStatus && batteryStatus !== "") { + if (batteryStatus === "Charging") { + SoundService.play("battery-charge"); + } else if (_prevBatteryStatus === "Charging" && batteryStatus === "Discharging") { + SoundService.play("battery-warning"); + } + _prevBatteryStatus = batteryStatus; + } + } + + onBatteryLevelChanged: { + if (!_batteryInitialized || batteryStatus === "Charging") + return; + + if (_prevBatteryLevel > 20 && batteryLevel <= 20 && batteryLevel > 10) { + SoundService.play("battery-warning"); + } else if (_prevBatteryLevel > 10 && batteryLevel <= 10) { + SoundService.play("battery-low"); + } + _prevBatteryLevel = batteryLevel; + } property string batteryEstimation: { if (!hasBattery) return "Continuous power supply active"; diff --git a/quickshell/agility/Core/Windows/WidgetLoader.qml b/quickshell/agility/Core/Windows/WidgetLoader.qml index bf689088..8cc77e80 100644 --- a/quickshell/agility/Core/Windows/WidgetLoader.qml +++ b/quickshell/agility/Core/Windows/WidgetLoader.qml @@ -31,12 +31,15 @@ Item { loader.active = true; if (loader.status === Loader.Ready && loader.item) loader.item.isOpen = true; - + if (AppState.isStandaloneWindow(widgetId)) + SoundService.play("widget-placed"); } else { if (loader.item) loader.item.isOpen = false; _isClosing = true; + if (AppState.isStandaloneWindow(widgetId)) + SoundService.play("widget-removed"); } } diff --git a/quickshell/agility/Modules/Settings/EffectsSettings/EffectsSettings.qml b/quickshell/agility/Modules/Settings/EffectsSettings/EffectsSettings.qml index ffa19eae..e23188a7 100644 --- a/quickshell/agility/Modules/Settings/EffectsSettings/EffectsSettings.qml +++ b/quickshell/agility/Modules/Settings/EffectsSettings/EffectsSettings.qml @@ -1,4 +1,5 @@ import QtQuick +import QtQuick.Controls import QtQuick.Layouts import qs.Core import qs.Core.Components @@ -52,6 +53,52 @@ AppContainer { } } } + + Divider { + Layout.fillWidth: true + visible: true + } + + SettingRowTemplate { + label: "Audition Sound Theme" + description: "Play a preview sound effect to verify audio feedback" + + Button { + id: testSoundBtn + text: "▶ Play Test Sound" + enabled: SettingsService.soundEffectsEnabled + opacity: enabled ? 1.0 : 0.5 + font.family: Constants.fontFamily + font.pixelSize: Math.round(11 * SettingsService.fontScale) + font.weight: Font.DemiBold + implicitHeight: 32 + implicitWidth: 140 + contentItem: ThemedText { + text: testSoundBtn.text + font.family: Constants.fontFamily + font.pixelSize: Math.round(11 * SettingsService.fontScale) + font.weight: Font.DemiBold + color: testSoundBtn.enabled ? (testSoundBtn.hovered ? Theme.bg : Theme.accent) : Theme.muted + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + background: Rectangle { + color: testSoundBtn.enabled && testSoundBtn.hovered ? Theme.accent : Theme.bg + border.color: testSoundBtn.enabled ? Theme.accent : Theme.borderSecondary + border.width: 1 + radius: Constants.sizeXs + + Behavior on color { + ColorAnimation { + duration: Constants.animFast + } + } + } + onClicked: { + SoundService.play("confirm", 0); + } + } + } } AppGroup { diff --git a/quickshell/agility/Modules/Settings/InputAndClipboardSettings/InputAndClipboardSettings.qml b/quickshell/agility/Modules/Settings/InputAndClipboardSettings/InputAndClipboardSettings.qml index 9c3a3907..740a0405 100644 --- a/quickshell/agility/Modules/Settings/InputAndClipboardSettings/InputAndClipboardSettings.qml +++ b/quickshell/agility/Modules/Settings/InputAndClipboardSettings/InputAndClipboardSettings.qml @@ -320,6 +320,7 @@ AppContainer { }); SettingsService.customShortcuts = updated; SettingsService.saveSettings(); + SoundService.play("confirm"); newShortcutName.text = ""; newShortcutKeyPill.keyText = ""; newShortcutCmd.text = ""; From 1a09bfeb5d83458cd546e01f71435ddde6d80790 Mon Sep 17 00:00:00 2001 From: Chintan Patel <216989679+Chintanpatel24@users.noreply.github.com> Date: Wed, 21 Oct 2026 23:30:04 +0530 Subject: [PATCH 2/3] feat(osd, clock): add volume/brightness floating OSD pill and focus pomodoro timer with alarm sound --- agility-shell | 4 +- crates/agility-cli/src/main.rs | 193 +++++++++--- .../Core/Services/FocusTimerService.qml | 92 ++++++ .../agility/Core/Services/OsdService.qml | 120 ++++++++ .../Bar/Widgets/Clock/ClockContent.qml | 286 +++++++++++++++++- quickshell/agility/Modules/OSD/OsdPill.qml | 127 ++++++++ quickshell/agility/shell.qml | 32 ++ 7 files changed, 789 insertions(+), 65 deletions(-) create mode 100644 quickshell/agility/Core/Services/FocusTimerService.qml create mode 100644 quickshell/agility/Core/Services/OsdService.qml create mode 100644 quickshell/agility/Modules/OSD/OsdPill.qml diff --git a/agility-shell b/agility-shell index 6e540720..eede3439 100755 --- a/agility-shell +++ b/agility-shell @@ -39,11 +39,11 @@ for cand in \ done # If already running: toggle launcher/dashboard -if pgrep -x "quickshell" >/dev/null 2>&1; then +if pgrep -f "quickshell.*agility" >/dev/null 2>&1 || pgrep -f "agility.*shell.qml" >/dev/null 2>&1; then if command -v agl >/dev/null 2>&1; then agl toggle launcher >/dev/null 2>&1 || true elif command -v qs >/dev/null 2>&1; then - qs ipc call launcher toggle >/dev/null 2>&1 || true + qs ipc -i agility-shell call launcher toggle >/dev/null 2>&1 || true elif [[ -x "$SELF_DIR/target/release/agl" ]]; then "$SELF_DIR/target/release/agl" toggle launcher >/dev/null 2>&1 || true fi diff --git a/crates/agility-cli/src/main.rs b/crates/agility-cli/src/main.rs index e8e4fa19..9698e8a1 100644 --- a/crates/agility-cli/src/main.rs +++ b/crates/agility-cli/src/main.rs @@ -168,6 +168,12 @@ enum Commands { /// Optional transition duration in seconds #[arg(long)] duration: Option, + /// Optional transition center position (e.g. "center" or "500,300") + #[arg(long)] + pos: Option, + /// Skip awww dispatch if already dispatched by fast path + #[arg(long)] + skip_backend: bool, /// Output list in JSON format #[arg(long)] json: bool, @@ -206,8 +212,20 @@ async fn main() -> Result<()> { action, transition, duration, + pos, + skip_backend, json, - } => handle_wallpaper(&action, transition.as_deref(), duration, json).await?, + } => { + handle_wallpaper( + &action, + transition.as_deref(), + duration, + pos.as_deref(), + skip_backend, + json, + ) + .await? + } Commands::Auth { args } => { std::process::exit(tools::auth::run(&args)); } @@ -331,9 +349,9 @@ async fn handle_start(legacy: bool) -> Result<()> { println!("✓ Spawned awww-daemon."); } - let quickshell_pid = get_process_pid("quickshell"); + let quickshell_pid = get_agility_quickshell_pid(); if let Some(pid) = quickshell_pid { - println!("ℹ quickshell is already running (PID: {pid})."); + println!("ℹ quickshell (agility) is already running (PID: {pid})."); } else { let shell_qml = locate_shell_qml(); if let Some(path) = shell_qml { @@ -379,8 +397,13 @@ async fn handle_stop() -> Result<()> { .status(); } - // Gracefully terminate daemon and frontend - let _ = Command::new("killall").arg("-q").arg("quickshell").status(); + // Gracefully terminate daemon and agility frontend + for pid in get_agility_quickshell_pids() { + let _ = Command::new("kill") + .arg("-15") + .arg(pid.to_string()) + .status(); + } let _ = Command::new("killall").arg("-q").arg("agilityd").status(); let _ = Command::new("killall") .arg("-q") @@ -430,13 +453,15 @@ async fn handle_status() -> Result<()> { } // Quickshell process check - let qs_pid = get_process_pid("quickshell"); + let qs_pid = get_agility_quickshell_pid(); match qs_pid { Some(pid) => { let rss = get_process_rss_mb(pid); - println!("● Frontend (quickshell): RUNNING (PID: {pid}, Memory: {rss:.1} MB RSS)"); + println!( + "● Frontend (quickshell - agility): RUNNING (PID: {pid}, Memory: {rss:.1} MB RSS)" + ); } - None => println!("○ Frontend (quickshell): STOPPED"), + None => println!("○ Frontend (quickshell - agility): STOPPED"), } // Total memory calculation @@ -1464,6 +1489,31 @@ fn is_command_available(cmd: &str) -> bool { .unwrap_or(false) } +fn get_agility_quickshell_pids() -> Vec { + let mut pids = Vec::new(); + if let Ok(out) = Command::new("pgrep").arg("-a").arg("quickshell").output() { + if out.status.success() { + let s = String::from_utf8_lossy(&out.stdout); + for line in s.lines() { + let parts: Vec<&str> = line.split_whitespace().collect(); + if parts.len() >= 2 { + let cmdline = parts[1..].join(" "); + if cmdline.contains("agility") || cmdline.contains("agility-shell") { + if let Ok(pid) = parts[0].parse::() { + pids.push(pid); + } + } + } + } + } + } + pids +} + +fn get_agility_quickshell_pid() -> Option { + get_agility_quickshell_pids().into_iter().next() +} + fn get_process_pid(proc_name: &str) -> Option { let out = Command::new("pgrep") .arg("-x") @@ -1551,10 +1601,11 @@ fn dispatch_qs_ipc(target: &str, func: &str, args: &[&str]) -> bool { let qml_path = locate_shell_qml(); let mut cmd = Command::new("quickshell"); + cmd.arg("ipc"); if let Some(ref p) = qml_path { cmd.args(["-p", p.to_str().unwrap_or("")]); } - cmd.args(["ipc", "call", target, func]); + cmd.args(["call", target, func]); for a in args { cmd.arg(*a); } @@ -1565,10 +1616,11 @@ fn dispatch_qs_ipc(target: &str, func: &str, args: &[&str]) -> bool { } let mut fallback = Command::new("qs"); + fallback.arg("ipc"); if let Some(ref p) = qml_path { fallback.args(["-p", p.to_str().unwrap_or("")]); } - fallback.args(["ipc", "call", target, func]); + fallback.args(["call", target, func]); for a in args { fallback.arg(*a); } @@ -1785,6 +1837,22 @@ fn expand_user_path(p: &str) -> std::path::PathBuf { Path::new(trimmed).to_path_buf() } +fn get_custom_wallpaper_dir() -> Option { + let home = std::env::var("HOME").ok()?; + let prefs_path = Path::new(&home).join(".cache/quickshell/settings_prefs.json"); + let content = fs::read_to_string(&prefs_path).ok()?; + let val: serde_json::Value = serde_json::from_str(&content).ok()?; + if val.get("wpSourceMode").and_then(|v| v.as_str()) == Some("custom") { + if let Some(folder) = val.get("wpCustomFolderPath").and_then(|v| v.as_str()) { + let expanded = expand_user_path(folder); + if expanded.is_dir() { + return Some(expanded); + } + } + } + None +} + fn resolve_cli_wallpaper(path_str: &str) -> Option { let trimmed = path_str.trim(); if trimmed.is_empty() { @@ -1799,6 +1867,10 @@ fn resolve_cli_wallpaper(path_str: &str) -> Option { let file_name = direct.file_name()?.to_str()?; let mut search_dirs = Vec::new(); + if let Some(custom_dir) = get_custom_wallpaper_dir() { + search_dirs.push(custom_dir); + } + if let Ok(home) = std::env::var("HOME") { search_dirs.push(Path::new(&home).join(".local/share/agility-shell/wallpapers")); search_dirs.push(Path::new(&home).join(".config/agility-shell/wallpapers")); @@ -1823,17 +1895,22 @@ fn resolve_cli_wallpaper(path_str: &str) -> Option { fn list_cli_wallpapers() -> Vec { let mut search_dirs = Vec::new(); - if let Ok(home) = std::env::var("HOME") { - search_dirs.push(Path::new(&home).join(".local/share/agility-shell/wallpapers")); - search_dirs.push(Path::new(&home).join(".config/agility-shell/wallpapers")); - search_dirs.push(Path::new(&home).join("Pictures/Wallpapers")); - search_dirs.push(Path::new(&home).join("Pictures")); - } - if let Ok(data_home) = std::env::var("XDG_DATA_HOME") { - search_dirs.push(Path::new(&data_home).join("agility-shell/wallpapers")); + + if let Some(custom_dir) = get_custom_wallpaper_dir() { + search_dirs.push(custom_dir); + } else { + if let Ok(home) = std::env::var("HOME") { + search_dirs.push(Path::new(&home).join(".local/share/agility-shell/wallpapers")); + search_dirs.push(Path::new(&home).join(".config/agility-shell/wallpapers")); + search_dirs.push(Path::new(&home).join("Pictures/Wallpapers")); + search_dirs.push(Path::new(&home).join("Pictures")); + } + if let Ok(data_home) = std::env::var("XDG_DATA_HOME") { + search_dirs.push(Path::new(&data_home).join("agility-shell/wallpapers")); + } + search_dirs.push(Path::new("/usr/share/agility-shell/wallpapers").to_path_buf()); + search_dirs.push(Path::new("wallpapers").to_path_buf()); } - search_dirs.push(Path::new("/usr/share/agility-shell/wallpapers").to_path_buf()); - search_dirs.push(Path::new("wallpapers").to_path_buf()); let mut found = Vec::new(); let mut seen_names = std::collections::HashSet::new(); @@ -1885,6 +1962,8 @@ async fn handle_wallpaper( action: &str, transition: Option<&str>, duration: Option, + pos: Option<&str>, + skip_backend: bool, json: bool, ) -> Result<()> { let action_lower = action.trim().to_lowercase(); @@ -1986,12 +2065,12 @@ async fn handle_wallpaper( let picked = &walls[idx]; let path_str = picked.to_string_lossy().to_string(); // Apply this chosen wallpaper - apply_cli_wallpaper(&path_str, transition, duration).await?; + apply_cli_wallpaper(&path_str, transition, duration, pos, skip_backend).await?; println!("{path_str}"); } _ => { // Target is a path or filename - apply_cli_wallpaper(action, transition, duration).await?; + apply_cli_wallpaper(action, transition, duration, pos, skip_backend).await?; } } @@ -2002,10 +2081,16 @@ async fn apply_cli_wallpaper( path_str: &str, transition: Option<&str>, duration: Option, + pos: Option<&str>, + skip_backend: bool, ) -> Result<()> { // 1. Try D-Bus SetWallpaper if let Ok(conn) = Connection::session().await { - let t_type = transition.unwrap_or(""); + let t_type = if skip_backend { + "skip" + } else { + transition.unwrap_or("") + }; let dur = duration.unwrap_or(0.0); if let Ok(reply) = conn .call_method( @@ -2031,33 +2116,41 @@ async fn apply_cli_wallpaper( resolve_cli_wallpaper(path_str).context(format!("Wallpaper file not found: {path_str}"))?; let abs_str = resolved.to_string_lossy().to_string(); - // Ensure awww-daemon is running - if is_command_available("awww-daemon") && get_process_pid("awww-daemon").is_none() { - let _ = Command::new("awww-daemon").spawn(); - } - - // Dispatch awww img with ultra-fast bilinear filter and 60fps step - if is_command_available("awww") { - let mut cmd = Command::new("awww"); - let t_type = transition.unwrap_or("grow"); - let dur_str = format!("{:.2}", duration.unwrap_or(0.2)); - cmd.args([ - "img", - &abs_str, - "--resize", - "crop", - "--filter", - "Bilinear", - "--transition-type", - t_type, - "--transition-duration", - &dur_str, - "--transition-step", - "180", - "--transition-fps", - "60", - ]); - let _ = cmd.spawn(); + if !skip_backend { + // Ensure awww-daemon is running + if is_command_available("awww-daemon") && get_process_pid("awww-daemon").is_none() { + let _ = Command::new("awww-daemon").spawn(); + } + + // Dispatch awww img with ultra-fast bilinear filter and 60fps step + if is_command_available("awww") { + let mut cmd = Command::new("awww"); + let t_type = transition.unwrap_or("grow"); + let dur_str = format!("{:.2}", duration.unwrap_or(0.2)); + cmd.args([ + "img", + &abs_str, + "--resize", + "crop", + "--filter", + "Bilinear", + "--transition-type", + t_type, + "--transition-duration", + &dur_str, + "--transition-step", + "180", + "--transition-fps", + "60", + ]); + if let Some(p) = pos { + if p.contains(',') { + cmd.arg("--invert-y"); + } + cmd.args(["--transition-pos", p]); + } + let _ = cmd.spawn(); + } } // Write caches diff --git a/quickshell/agility/Core/Services/FocusTimerService.qml b/quickshell/agility/Core/Services/FocusTimerService.qml new file mode 100644 index 00000000..94ace437 --- /dev/null +++ b/quickshell/agility/Core/Services/FocusTimerService.qml @@ -0,0 +1,92 @@ +pragma Singleton +import QtQuick +import Quickshell +import qs.Core +import qs.Core.Services + +Item { + id: root + + property int totalSeconds: 25 * 60 + property int remainingSeconds: 25 * 60 + property bool isRunning: false + property string activeMode: "focus" // "focus", "shortBreak", "longBreak" + + readonly property real progress: totalSeconds > 0 ? Math.min(1.0, Math.max(0.0, 1.0 - (remainingSeconds / totalSeconds))) : 0 + readonly property string formattedTime: { + let mins = Math.floor(remainingSeconds / 60); + let secs = remainingSeconds % 60; + return mins.toString().padStart(2, "0") + ":" + secs.toString().padStart(2, "0"); + } + + signal timerFinished(string mode) + + Timer { + id: ticker + + interval: 1000 + running: root.isRunning + repeat: true + onTriggered: { + if (root.remainingSeconds > 1) { + root.remainingSeconds--; + } else if (root.remainingSeconds === 1) { + root.remainingSeconds = 0; + root.isRunning = false; + SoundService.play("alarm"); + root.timerFinished(root.activeMode); + + if (root.activeMode === "focus") { + NotificationService.notify("Focus Session Complete! 🎯", "Great job! Time to take a short break.", "clock", "Focus Timer"); + } else { + NotificationService.notify("Break Over! ⚡", "Ready to dive back into focus?", "clock", "Focus Timer"); + } + } else { + root.isRunning = false; + } + } + } + + function setMode(mode) { + if (root.isRunning) + root.isRunning = false; + + root.activeMode = mode; + if (mode === "focus") { + root.totalSeconds = 25 * 60; + } else if (mode === "shortBreak") { + root.totalSeconds = 5 * 60; + } else if (mode === "longBreak") { + root.totalSeconds = 15 * 60; + } + root.remainingSeconds = root.totalSeconds; + SoundService.play("confirm"); + } + + function toggle() { + if (root.isRunning) { + pause(); + } else { + start(); + } + } + + function start() { + if (root.remainingSeconds <= 0) + root.remainingSeconds = root.totalSeconds; + + root.isRunning = true; + SoundService.play("confirm"); + } + + function pause() { + root.isRunning = false; + SoundService.play("confirm"); + } + + function reset() { + root.isRunning = false; + root.remainingSeconds = root.totalSeconds; + SoundService.play("confirm"); + } +} diff --git a/quickshell/agility/Core/Services/OsdService.qml b/quickshell/agility/Core/Services/OsdService.qml new file mode 100644 index 00000000..92f2be6a --- /dev/null +++ b/quickshell/agility/Core/Services/OsdService.qml @@ -0,0 +1,120 @@ +pragma Singleton +import QtQuick +import Quickshell +import Quickshell.Io +import Quickshell.Services.Pipewire +import qs.Core +import qs.Core.Services + +Item { + id: root + + property var sink: Pipewire.defaultAudioSink + property int currentVolume: (sink && sink.audio) ? Math.round(sink.audio.volume * 100) : 0 + property bool isMuted: (sink && sink.audio) ? sink.audio.muted : false + property int currentBrightness: 100 + + property bool isVisible: false + property string activeType: "volume" // "volume", "brightness" + property int displayValue: 0 + property string displayIcon: "volume" + property string displayLabel: "Volume" + + signal triggered() + + function showVolume(step) { + activeType = "volume"; + displayValue = isMuted ? 0 : currentVolume; + displayIcon = (isMuted || displayValue === 0) ? "volume-off" : "volume"; + displayLabel = isMuted ? "Audio Muted" : ("Volume " + displayValue + "%"); + triggerOsd(); + } + + function showBrightness(step) { + activeType = "brightness"; + brightGetProc.running = false; + brightGetProc.running = true; + } + + function triggerOsd() { + isVisible = true; + hideTimer.restart(); + triggered(); + } + + property int _lastMonitoredVol: -1 + property bool _lastMonitoredMute: false + property bool _initialized: false + + onCurrentVolumeChanged: { + if (!_initialized) + return; + + if (_lastMonitoredVol !== currentVolume) { + _lastMonitoredVol = currentVolume; + showVolume(); + } + } + + onIsMutedChanged: { + if (!_initialized) + return; + + if (_lastMonitoredMute !== isMuted) { + _lastMonitoredMute = isMuted; + showVolume(); + } + } + + Timer { + id: initTimer + + interval: 1200 + running: true + repeat: false + onTriggered: { + root._lastMonitoredVol = root.currentVolume; + root._lastMonitoredMute = root.isMuted; + root._initialized = true; + } + } + + Timer { + id: hideTimer + + interval: 1600 + repeat: false + onTriggered: { + root.isVisible = false; + } + } + + Process { + id: brightGetProc + + command: ["brightnessctl", "-m"] + + stdout: SplitParser { + onRead: (data) => { + if (!data) + return; + + let parts = data.trim().split(","); + if (parts.length >= 4) { + let pct = parseInt(parts[3].replace("%", "")); + if (!isNaN(pct)) { + root.currentBrightness = pct; + root.displayValue = pct; + root.displayIcon = "sun"; + root.displayLabel = "Brightness " + pct + "%"; + root.triggerOsd(); + } + } + } + } + } + + PwObjectTracker { + objects: [Pipewire.defaultAudioSink] + } +} diff --git a/quickshell/agility/Modules/Bar/Widgets/Clock/ClockContent.qml b/quickshell/agility/Modules/Bar/Widgets/Clock/ClockContent.qml index 7dc103cc..2483b0e3 100644 --- a/quickshell/agility/Modules/Bar/Widgets/Clock/ClockContent.qml +++ b/quickshell/agility/Modules/Bar/Widgets/Clock/ClockContent.qml @@ -10,8 +10,8 @@ Item { property var widget: null property date now: new Date() - implicitWidth: 300 - implicitHeight: 95 + implicitWidth: 320 + implicitHeight: 250 width: implicitWidth height: implicitHeight @@ -25,10 +25,10 @@ Item { ColumnLayout { anchors.fill: parent - anchors.margins: Constants.size2Xs + anchors.margins: Constants.sizeXs spacing: Constants.sizeXs - // Header: Big Time & Format Controls + // SECTION 1: Clock & Date Header RowLayout { Layout.fillWidth: true spacing: Constants.sizeSm @@ -43,7 +43,7 @@ Item { return h + ":" + m; } font.bold: true - customSize: Constants.size4Xl - 4 + customSize: Constants.size4Xl - 6 color: Theme.barFg } @@ -55,8 +55,8 @@ Item { visible: !SettingsService.clock24h color: Theme.barBgSecondary radius: Constants.sizeXs - 2 - Layout.preferredWidth: apText.implicitWidth + 10 - Layout.preferredHeight: Constants.sizeLg + 2 + Layout.preferredWidth: apText.implicitWidth + 8 + Layout.preferredHeight: Constants.sizeLg ThemedText { id: apText @@ -67,7 +67,6 @@ Item { customSize: Constants.sizeXs - 2 color: Theme.isLightBar ? Theme.barFg : Theme.accent } - } ThemedText { @@ -76,7 +75,6 @@ Item { font.bold: true color: Theme.barMuted } - } Item { @@ -91,11 +89,10 @@ Item { Layout.alignment: Qt.AlignVCenter Layout.rightMargin: Constants.size2Xs icon: isDay ? "sun" : "moon-filled" - iconSize: 38 + iconSize: 34 iconColor: Theme.isLightBar ? (isDay ? "#e58e00" : Theme.barFg) : Theme.accent flat: true } - } // Subtitle: Date & Day @@ -105,7 +102,7 @@ Item { SvgIcon { icon: "calendar" - iconSize: 15 + iconSize: 14 iconColor: Theme.isLightBar ? Theme.barFg : Theme.accent flat: true } @@ -118,9 +115,272 @@ Item { Layout.fillWidth: true elide: Text.ElideRight } + } + // Divider + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: 1 + Layout.topMargin: Constants.size3Xs + Layout.bottomMargin: Constants.size3Xs + color: Theme.isLightBar ? Qt.rgba(0, 0, 0, 0.08) : Qt.rgba(255, 255, 255, 0.08) } - } + // SECTION 2: Focus & Pomodoro Timer + RowLayout { + Layout.fillWidth: true + spacing: Constants.sizeXs + + SvgIcon { + icon: "clock" + iconSize: 14 + iconColor: Theme.isLightBar ? Theme.barFg : Theme.accent + flat: true + } + + ThemedText { + text: "Focus Timer" + font.bold: true + customSize: Constants.sizeSm + color: Theme.barFg + } + + Item { + Layout.fillWidth: true + } + + // Status Badge + Rectangle { + radius: Constants.sizeXs - 2 + color: FocusTimerService.isRunning + ? (Theme.isLightBar ? Qt.rgba(0, 0, 0, 0.1) : Qt.rgba(255, 255, 255, 0.12)) + : Theme.barBgSecondary + Layout.preferredWidth: statusText.implicitWidth + 12 + Layout.preferredHeight: 18 + ThemedText { + id: statusText + anchors.centerIn: parent + text: FocusTimerService.isRunning + ? (FocusTimerService.activeMode === "focus" ? "FOCUSING" : "BREAK") + : (FocusTimerService.remainingSeconds === 0 ? "DONE" : "READY") + customSize: Constants.sizeXs - 3 + font.bold: true + color: FocusTimerService.isRunning + ? (Theme.isLightBar ? Theme.barFg : Theme.accent) + : Theme.barMuted + } + } + } + + // Countdown Digits & Controls + RowLayout { + Layout.fillWidth: true + spacing: Constants.sizeMd + + ThemedText { + text: FocusTimerService.formattedTime + font.bold: true + customSize: Constants.size4Xl - 6 + color: FocusTimerService.isRunning + ? (Theme.isLightBar ? Theme.barFg : Theme.accent) + : Theme.barFg + } + + Item { + Layout.fillWidth: true + } + + // Start / Pause Button + Rectangle { + id: playBtn + radius: Constants.sizeXs + Layout.preferredWidth: playRow.implicitWidth + 14 + Layout.preferredHeight: 28 + color: playMouse.containsMouse + ? (Theme.isLightBar ? Qt.rgba(0, 0, 0, 0.12) : Qt.rgba(255, 255, 255, 0.16)) + : (FocusTimerService.isRunning + ? (Theme.isLightBar ? Qt.rgba(0, 0, 0, 0.08) : Qt.rgba(255, 255, 255, 0.1)) + : (Theme.isLightBar ? Theme.barFg : Theme.accent)) + + RowLayout { + id: playRow + anchors.centerIn: parent + spacing: Constants.size3Xs + + SvgIcon { + icon: FocusTimerService.isRunning ? "player-pause" : "player-play" + iconSize: 12 + iconColor: playBtn.color === Theme.barFg || (!FocusTimerService.isRunning && !Theme.isLightBar) + ? Theme.barBg + : (Theme.isLightBar ? Theme.barFg : Theme.accent) + flat: true + } + + ThemedText { + text: FocusTimerService.isRunning ? "Pause" : "Start" + font.bold: true + customSize: Constants.sizeXs + color: playBtn.color === Theme.barFg || (!FocusTimerService.isRunning && !Theme.isLightBar) + ? Theme.barBg + : (Theme.isLightBar ? Theme.barFg : Theme.accent) + } + } + + MouseArea { + id: playMouse + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: FocusTimerService.toggle() + } + } + + // Reset Button + Rectangle { + id: resetBtn + radius: Constants.sizeXs + Layout.preferredWidth: 28 + Layout.preferredHeight: 28 + color: resetMouse.containsMouse + ? (Theme.isLightBar ? Qt.rgba(0, 0, 0, 0.1) : Qt.rgba(255, 255, 255, 0.12)) + : Theme.barBgSecondary + + SvgIcon { + anchors.centerIn: parent + icon: "refresh" + iconSize: 13 + iconColor: Theme.barMuted + flat: true + } + + MouseArea { + id: resetMouse + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: FocusTimerService.reset() + } + } + } + + // Progress Bar + Rectangle { + id: progressTrack + Layout.fillWidth: true + Layout.preferredHeight: 4 + radius: 2 + color: Theme.barBgSecondary + clip: true + + Rectangle { + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + width: parent.width * FocusTimerService.progress + radius: 2 + color: Theme.isLightBar ? Theme.barFg : Theme.accent + + Behavior on width { + NumberAnimation { + duration: Constants.animNormal + easing.type: Easing.OutCubic + } + } + } + } + + // Mode Chips + RowLayout { + Layout.fillWidth: true + spacing: Constants.size2Xs + + // Focus Chip + Rectangle { + readonly property bool isSelected: FocusTimerService.activeMode === "focus" + Layout.fillWidth: true + Layout.preferredHeight: 24 + radius: Constants.sizeXs - 2 + color: isSelected + ? (Theme.isLightBar ? Qt.rgba(0, 0, 0, 0.12) : Qt.rgba(255, 255, 255, 0.14)) + : (focusChipMouse.containsMouse ? (Theme.isLightBar ? Qt.rgba(0, 0, 0, 0.06) : Qt.rgba(255, 255, 255, 0.06)) : "transparent") + border.width: isSelected ? 1 : 0 + border.color: Theme.isLightBar ? Theme.barFg : Theme.accent + + ThemedText { + anchors.centerIn: parent + text: "25m Focus" + customSize: Constants.sizeXs - 2 + font.bold: parent.isSelected + color: parent.isSelected ? Theme.barFg : Theme.barMuted + } + + MouseArea { + id: focusChipMouse + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: FocusTimerService.setMode("focus") + } + } + + // Short Break Chip + Rectangle { + readonly property bool isSelected: FocusTimerService.activeMode === "shortBreak" + Layout.fillWidth: true + Layout.preferredHeight: 24 + radius: Constants.sizeXs - 2 + color: isSelected + ? (Theme.isLightBar ? Qt.rgba(0, 0, 0, 0.12) : Qt.rgba(255, 255, 255, 0.14)) + : (shortChipMouse.containsMouse ? (Theme.isLightBar ? Qt.rgba(0, 0, 0, 0.06) : Qt.rgba(255, 255, 255, 0.06)) : "transparent") + border.width: isSelected ? 1 : 0 + border.color: Theme.isLightBar ? Theme.barFg : Theme.accent + + ThemedText { + anchors.centerIn: parent + text: "5m Short Break" + customSize: Constants.sizeXs - 2 + font.bold: parent.isSelected + color: parent.isSelected ? Theme.barFg : Theme.barMuted + } + + MouseArea { + id: shortChipMouse + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: FocusTimerService.setMode("shortBreak") + } + } + + // Long Break Chip + Rectangle { + readonly property bool isSelected: FocusTimerService.activeMode === "longBreak" + Layout.fillWidth: true + Layout.preferredHeight: 24 + radius: Constants.sizeXs - 2 + color: isSelected + ? (Theme.isLightBar ? Qt.rgba(0, 0, 0, 0.12) : Qt.rgba(255, 255, 255, 0.14)) + : (longChipMouse.containsMouse ? (Theme.isLightBar ? Qt.rgba(0, 0, 0, 0.06) : Qt.rgba(255, 255, 255, 0.06)) : "transparent") + border.width: isSelected ? 1 : 0 + border.color: Theme.isLightBar ? Theme.barFg : Theme.accent + + ThemedText { + anchors.centerIn: parent + text: "15m Long Break" + customSize: Constants.sizeXs - 2 + font.bold: parent.isSelected + color: parent.isSelected ? Theme.barFg : Theme.barMuted + } + + MouseArea { + id: longChipMouse + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: FocusTimerService.setMode("longBreak") + } + } + } + } } diff --git a/quickshell/agility/Modules/OSD/OsdPill.qml b/quickshell/agility/Modules/OSD/OsdPill.qml new file mode 100644 index 00000000..e33cd0c3 --- /dev/null +++ b/quickshell/agility/Modules/OSD/OsdPill.qml @@ -0,0 +1,127 @@ +import Qt5Compat.GraphicalEffects +import QtQuick +import QtQuick.Layouts +import Quickshell +import Quickshell.Wayland +import qs.Core +import qs.Core.Components +import qs.Core.Services + +PanelWindow { + id: root + + WlrLayershell.layer: WlrLayer.Overlay + WlrLayershell.namespace: "agility-osd" + WlrLayershell.keyboardFocus: WlrKeyboardFocus.None + + anchors { + bottom: true + } + + margins { + bottom: 84 + } + + implicitWidth: 280 + implicitHeight: 56 + width: implicitWidth + height: implicitHeight + color: "transparent" + visible: OsdService.isVisible || scaleAnimation.running + + Rectangle { + id: container + anchors.fill: parent + radius: height / 2 + color: Theme.bg + border.color: Theme.border + border.width: 1 + + opacity: OsdService.isVisible ? 1.0 : 0.0 + scale: OsdService.isVisible ? 1.0 : 0.88 + + Behavior on opacity { + NumberAnimation { duration: Constants.animFast; easing.type: Easing.OutQuad } + } + + Behavior on scale { + id: scaleAnimation + NumberAnimation { duration: Constants.animNormal; easing.type: Easing.OutBack } + } + + layer.enabled: true + layer.effect: DropShadow { + transparentBorder: true + color: Theme.shadow + radius: Constants.sizeMd + samples: 12 + verticalOffset: 4 + horizontalOffset: 0 + } + + RowLayout { + anchors.fill: parent + anchors.leftMargin: Constants.sizeMd + anchors.rightMargin: Constants.sizeMd + spacing: Constants.sizeSm + + SvgIcon { + icon: OsdService.displayIcon + iconSize: 22 + iconColor: Theme.accent + flat: true + Layout.alignment: Qt.AlignVCenter + } + + ColumnLayout { + Layout.fillWidth: true + spacing: Constants.size3Xs + Layout.alignment: Qt.AlignVCenter + + RowLayout { + Layout.fillWidth: true + + ThemedText { + text: OsdService.activeType === "volume" ? (OsdService.isMuted ? "Muted" : "Volume") : "Brightness" + font.family: Constants.fontFamily + font.pixelSize: Math.round(Constants.sizeSm * SettingsService.fontScale) + font.bold: true + color: Theme.fg + } + + Item { Layout.fillWidth: true } + + ThemedText { + text: OsdService.isMuted ? "0%" : (OsdService.displayValue + "%") + font.family: Constants.fontFamily + font.pixelSize: Math.round(Constants.sizeSm * SettingsService.fontScale) + font.bold: true + color: Theme.accent + } + } + + // Progress Bar + Rectangle { + id: track + Layout.fillWidth: true + implicitHeight: 5 + radius: 3 + color: Theme.bgSecondary + + Rectangle { + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + width: Math.round(track.width * (Math.min(100, Math.max(0, OsdService.displayValue)) / 100)) + radius: 3 + color: Theme.accent + + Behavior on width { + NumberAnimation { duration: Constants.animFast; easing.type: Easing.OutQuad } + } + } + } + } + } + } +} diff --git a/quickshell/agility/shell.qml b/quickshell/agility/shell.qml index fc0bd5db..05f7c232 100644 --- a/quickshell/agility/shell.qml +++ b/quickshell/agility/shell.qml @@ -1,3 +1,5 @@ +//@ pragma ShellId agility-shell +//@ pragma AppId agility-shell import QtQuick import Quickshell import Quickshell.Io @@ -135,6 +137,36 @@ ShellRoot { notificationService: globalNotificationService } + Variants { + model: Quickshell.screens + + PanelWindow { + required property var modelData + screen: modelData + + WlrLayershell.layer: WlrLayer.Background + WlrLayershell.keyboardFocus: WlrKeyboardFocus.None + color: "transparent" + focusable: false + visible: SettingsService.settingsLoaded && HyprlandService.wpClicksEnabled + + anchors { + top: true + bottom: true + left: true + right: true + } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton + onDoubleClicked: (mouse) => { + WallpaperManager.cycleNextWallpaper(mouse.x, mouse.y, parent.width, parent.height); + } + } + } + } + Timer { id: startupSoundTimer interval: 300 From e23c2ac13c94d02ecf9441993f8fda33c8600e25 Mon Sep 17 00:00:00 2001 From: Chintan Patel <216989679+Chintanpatel24@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:27:20 +0530 Subject: [PATCH 3/3] fix(osd): set ExclusionMode.Ignore on OsdPill and wire IPC in shell.qml --- quickshell/agility/Modules/OSD/OsdPill.qml | 10 ++++++++++ quickshell/agility/shell.qml | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/quickshell/agility/Modules/OSD/OsdPill.qml b/quickshell/agility/Modules/OSD/OsdPill.qml index e33cd0c3..b07f08ee 100644 --- a/quickshell/agility/Modules/OSD/OsdPill.qml +++ b/quickshell/agility/Modules/OSD/OsdPill.qml @@ -12,6 +12,7 @@ PanelWindow { WlrLayershell.layer: WlrLayer.Overlay WlrLayershell.namespace: "agility-osd" + WlrLayershell.exclusionMode: ExclusionMode.Ignore WlrLayershell.keyboardFocus: WlrKeyboardFocus.None anchors { @@ -29,6 +30,15 @@ PanelWindow { color: "transparent" visible: OsdService.isVisible || scaleAnimation.running + mask: Region { + Region { + x: 0 + y: 0 + width: (OsdService.isVisible || scaleAnimation.running) ? root.width : 0 + height: (OsdService.isVisible || scaleAnimation.running) ? root.height : 0 + } + } + Rectangle { id: container anchors.fill: parent diff --git a/quickshell/agility/shell.qml b/quickshell/agility/shell.qml index 05f7c232..6cf851c6 100644 --- a/quickshell/agility/shell.qml +++ b/quickshell/agility/shell.qml @@ -10,6 +10,7 @@ import qs.Core.Windows import qs.Modules.Bar import qs.Modules.Bar.Styles.Convex import qs.Modules.Bar.Styles.Gaming +import qs.Modules.OSD ShellRoot { id: root @@ -17,6 +18,18 @@ ShellRoot { readonly property bool isGaming: DisplayProfileService.gameModeActive readonly property bool isConvex: SettingsService.barStyle === "convex" + IpcHandler { + target: "osd" + + function volume(val: string) { + OsdService.showVolume(val); + } + + function brightness(val: string) { + OsdService.showBrightness(val); + } + } + IpcHandler { function toggle(widgetId: string) { if (widgetId === "edgelight" || widgetId === "edgelighting") { @@ -167,6 +180,10 @@ ShellRoot { } } + OsdPill { + id: osdPillWindow + } + Timer { id: startupSoundTimer interval: 300