repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
quickshell/nuguland/shell.qml
Rawimport QtQuick
import Quickshell
import Quickshell.Io
ShellRoot {
id: shell
Theme {
id: nuguTheme
}
Time {
id: time
}
Niri {
id: niri
}
Resources {
id: resources
}
Notifications {
id: notifications
}
Tray {
id: tray
}
Clipboard {
id: clipboard
}
Launcher {
id: launcher
niriService: niri
clipboardService: clipboard
}
Osd {
id: osd
}
Media {
id: media
osdService: osd
}
Audio {
id: audio
osdService: osd
}
Idle {
id: idle
}
Privilege {
id: privilege
}
Lock {
id: lock
theme: nuguTheme
timeService: time
mediaService: media
notificationService: notifications
powerService: power
}
Network {
id: network
}
Bluetooth {
id: bluetooth
}
Power {
id: power
lockService: lock
niriService: niri
}
Screenshots {
id: screenshots
niriService: niri
osdService: osd
}
SurfaceManager {
id: surfaceManager
}
Diagnostics {
id: diagnostics
niriService: niri
timeService: time
resourceService: resources
notificationService: notifications
trayService: tray
launcherService: launcher
clipboardService: clipboard
mediaService: media
audioService: audio
idleService: idle
privilegeService: privilege
lockService: lock
networkService: network
bluetoothService: bluetooth
powerService: power
screenshotsService: screenshots
osdService: osd
surfaces: surfaceManager
}
FloatingWindow {
title: "Nuguland privilege"
visible: privilege.active || privilege.error.length > 0
width: 720
height: 420
color: "transparent"
PrivilegeSurface {
anchors.fill: parent
theme: nuguTheme
privilegeService: privilege
}
}
Variants {
model: Quickshell.screens
delegate: Component {
AuroraBackdrop {
required property var modelData
screen: modelData
}
}
}
Variants {
model: Quickshell.screens
delegate: Component {
Bar {
required property var modelData
screen: modelData
theme: nuguTheme
niriService: niri
timeService: time
resourceService: resources
notificationService: notifications
trayService: tray
mediaService: media
clipboardService: clipboard
launcherService: launcher
audioService: audio
networkService: network
bluetoothService: bluetooth
powerService: power
screenshotsService: screenshots
idleService: idle
lockService: lock
diagnosticsService: diagnostics
surfaces: surfaceManager
}
}
}
IpcHandler {
function increase() {
return audio.increase();
}
function decrease() {
return audio.decrease();
}
function muteOutput() {
return audio.muteOutput();
}
function muteInput() {
return audio.muteInput();
}
function route(action) {
return audio.route(action);
}
target: "volume"
}
IpcHandler {
function next() {
return media.action("next");
}
function previous() {
return media.action("previous");
}
function playPause() {
return media.action("playPause");
}
function stop() {
return media.action("stop");
}
function shuffle() {
return media.action("shuffle");
}
function repeat() {
return media.action("repeat");
}
function route(action) {
return media.action(action);
}
target: "media"
}
IpcHandler {
function adjust(sign) {
const direction = String(sign) === "-" ? "down" : "up";
const expression = String(sign) === "-" ? "b - m / 20" : "b + m / 20";
Quickshell.execDetached(["sh", "-c", `d=/sys/class/backlight/intel_backlight; b=$(cat $d/brightness); m=$(cat $d/max_brightness); n=$((${expression})); [ $n -lt 1 ] && n=1; [ $n -gt $m ] && n=$m; printf '%s\\n' $n > $d/brightness`]);
return osd.trigger("brightness", direction);
}
function increase() {
return adjust("+");
}
function decrease() {
return adjust("-");
}
target: "brightness"
}
IpcHandler {
function ping() {
return "nuguland";
}
function niriState() {
return niri.stateJson();
}
function reloadTheme() {
nuguTheme.reload();
return nuguTheme.mode;
}
function screenshotScreen(path) {
niri.screenshotScreen(path);
return path;
}
function windowRuleMetadata() {
return niri.windowRuleMetadata();
}
function windowCardAction(kind) {
return niri.windowCardAction(kind);
}
function timeState() {
return time.stateJson();
}
function timeStateAt(iso) {
return time.stateAt(iso);
}
function timeRelative(fromIso, toIso) {
return time.relative(fromIso, toIso);
}
function timeCalendar(year, month, selectedDay) {
return time.calendar(year, month, selectedDay);
}
function cpuWidgetState(value) {
return resources.cpuWidgetState(value);
}
function resourceHeroCard(kind, value, samplesCsv) {
return resources.resourceHeroCard(kind, value, String(samplesCsv).split(",").map(Number));
}
function notificationWidgetState(attention, active) {
return notifications.widgetState(attention, active);
}
function notificationsState() {
return notifications.stateJson();
}
function notificationsSeed() {
return notifications.seed();
}
function notificationsToggleDnd() {
return notifications.toggleDnd();
}
function notificationsAction(id, actionId) {
return notifications.runAction(id, actionId);
}
function notificationsToggleGroup(appName) {
return notifications.toggleGroup(appName);
}
function notificationsDrag(id, deltaX, width) {
return notifications.dragNotification(id, deltaX, width);
}
function notificationsDiscardAll() {
return notifications.discardAllNotifications();
}
function trayWidgetState(attention, active) {
return tray.widgetState(attention, active);
}
function trayState() {
return tray.stateJson();
}
function trayMenuExpand(id) {
return tray.expandSubmenu(id);
}
function trayMenuActivate(id) {
return tray.activateRow(id);
}
function trayMenuClose(reason) {
return tray.closeMenu(reason);
}
function diagnosticsState() {
return diagnostics.stateJson();
}
function launcherSearch(query) {
return launcher.search(query);
}
function launcherState() {
return launcher.stateJson();
}
function osdTrigger(event, value) {
return osd.trigger(event, value);
}
function osdState() {
return osd.stateJson();
}
function osdExpire() {
return osd.expire();
}
function clipboardState() {
return clipboard.stateJson();
}
function clipboardSearch(query) {
return clipboard.search(query);
}
function clipboardTogglePin(id) {
return clipboard.togglePin(id);
}
function clipboardCopy(id) {
return clipboard.copy(id);
}
function clipboardPaste(id) {
return clipboard.paste(id);
}
function clipboardDelete(id) {
return clipboard.deleteRow(id);
}
function clipboardPrivateMode(enabled) {
return clipboard.setPrivateMode(enabled);
}
function mediaState() {
return media.stateJson();
}
function mediaAction(kind) {
return media.action(kind);
}
function mediaSeek(position) {
return media.seek(position);
}
function mediaSelect(id) {
return media.select(id);
}
function audioState() {
return audio.stateJson();
}
function audioSetVolume(id, volume) {
return audio.setVolume(id, volume);
}
function audioToggleMute(id) {
return audio.toggleMute(id);
}
function audioSetDefaultSink(id) {
return audio.setDefaultSink(id);
}
function audioSetDefaultSource(id) {
return audio.setDefaultSource(id);
}
function audioMoveStream(id, target) {
return audio.moveStream(id, target);
}
function idleState() {
return idle.stateJson();
}
function idleEnable(minutes, reason) {
return idle.enable(minutes, reason);
}
function idleDisable() {
return idle.disable();
}
function idleToggle(minutes, reason) {
return idle.toggle(minutes, reason);
}
function idleSetActivity(name) {
return idle.setActivity(name);
}
function idleExpire() {
return idle.expire();
}
function privilegeState() {
return privilege.stateJson();
}
function privilegeBeginTestRequest(app, actionId, message) {
return privilege.beginTestRequest(app, actionId, message);
}
function privilegeSubmit(secret) {
return privilege.submit(secret);
}
function privilegeDeny() {
return privilege.deny();
}
function privilegeCancel() {
return privilege.cancel();
}
function privilegeFail(message) {
return privilege.fail(message);
}
function privilegeClear() {
return privilege.clear();
}
function lockState() {
return lock.stateJson();
}
function lockRequest() {
return lock.request();
}
function lockType(secret) {
return lock.typeSecret(secret);
}
function lockSubmit(secret) {
return lock.submit(secret);
}
function lockFail(message) {
return lock.fail(message);
}
function lockUnlock() {
return lock.unlock();
}
function lockCancel() {
return lock.cancel();
}
function networkState() {
return network.stateJson();
}
function networkScan() {
return network.scan();
}
function networkSelect(id) {
return network.select(id);
}
function networkToggleWifi(enabled) {
return network.toggleWifi(enabled);
}
function networkForget(id) {
return network.forget(id);
}
function networkCheckConnectivity() {
return network.checkConnectivity();
}
function bluetoothState() {
return bluetooth.stateJson();
}
function bluetoothScan() {
return bluetooth.scan();
}
function bluetoothToggle(enabled) {
return bluetooth.toggle(enabled);
}
function bluetoothDeviceAction(kind, id) {
return bluetooth.deviceAction(kind, id);
}
function powerState() {
return power.stateJson();
}
function powerSetProfile(name) {
return power.setProfile(name);
}
function powerSessionAction(kind) {
return power.sessionAction(kind);
}
function powerConfirmAction(kind) {
return power.confirmAction(kind);
}
function powerCancelAction() {
return power.cancelAction();
}
function screenshotsState() {
return screenshots.stateJson();
}
function screenshotsBeginSelection(x, y) {
return screenshots.beginSelection(x, y);
}
function screenshotsUpdateSelection(x, y) {
return screenshots.updateSelection(x, y);
}
function screenshotsCompleteSelection(path) {
return screenshots.completeSelection(path);
}
function screenshotsCancelSelection() {
return screenshots.cancelSelection();
}
function screenshotsCapture(kind, path) {
return screenshots.capture(kind, path);
}
function screenshotsPickColor() {
return screenshots.pickColor();
}
function screenshotsRecordAction(kind, id) {
return screenshots.recordAction(kind, id);
}
function screenshotsClear() {
return screenshots.clear();
}
function registeredAnchors() {
return surfaceManager.registeredAnchors();
}
function popoutContentCatalog() {
return surfaceManager.popoutContentCatalog();
}
function setPopoutScreen(width, height) {
return surfaceManager.setPopoutScreen(width, height);
}
function openPopout(name, anchor) {
return surfaceManager.openPopout(name, anchor);
}
function openRegisteredPopout(name) {
return surfaceManager.openRegisteredPopout(name);
}
function openNotifications() {
return surfaceManager.openRegisteredPopout("notifications");
}
function hoverRegisteredPopout(name) {
return surfaceManager.hoverRegisteredPopout(name);
}
function closePopout() {
return surfaceManager.closePopout("");
}
function popoutInteraction(kind) {
return surfaceManager.popoutInteraction(kind);
}
function gesturePress(x, y) {
return surfaceManager.gesturePress(x, y);
}
function gestureDrag(x, y) {
return surfaceManager.gestureDrag(x, y);
}
function gestureRelease(x, y) {
return surfaceManager.gestureRelease(x, y);
}
function gestureCancel(reason) {
return surfaceManager.gestureCancel(reason);
}
function popoutState() {
return surfaceManager.popoutState();
}
function hideAll() {
surfaceManager.closePopout("hideAll");
return "ok";
}
target: "nuguland"
}
component NuguText: Text {
required property QtObject theme
property string variant: "body"
property bool selected: false
color: !theme ? "transparent" : (selected ? theme.content.backdrop : (variant === "title" ? theme.ui.important_global : (variant === "meta" ? theme.ui.normal : theme.content.normal)))
font.family: variant === "mono" ? "IBM Plex Mono" : "IBM Plex Sans"
font.pixelSize: variant === "title" ? 15 : (variant === "meta" ? 13 : 14)
font.bold: variant === "title"
elide: Text.ElideRight
}
component PrivilegeFailureShake: Item {
id: shakeRoot
default property alias content: contentItem.data
property bool active: false
property real boundedDistance: 12
readonly property var shakeOffsets: [0, -boundedDistance, boundedDistance, -boundedDistance / 2, boundedDistance / 2, 0]
implicitWidth: contentItem.implicitWidth
implicitHeight: contentItem.implicitHeight
onActiveChanged: {
if (active)
shake.restart();
}
Item {
id: contentItem
anchors.fill: parent
implicitWidth: childrenRect.width
implicitHeight: childrenRect.height
}
SequentialAnimation {
id: shake
running: false
alwaysRunToEnd: true
ScriptAction {
script: translation.x = shakeRoot.shakeOffsets[0]
}
NumberAnimation {
target: translation
property: "x"
to: shakeRoot.shakeOffsets[1]
duration: 50
easing.type: Easing.OutCubic
}
NumberAnimation {
target: translation
property: "x"
to: shakeRoot.shakeOffsets[2]
duration: 50
easing.type: Easing.OutCubic
}
NumberAnimation {
target: translation
property: "x"
to: shakeRoot.shakeOffsets[3]
duration: 40
easing.type: Easing.OutCubic
}
NumberAnimation {
target: translation
property: "x"
to: shakeRoot.shakeOffsets[4]
duration: 40
easing.type: Easing.OutCubic
}
NumberAnimation {
target: translation
property: "x"
to: shakeRoot.shakeOffsets[5]
duration: 30
easing.type: Easing.OutCubic
}
}
transform: Translate {
id: translation
x: 0
}
}
component PrivilegeSurface: Rectangle {
id: root
required property QtObject theme
required property QtObject privilegeService
property var state: privilegeService ? parseJson(privilegeService.stateJson(), {
"request": {
},
"privilegeSurfacePanelContract": {
},
"buttons": []
}) : ({
"request": {
},
"privilegeSurfacePanelContract": {
},
"buttons": []
})
readonly property var request: state.request || ({
})
readonly property var panel: state.privilegeSurfacePanelContract || ({
})
readonly property string source: "Quickshell Polkit manual agent.qml plus Nuguland Polkit.qml plus Nuguland PolkitService.qml"
readonly property bool isolatedSecuritySurface: true
readonly property bool requestIdentityCard: true
readonly property bool secretPromptField: true
readonly property bool denyCancelConfirmRow: true
readonly property bool failureShakeSlot: true
readonly property bool noDecorativeDistraction: true
readonly property bool serviceFedOnly: true
function parseJson(text, valueWhenInvalid) {
try {
return JSON.parse(String(text));
} catch (error) {
return valueWhenInvalid;
}
}
function refreshFrom(text) {
state = parseJson(text, state);
}
function submitSecret(secret) {
if (privilegeService)
refreshFrom(privilegeService.submit(secret));
}
function deny() {
if (privilegeService)
refreshFrom(privilegeService.deny());
}
function cancel() {
if (privilegeService)
refreshFrom(privilegeService.cancel());
}
color: theme ? theme.withAlpha(theme.ui.backdrop, 0.94) : "black"
visible: state.active || state.error.length > 0
Keys.onEscapePressed: (event) => {
event.accepted = true;
root.cancel();
}
Rectangle {
anchors.centerIn: parent
width: Math.min(parent.width - 48, 560)
height: Math.min(parent.height - 48, 370)
radius: 22
color: root.theme ? root.theme.ui.backdrop : "transparent"
border.width: 1
border.color: root.theme ? root.theme.warning : "transparent"
Column {
anchors.fill: parent
anchors.margins: 22
spacing: 12
NuguText {
theme: root.theme
variant: "meta"
text: "Authentication required"
width: parent.width
wrapMode: Text.WordWrap
}
Rectangle {
objectName: "requestIdentityCard"
width: parent.width
height: 94
radius: 15
color: root.theme ? root.theme.withAlpha(root.theme.warning, 0.14) : "transparent"
border.width: 1
border.color: root.theme ? root.theme.warning : "transparent"
Column {
anchors.fill: parent
anchors.margins: 12
spacing: 5
NuguText {
theme: root.theme
variant: "title"
text: root.request.app || "polkit"
width: parent.width
elide: Text.ElideRight
}
NuguText {
theme: root.theme
text: root.request.message || "Authentication required"
width: parent.width
elide: Text.ElideRight
}
NuguText {
theme: root.theme
variant: "meta"
text: root.request.actionId || "native Polkit request"
width: parent.width
elide: Text.ElideMiddle
}
}
}
PrivilegeFailureShake {
objectName: "failureShakeSlot"
active: root.state.error && root.state.error.length > 0
width: parent.width
height: secretBox.height
Rectangle {
id: secretBox
objectName: "secretPromptField"
width: parent.width
height: 46
radius: 23
color: root.theme ? root.theme.withAlpha(root.state.error ? root.theme.error : root.theme.ui.focus, root.state.error ? 0.18 : 0.12) : "transparent"
border.width: 1
border.color: root.theme ? (root.state.error ? root.theme.error : root.theme.ui.focus) : "transparent"
NuguText {
anchors.left: parent.left
anchors.leftMargin: 14
anchors.verticalCenter: parent.verticalCenter
theme: root.theme
variant: "meta"
text: root.request.prompt || "Password"
opacity: 0.74
}
TextInput {
id: secretInput
anchors.left: parent.left
anchors.leftMargin: 106
anchors.right: parent.right
anchors.rightMargin: 14
anchors.verticalCenter: parent.verticalCenter
color: root.theme ? root.theme.content.normal : "white"
selectionColor: root.theme ? root.theme.ui.focus : "white"
selectedTextColor: root.theme ? root.theme.content.backdrop : "black"
font.family: "IBM Plex Mono"
echoMode: root.request.responseVisible ? TextInput.Normal : TextInput.Password
inputMethodHints: Qt.ImhSensitiveData
focus: root.state.active
onActiveFocusChanged: {
if (!activeFocus && root.state.active)
forceActiveFocus();
}
Keys.onReturnPressed: (event) => {
event.accepted = true;
root.submitSecret(text);
text = "";
}
Keys.onEnterPressed: (event) => {
event.accepted = true;
root.submitSecret(text);
text = "";
}
Keys.onEscapePressed: (event) => {
event.accepted = true;
root.cancel();
text = "";
}
}
}
}
NuguText {
theme: root.theme
variant: "meta"
text: root.state.error || "No decoration. No command construction. Native Polkit route."
width: parent.width
color: root.state.error && root.theme ? root.theme.error : (root.theme ? root.theme.content.normal : "white")
elide: Text.ElideRight
}
Row {
objectName: "denyCancelConfirmRow"
width: parent.width
spacing: 8
Repeater {
model: ["deny", "cancel", "confirm"]
delegate: Rectangle {
id: action
required property string modelData
width: Math.floor((parent.width - 16) / 3)
height: 38
radius: 12
color: root.theme ? root.theme.withAlpha(action.modelData === "confirm" ? root.theme.ui.focus : root.theme.ui.minor, action.modelData === "confirm" ? 0.16 : 0.1) : "transparent"
border.width: 1
border.color: root.theme ? (action.modelData === "confirm" ? root.theme.ui.focus : root.theme.ui.minor) : "transparent"
NuguText {
anchors.centerIn: parent
theme: root.theme
variant: "meta"
selected: action.modelData === "confirm"
text: action.modelData
}
MouseArea {
anchors.fill: parent
onClicked: {
if (action.modelData === "deny") {
root.deny();
} else if (action.modelData === "cancel") {
root.cancel();
} else {
root.submitSecret(secretInput.text);
secretInput.text = "";
}
}
}
}
}
}
}
}
}
}