Qt 6.12 shadows the bare Color singleton, so the bar and every Color role read undefined on fresh installs. Keep our I18n text in the four conflicting files, qualify #14433's notification button color, give the new dictation menu rows and notifications Chinese, and drop table entries for the removed Voxtype and FIDO2 texts.
74 lines
1.9 KiB
QML
74 lines
1.9 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import qs.Commons
|
|
import qs.Commons as Commons
|
|
import qs.Ui
|
|
|
|
BarIndicator {
|
|
id: root
|
|
|
|
property bool granted: false
|
|
property bool refreshPending: false
|
|
|
|
active: granted
|
|
activeText: ""
|
|
inactiveText: ""
|
|
activeTooltipText: I18n.tr("Disable Passwordless Sudo")
|
|
inactiveTooltipText: I18n.tr("Passwordless Sudo")
|
|
useActiveColor: true
|
|
activeColor: Commons.Color.urgent
|
|
|
|
function refresh() {
|
|
if (!root.bar) return
|
|
if (statusProc.running) {
|
|
root.refreshPending = true
|
|
return
|
|
}
|
|
root.refreshPending = false
|
|
statusProc.running = true
|
|
}
|
|
|
|
onBarChanged: refresh()
|
|
Component.onCompleted: refresh()
|
|
|
|
Connections {
|
|
target: root.indicatorHost
|
|
ignoreUnknownSignals: true
|
|
function onRefreshRequested() { root.refresh() }
|
|
}
|
|
|
|
Timer {
|
|
interval: 5000
|
|
repeat: true
|
|
running: !!root.bar
|
|
onTriggered: root.refresh()
|
|
}
|
|
|
|
Process {
|
|
id: statusProc
|
|
command: ["omarchy-sudo-passwordless", "--active"]
|
|
onExited: function(exitCode, exitStatus) {
|
|
root.granted = exitCode === 0 && exitStatus === 0
|
|
if (root.refreshPending) Qt.callLater(root.refresh)
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: disableProc
|
|
command: ["omarchy-sudo-passwordless", "--disable"]
|
|
onExited: function(exitCode, exitStatus) {
|
|
if ((exitCode !== 0 || exitStatus !== 0) && root.bar)
|
|
Quickshell.execDetached([Quickshell.env("OMARCHY_PATH") + "/bin/omarchy-notification-send", I18n.tr("Could not disable passwordless sudo"), I18n.tr("Check the sudo configuration and try again.")])
|
|
if (root.indicatorHost) root.indicatorHost.refresh()
|
|
else root.refresh()
|
|
}
|
|
}
|
|
|
|
onPressed: function() {
|
|
if (!root.bar || disableProc.running) return
|
|
if (root.granted) disableProc.running = true
|
|
else root.bar.run("omarchy-launch-floating-terminal-with-presentation omarchy-sudo-passwordless")
|
|
}
|
|
}
|