diff options
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/Services')
4 files changed, 178 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/Services/Brightness.qml b/accounts/gkleen@sif/shell/quickshell/Services/Brightness.qml new file mode 100644 index 00000000..8318df50 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Services/Brightness.qml | |||
@@ -0,0 +1,75 @@ | |||
1 | pragma Singleton | ||
2 | |||
3 | import QtQml | ||
4 | import Quickshell | ||
5 | import Quickshell.Io | ||
6 | import Custom as Custom | ||
7 | |||
8 | Singleton { | ||
9 | id: root | ||
10 | |||
11 | property string subsystem: "backlight" | ||
12 | property string device: "intel_backlight" | ||
13 | |||
14 | property real currBrightness | ||
15 | property real exponent: 4 | ||
16 | |||
17 | function calcCurrBrightness() { | ||
18 | if (!currFile.loaded || !maxFile.loaded) | ||
19 | return undefined; | ||
20 | const curr = Number(currFile.text()); | ||
21 | const max = Number(maxFile.text()); | ||
22 | const val = Math.pow(curr / max, 1 / root.exponent); | ||
23 | return val; | ||
24 | } | ||
25 | |||
26 | Connections { | ||
27 | target: currFile | ||
28 | function onLoaded() { | ||
29 | const b = root.calcCurrBrightness(); | ||
30 | if (typeof b !== 'undefined') | ||
31 | root.currBrightness = b; | ||
32 | } | ||
33 | } | ||
34 | Connections { | ||
35 | target: maxFile | ||
36 | function onLoaded() { | ||
37 | const b = root.calcCurrBrightness(); | ||
38 | if (typeof b !== 'undefined') | ||
39 | root.currBrightness = b; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | onCurrBrightnessChanged: { | ||
44 | root.currBrightness = Math.max(0, Math.min(1, root.currBrightness)); | ||
45 | |||
46 | const prev = root.calcCurrBrightness(); | ||
47 | if (typeof prev === 'undefined' || Math.abs(root.currBrightness - prev) < 0.01) | ||
48 | return; | ||
49 | |||
50 | const max = Number(maxFile.text()); | ||
51 | const actual = Number(currFile.text()); | ||
52 | let curr = Math.max(0, Math.min(max, Math.pow(root.currBrightness, root.exponent) * max)); | ||
53 | if (Math.round(curr) == actual && curr < actual) | ||
54 | curr = Math.max(0, actual - 1); | ||
55 | else if (Math.round(curr) == actual && curr > actual) | ||
56 | curr = Math.min(max, actual + 1); | ||
57 | // root.currBrightness = Math.pow(curr / max, 1 / root.exponent); | ||
58 | Custom.Systemd.setBrightness(root.subsystem, root.device, Math.round(curr)); | ||
59 | } | ||
60 | |||
61 | FileView { | ||
62 | id: currFile | ||
63 | path: `/sys/class/${root.subsystem}/${root.device}/brightness` | ||
64 | blockAllReads: true | ||
65 | watchChanges: true | ||
66 | onFileChanged: reload() | ||
67 | } | ||
68 | FileView { | ||
69 | id: maxFile | ||
70 | path: `/sys/class/${root.subsystem}/${root.device}/max_brightness` | ||
71 | blockAllReads: true | ||
72 | watchChanges: true | ||
73 | onFileChanged: reload() | ||
74 | } | ||
75 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/Services/GpgAgent.qml b/accounts/gkleen@sif/shell/quickshell/Services/GpgAgent.qml new file mode 100644 index 00000000..3de69535 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Services/GpgAgent.qml | |||
@@ -0,0 +1,18 @@ | |||
1 | pragma Singleton | ||
2 | |||
3 | import Quickshell | ||
4 | import Quickshell.Io | ||
5 | |||
6 | Singleton { | ||
7 | id: root | ||
8 | |||
9 | Socket { | ||
10 | id: agentSocket | ||
11 | connected: true | ||
12 | path: `${Quickshell.env("XDG_RUNTIME_DIR")}/gnupg/S.gpg-agent` | ||
13 | } | ||
14 | |||
15 | function reloadAgent() { | ||
16 | agentSocket.write("RELOADAGENT\n") | ||
17 | } | ||
18 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/Services/InhibitorState.qml b/accounts/gkleen@sif/shell/quickshell/Services/InhibitorState.qml new file mode 100644 index 00000000..fe48fd7f --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Services/InhibitorState.qml | |||
@@ -0,0 +1,22 @@ | |||
1 | pragma Singleton | ||
2 | |||
3 | import Quickshell | ||
4 | import Custom as Custom | ||
5 | |||
6 | Singleton { | ||
7 | id: inhibitorState | ||
8 | |||
9 | property bool waylandIdleInhibited: false | ||
10 | property alias lidSwitchInhibited: lidSwitchInhibitor.enabled | ||
11 | |||
12 | Custom.SystemdInhibitor { | ||
13 | id: lidSwitchInhibitor | ||
14 | |||
15 | enabled: false | ||
16 | |||
17 | what: Custom.SystemdInhibitorParams.HandleLidSwitch | ||
18 | who: "quickshell" | ||
19 | why: "User request" | ||
20 | mode: Custom.SystemdInhibitorParams.BlockWeak | ||
21 | } | ||
22 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/Services/Privacy.qml b/accounts/gkleen@sif/shell/quickshell/Services/Privacy.qml new file mode 100644 index 00000000..9c813e49 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Services/Privacy.qml | |||
@@ -0,0 +1,63 @@ | |||
1 | pragma Singleton | ||
2 | |||
3 | import QtQml | ||
4 | import Quickshell | ||
5 | import Quickshell.Services.Pipewire | ||
6 | |||
7 | Singleton { | ||
8 | id: root | ||
9 | |||
10 | PwObjectTracker { | ||
11 | objects: Pipewire.nodes.values | ||
12 | } | ||
13 | |||
14 | enum Item { | ||
15 | Microphone, | ||
16 | Screensharing | ||
17 | } | ||
18 | |||
19 | readonly property list<var> activeItems: { | ||
20 | var items = []; | ||
21 | if (microphoneActive) | ||
22 | items.push(Privacy.Item.Microphone); | ||
23 | if (screensharingActive) | ||
24 | items.push(Privacy.Item.Screensharing); | ||
25 | return items; | ||
26 | } | ||
27 | |||
28 | readonly property bool microphoneActive: { | ||
29 | if (!Pipewire.ready || !Pipewire.nodes?.values) { | ||
30 | return false | ||
31 | } | ||
32 | |||
33 | for (const node of Pipewire.nodes.values) { | ||
34 | if (!node || (node.type & PwNodeType.AudioInStream) != PwNodeType.AudioInStream) | ||
35 | continue; | ||
36 | |||
37 | if (node.properties?.["stream.monitor"] === "true") | ||
38 | continue; | ||
39 | |||
40 | if (node.audio?.muted) | ||
41 | continue; | ||
42 | |||
43 | return true; | ||
44 | } | ||
45 | |||
46 | return false; | ||
47 | } | ||
48 | |||
49 | readonly property bool screensharingActive: { | ||
50 | if (!Pipewire.ready || !Pipewire.nodes?.values) { | ||
51 | return false | ||
52 | } | ||
53 | |||
54 | for (const node of Pipewire.nodes.values) { | ||
55 | if (!node || (node.type & PwNodeType.VideoInStream) != PwNodeType.VideoInStream) | ||
56 | continue; | ||
57 | |||
58 | return true; | ||
59 | } | ||
60 | |||
61 | return false; | ||
62 | } | ||
63 | } | ||