Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions install/omarchy-base.packages
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fontconfig
foot
fzf
git
gliff
gnome-keyring
gnome-themes-extra
grim
Expand Down
2 changes: 1 addition & 1 deletion manual/05-the-top-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Removing either service takes its widget back off the bar.

## Indicators

The little cluster in the center is the indicators widget. These are status glyphs for modes you've turned on: do not disturb, night light, a queued [reminder](09-reminders.md), an active screen recording, stay awake, and [dictation](11-text-extraction-dictation.md). They light up when the mode is active and otherwise stay out of the way — hover to the left of the clock (above it on a vertical bar) to peek at the inactive ones. Clicking an indicator toggles that mode.
The little cluster in the center is the indicators widget. These are status glyphs for modes you've turned on: do not disturb, night light, a queued [reminder](09-reminders.md), an active screen recording, stay awake, and [dictation](11-text-extraction-dictation.md). They light up when the mode is active and otherwise stay out of the way — hover to the left of the clock (above it on a vertical bar) to peek at the inactive ones. Clicking an indicator toggles that mode. One more is status only: a remote session lights up red while someone is connected to this machine through gliff, and a notification announces when the session starts and ends.

If you'd rather they were always visible, set `alwaysShow` to `true` on the widget. And if you only care about some of them, list the ones you want in `items`: `["Dnd", "Reminder", "NightLight"]`. You can have more than one indicators widget, so different sections can show different subsets.

