forked from Shinonome/dots-hyprland
easyeffects toggle: move logic to a service
This commit is contained in:
@@ -1,23 +1,23 @@
|
|||||||
import qs.modules.common.widgets
|
import qs.modules.common.widgets
|
||||||
import qs
|
import qs
|
||||||
|
import qs.services
|
||||||
|
import QtQuick
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
|
|
||||||
QuickToggleButton {
|
QuickToggleButton {
|
||||||
id: root
|
id: root
|
||||||
toggled: false
|
toggled: EasyEffects.active
|
||||||
visible: false
|
visible: EasyEffects.available
|
||||||
buttonIcon: "instant_mix"
|
buttonIcon: "instant_mix"
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
EasyEffects.fetchActiveState()
|
||||||
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (toggled) {
|
EasyEffects.toggle()
|
||||||
root.toggled = false
|
|
||||||
Quickshell.execDetached(["pkill", "easyeffects"])
|
|
||||||
} else {
|
|
||||||
root.toggled = true
|
|
||||||
Quickshell.execDetached(["easyeffects", "--gapplication-service"])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
altAction: () => {
|
altAction: () => {
|
||||||
@@ -25,24 +25,6 @@ QuickToggleButton {
|
|||||||
GlobalStates.sidebarRightOpen = false
|
GlobalStates.sidebarRightOpen = false
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
|
||||||
id: fetchAvailability
|
|
||||||
running: true
|
|
||||||
command: ["bash", "-c", "command -v easyeffects"]
|
|
||||||
onExited: (exitCode, exitStatus) => {
|
|
||||||
root.visible = exitCode === 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Process {
|
|
||||||
id: fetchActiveState
|
|
||||||
running: true
|
|
||||||
command: ["pidof", "easyeffects"]
|
|
||||||
onExited: (exitCode, exitStatus) => {
|
|
||||||
root.toggled = exitCode === 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledToolTip {
|
StyledToolTip {
|
||||||
content: Translation.tr("EasyEffects | Right-click to configure")
|
content: Translation.tr("EasyEffects | Right-click to configure")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import qs.modules.common
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
|
import Quickshell.Services.Pipewire
|
||||||
|
pragma Singleton
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles EasyEffects active state and presets.
|
||||||
|
*/
|
||||||
|
Singleton {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property bool available: false
|
||||||
|
property bool active: false
|
||||||
|
|
||||||
|
function fetchAvailability() {
|
||||||
|
fetchAvailabilityProc.running = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchActiveState() {
|
||||||
|
fetchActiveStateProc.running = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function disable() {
|
||||||
|
root.active = false
|
||||||
|
Quickshell.execDetached(["pkill", "easyeffects"])
|
||||||
|
}
|
||||||
|
|
||||||
|
function enable() {
|
||||||
|
root.active = true
|
||||||
|
Quickshell.execDetached(["easyeffects", "--gapplication-service"])
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggle() {
|
||||||
|
if (root.active) {
|
||||||
|
root.disable()
|
||||||
|
} else {
|
||||||
|
root.enable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: fetchAvailabilityProc
|
||||||
|
running: true
|
||||||
|
command: ["bash", "-c", "command -v easyeffects"]
|
||||||
|
onExited: (exitCode, exitStatus) => {
|
||||||
|
root.available = exitCode === 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: fetchActiveStateProc
|
||||||
|
running: true
|
||||||
|
command: ["pidof", "easyeffects"]
|
||||||
|
onExited: (exitCode, exitStatus) => {
|
||||||
|
root.active = exitCode === 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user