Repository navigation
Install gliff by default and show when a remote session is active #14712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+483
−4
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b567a93
Install gliff by default
dhh f01ba14
Show a bar indicator while a gliff remote session is active
dhh 6b5efac
Address review of the remote session indicator
dhh 5df3b8a
Drop the remote session notifications
dhh 42cda51
Tighten remote session detection after review
dhh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ fontconfig | |
| foot | ||
| fzf | ||
| git | ||
| gliff | ||
| gnome-keyring | ||
| gnome-themes-extra | ||
| grim | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| echo "Install Gliff, the Hyprland remote desktop over SSH" | ||
|
|
||
| omarchy-pkg-add gliff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import QtQuick | ||
| import qs.Commons as Commons | ||
| import qs.Ui | ||
|
|
||
| BarIndicator { | ||
| id: root | ||
|
|
||
| readonly property var remoteSessionService: bar?.shell?.firstPartyServiceFor("omarchy.remote-session") | ||
| readonly property var peers: remoteSessionService && Array.isArray(remoteSessionService.peers) ? remoteSessionService.peers : [] | ||
|
|
||
| active: remoteSessionService ? remoteSessionService.active : false | ||
| activeText: "" | ||
| inactiveText: "" | ||
| activeTooltipText: peers.length > 0 ? "Remote session from " + peers.join(", ") : "Remote session" | ||
| inactiveTooltipText: "Remote Session" | ||
| useActiveColor: true | ||
| activeColor: Commons.Color.urgent | ||
|
|
||
| Connections { | ||
| target: root.indicatorHost | ||
| ignoreUnknownSignals: true | ||
| function onRefreshRequested() { | ||
| if (root.remoteSessionService) root.remoteSessionService.refresh() | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
shell/plugins/services/remote-session/RemoteSessionModel.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // Hyprland emits these whenever a screencopy session starts or stops, which | ||
| // covers gliff-server (ext-image-copy-capture) as well as screen recorders | ||
| // and browser screen shares, so the event is only a cue to re-probe. | ||
| function isCaptureEvent(name) { | ||
| var event = String(name || "") | ||
| return event === "screencast" || event === "screencastv2" | ||
| } | ||
|
|
||
| // Parses the probe output: one "<pid> [peer]" line per running gliff-server, | ||
| // where peer is the ssh client address when the server was spawned over ssh. | ||
| function stateFromOutput(text) { | ||
| var lines = String(text || "").split("\n") | ||
| var sessions = 0 | ||
| var peers = [] | ||
| for (var i = 0; i < lines.length; i++) { | ||
| var parts = lines[i].trim().split(/\s+/) | ||
| if (parts[0] === "") continue | ||
| sessions++ | ||
| var peer = parts[1] || "" | ||
| if (peer !== "" && peers.indexOf(peer) === -1) peers.push(peer) | ||
| } | ||
| return { active: sessions > 0, sessions: sessions, peers: peers } | ||
| } | ||
|
|
||
| function peerSummary(peers) { | ||
| var list = Array.isArray(peers) ? peers : [] | ||
| return list.length > 0 ? " from " + list.join(", ") : "" | ||
| } | ||
|
|
||
| function activeTooltip(peers) { | ||
| return "Remote session" + peerSummary(peers) | ||
| } | ||
|
|
||
| function startedBody(peers) { | ||
| return "Someone is viewing and controlling this screen" + peerSummary(peers) + " through gliff." | ||
| } | ||
|
|
||
| if (typeof module !== "undefined") { | ||
| module.exports = { | ||
| isCaptureEvent: isCaptureEvent, | ||
| stateFromOutput: stateFromOutput, | ||
| peerSummary: peerSummary, | ||
| activeTooltip: activeTooltip, | ||
| startedBody: startedBody | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import QtQuick | ||
| import Quickshell | ||
| import Quickshell.Hyprland | ||
| import Quickshell.Io | ||
| import "RemoteSessionModel.js" as RemoteSessionModel | ||
|
|
||
| // Watches for gliff-server, the Hyprland remote desktop, so the machine being | ||
| // controlled can see that someone is on it: the RemoteSession bar indicator | ||
| // reads `active`, and a notification announces each session start and end. | ||
| Item { | ||
| id: root | ||
|
|
||
| // Injected by omarchy-shell (the first-party service loader). | ||
| property var shell: null | ||
|
|
||
| property bool stateLoaded: false | ||
| property bool active: false | ||
| property int sessions: 0 | ||
| property var peers: [] | ||
|
|
||
| property bool refreshPending: false | ||
|
|
||
| function refresh() { | ||
| if (statusProbe.running) { | ||
| root.refreshPending = true | ||
| return | ||
| } | ||
| root.refreshPending = false | ||
| statusProbe.running = true | ||
| } | ||
|
|
||
| function applyProbe(text) { | ||
| var state = RemoteSessionModel.stateFromOutput(text) | ||
| var wasActive = root.active | ||
| var announce = root.stateLoaded && state.active !== wasActive | ||
|
|
||
| root.sessions = state.sessions | ||
| root.peers = state.peers | ||
| root.active = state.active | ||
| root.stateLoaded = true | ||
|
|
||
| if (announce) root.announce(state) | ||
| } | ||
|
|
||
| function announce(state) { | ||
| var args = ["omarchy-notification-send", "-g", ""] | ||
| if (state.active) { | ||
| args.push("Remote session started", RemoteSessionModel.startedBody(state.peers)) | ||
| } else { | ||
| args.push("Remote session ended", "The gliff connection to this screen closed.") | ||
| } | ||
| Quickshell.execDetached(args) | ||
| } | ||
|
|
||
| Component.onCompleted: refresh() | ||
|
|
||
| // gliff-server captures the screen through ext-image-copy-capture, so every | ||
| // session start and stop surfaces as a screencast event; the probe decides | ||
| // whether it was gliff or another screencopy client. | ||
| Connections { | ||
| target: Hyprland | ||
| function onRawEvent(event) { | ||
| if (RemoteSessionModel.isCaptureEvent(event ? event.name : "")) root.refresh() | ||
| } | ||
| } | ||
|
|
||
| // Safety net while a session is active, in case a stop event is missed. | ||
| Timer { | ||
| interval: 15000 | ||
| repeat: true | ||
| running: root.active | ||
| onTriggered: root.refresh() | ||
| } | ||
|
|
||
| // Only this user's servers count: another account's session on the same | ||
| // machine captures its own desktop, not this one. | ||
| Process { | ||
| id: statusProbe | ||
| command: ["bash", "-c", | ||
| 'for pid in $(pgrep -x -u "$(id -u)" gliff-server); do ' + | ||
| 'peer=$(tr "\\0" "\\n" < "/proc/$pid/environ" 2>/dev/null | sed -n "s/^SSH_CONNECTION=\\([^ ]*\\).*/\\1/p"); ' + | ||
| 'printf "%s %s\\n" "$pid" "$peer"; ' + | ||
| 'done'] | ||
| stdout: StdioCollector { | ||
| waitForEnd: true | ||
| onStreamFinished: root.applyProbe(text) | ||
| } | ||
| onExited: function() { | ||
| if (root.refreshPending) Qt.callLater(root.refresh) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "schemaVersion": 1, | ||
| "id": "omarchy.remote-session", | ||
| "name": "Remote Session", | ||
| "version": "1.0.0", | ||
| "author": "Omarchy", | ||
| "description": "Detects a gliff remote-desktop session on this machine for the bar indicator, and announces it with a notification.", | ||
| "kinds": [ | ||
| "service" | ||
| ], | ||
| "entryPoints": { | ||
| "service": "Service.qml" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.