Expand Down
3 changes: 3 additions & 0 deletions migrations/1791542175.sh
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
1 change: 1 addition & 0 deletions shell/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ User-installed plugins live alongside these conceptually but on disk under
| Battery | `omarchy.battery` | `service` | `services/battery/Service.qml` |
| Idle | `omarchy.idle` | `service` | `services/idle/Service.qml` |
| Night light | `omarchy.nightlight` | `service` | `services/nightlight/Service.qml` |
| Remote session | `omarchy.remote-session` | `service` | `services/remote-session/Service.qml` |
| Lock screen | `omarchy.lock` | `service` | `lock/Service.qml` |
| OSD | `omarchy.osd` | `panel` | `osd/Osd.qml` |
| Polkit agent | `omarchy.polkit` | `service` | `polkit/PolkitAgent.qml` |
Expand Down
26 changes: 26 additions & 0 deletions shell/plugins/bar/indicators/RemoteSession.qml
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()
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
}
}
}
5 changes: 5 additions & 0 deletions shell/plugins/bar/widgets/Indicators.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
"label": "Screen recording",
"description": "GPU screen recorder status"
},
{
"value": "RemoteSession",
"label": "Remote session",
"description": "Warning while someone is connected through gliff"
},
{
"value": "Reminder",
"label": "Reminder",
Expand Down
2 changes: 1 addition & 1 deletion shell/plugins/bar/widgets/Indicators.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ BarWidget {
id: root
moduleName: "omarchy.indicators"

readonly property var defaultIndicatorEntries: [ "PasswordlessSudo", "ScreenRecording", "Reminder", "NightLight", "Dnd", "StayAwake" ]
readonly property var defaultIndicatorEntries: [ "PasswordlessSudo", "ScreenRecording", "RemoteSession", "Reminder", "NightLight", "Dnd", "StayAwake" ]
readonly property var indicatorEntries: indicatorEntriesFromSettings(settings)
property var activeIndicatorIds: []
property var indicatorActiveStates: ({})
Expand Down
46 changes: 46 additions & 0 deletions shell/plugins/services/remote-session/RemoteSessionModel.js
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
}
}
92 changes: 92 additions & 0 deletions shell/plugins/services/remote-session/Service.qml
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)
}
}
}
14 changes: 14 additions & 0 deletions shell/plugins/services/remote-session/manifest.json
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"
}
}
7 changes: 7 additions & 0 deletions shell/services/PluginFirstPartyServiceApi.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ QtObject {
property bool doNotDisturb: false
property var activePlayer: null
property var sourcePlayers: []
property bool active: false
property var peers: []

property var _setIdleEnabled: null
property var _setNightlight: null
property var _setDoNotDisturb: null
property var _runAction: null
property var _playerKey: null
property var _selectPlayer: null
property var _refresh: null

function setIdleEnabled(value) {
if (serviceId === "omarchy.idle" && _setIdleEnabled) _setIdleEnabled(!!value)
Expand All @@ -43,4 +46,8 @@ QtObject {
function selectPlayer(playerId) {
if (serviceId === "omarchy.media" && _selectPlayer) _selectPlayer(String(playerId || ""))
}

function refresh() {
if (serviceId === "omarchy.remote-session" && _refresh) _refresh()
}
}
16 changes: 14 additions & 2 deletions shell/shell.qml
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ ShellRoot {

function pluginFirstPartyServiceFor(cacheKey, pluginId, requestedId) {
var id = String(requestedId || "")
var allowed = ["omarchy.idle", "omarchy.media", "omarchy.nightlight", "omarchy.notifications"]
var allowed = ["omarchy.idle", "omarchy.media", "omarchy.nightlight", "omarchy.notifications", "omarchy.remote-session"]
if (allowed.indexOf(id) === -1) return null
var proxyKey = cacheKey + "::" + id
if (_pluginFirstPartyServiceApis[proxyKey]) return _pluginFirstPartyServiceApis[proxyKey]
Expand Down Expand Up @@ -490,6 +490,10 @@ ShellRoot {
_selectPlayer: function(playerKey) {
var target = service()
if (target && typeof target.selectPlayer === "function") target.selectPlayer(playerKey)
},
_refresh: function() {
var target = service()
if (target && typeof target.refresh === "function") target.refresh()
}
})
if (!api) return null
Expand All @@ -513,6 +517,14 @@ ShellRoot {
var target = service()
return target && Array.isArray(target.sourcePlayers) ? target.sourcePlayers : []
})
api.active = Qt.binding(function() {
var target = service()
return target ? target.active === true : false
})
api.peers = Qt.binding(function() {
var target = service()
return target && Array.isArray(target.peers) ? target.peers : []
})
var next = ({})
for (var existing in _pluginFirstPartyServiceApis) next[existing] = _pluginFirstPartyServiceApis[existing]
next[proxyKey] = api
Expand Down Expand Up @@ -588,7 +600,7 @@ ShellRoot {
// property, even though the resulting proxy is otherwise acyclic.
var firstPartyServices = ({})
if (barCapabilities) {
var serviceIds = ["omarchy.idle", "omarchy.media", "omarchy.nightlight", "omarchy.notifications"]
var serviceIds = ["omarchy.idle", "omarchy.media", "omarchy.nightlight", "omarchy.notifications", "omarchy.remote-session"]
for (var i = 0; i < serviceIds.length; i++) {
var serviceId = serviceIds[i]
firstPartyServices[serviceId] = shell.pluginFirstPartyServiceFor(cacheKey, key, serviceId)
Expand Down
25 changes: 25 additions & 0 deletions test/shell.d/fixtures/indicator-contract/shell.qml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,23 @@ ShellRoot {
}
}

QtObject {
id: remoteSessionService
property bool active: false
property var peers: []
property int refreshes: 0
function refresh() {
refreshes++
}
}

QtObject {
id: mockShell
function firstPartyServiceFor(id) {
if (id === "omarchy.notifications") return notificationService
if (id === "omarchy.idle") return idleService
if (id === "omarchy.nightlight") return nightlightService
if (id === "omarchy.remote-session") return remoteSessionService
return null
}
}
Expand Down Expand Up @@ -74,6 +85,7 @@ ShellRoot {
QtObject {
id: indicatorHost
property bool revealInactiveIndicators: true
signal refreshRequested()
}

function createIndicator(name) {
Expand Down Expand Up @@ -198,6 +210,19 @@ ShellRoot {
root.assertTrue(root.commandCount("omarchy-capture-screenrecording --stop-recording") === 1, "Screen Recording left click stops active recording")
}

var remoteSession = root.createIndicator("RemoteSession")
if (remoteSession) {
remoteSession.moduleName = "RemoteSession"
root.injectBar(remoteSession)
root.assertTrue(remoteSession.active === false, "Remote Session starts inactive without a gliff server")
remoteSessionService.active = true
remoteSessionService.peers = ["10.0.0.5"]
root.assertTrue(remoteSession.active === true, "Remote Session follows the service state")
root.assertTrue(remoteSession.tooltipText === "Remote session from 10.0.0.5", "Remote Session tooltip names the connected peer")
indicatorHost.refreshRequested()
root.assertTrue(remoteSessionService.refreshes === 1, "Remote Session refresh re-probes the service")
}

var stayAwake = root.createIndicator("StayAwake")
if (stayAwake) {
stayAwake.moduleName = "StayAwake"
Expand Down
Loading