repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

fix nuguland polkit prompt

7b009f7b3e012c30e10e951de203ac575a0ae705

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (2)

quickshell/nuguland/privilege-ui.test.mjs

Added
new file mode 100644
1 +import assert from "node:assert/strict";
2 +import { readFileSync } from "node:fs";
4 +const qml = readFileSync(new URL("./shell.qml", import.meta.url), "utf8");
5 +const start = qml.indexOf("component PrivilegeSurface: Rectangle");
6 +const end = qml.indexOf("component NokoFocusOverlay", start);
7 +assert.notEqual(start, -1, "PrivilegeSurface component exists");
8 +assert.notEqual(end, -1, "PrivilegeSurface end marker exists");
9 +const surface = qml.slice(start, end);
11 +assert.match(surface, /id:\s*commandText/, "privilege surface has dedicated command text");
12 +assert.match(surface, /elide:\s*Text\.ElideNone/, "command text must not truncate");
13 +assert.match(surface, /secretInput\.forceActiveFocus\(\)/, "password input is explicitly focused");
14 +assert.doesNotMatch(surface, /requestIdentityCard/, "debug identity card is not rendered");
15 +assert.doesNotMatch(surface, /actionId/, "debug polkit action id is not rendered");
17 +console.log("privilege-ui.test.mjs: ALL PASS");

quickshell/nuguland/shell.qml

Modified
1400 1400 "buttons": []
1402 1402 readonly property var request: panelState.request || ({})
1403 - readonly property var panel: panelState.privilegeSurfacePanelContract || ({})
1404 - readonly property string source: "Quickshell Polkit manual agent.qml plus Nuguland Polkit.qml plus Nuguland PolkitService.qml"
1405 - readonly property bool isolatedSecuritySurface: true
1406 - readonly property bool requestIdentityCard: true
1407 1403 readonly property bool secretPromptField: true
1408 1404 readonly property bool denyCancelConfirmRow: true
1409 1405 readonly property bool failureShakeSlot: true
1410 - readonly property bool noDecorativeDistraction: true
1411 - readonly property bool serviceFedOnly: true
1413 1407 function parseJson(text, valueWhenInvalid) {
1421 1415 function refreshFrom(text) {
1422 - state = parseJson(text, state);
1416 + panelState = parseJson(text, panelState);
1425 1419 function submitSecret(secret) {
1437 1431 refreshFrom(privilegeService.cancel());
1434 + function focusSecret() {
1435 + if (root.visible && root.panelState.active) {
1436 + root.forceActiveFocus();
1437 + secretInput.forceActiveFocus();
1440 1441 color: theme ? theme.withAlpha(theme.ui.backdrop, 0.94) : "black"
1441 1442 visible: panelState.active || panelState.error.length > 0
1443 + focus: visible
1444 + onVisibleChanged: Qt.callLater(root.focusSecret)
1445 + Component.onCompleted: Qt.callLater(root.focusSecret)
1442 1446 Keys.onEscapePressed: event => {
1443 1447 event.accepted = true;
1444 1448 root.cancel();
1447 1451 Rectangle {
1448 1452 anchors.centerIn: parent
1449 - width: Math.min(parent.width - 48, 520)
1453 + width: Math.min(parent.width - 48, 680)
1450 1454 height: cardColumn.implicitHeight + 44
1451 1455 radius: 24
1452 1456 color: root.theme ? root.theme.withAlpha(root.theme.ui.backdrop, 0.98) : "#181818"
1462 1466 anchors.margins: 22
1463 1467 spacing: 16
1465 - Row {
1469 + Column {
1466 1470 width: parent.width
1467 - spacing: 12
1471 + spacing: 10
1473 + NuguText {
1474 + theme: root.theme
1475 + variant: "title"
1476 + text: root.panelState.error ? "authentication unavailable" : "authorization required"
1477 + width: parent.width
1478 + elide: Text.ElideRight
1469 1481 Rectangle {
1470 - width: 38
1471 - height: 38
1472 - radius: 14
1473 - color: root.theme ? root.theme.withAlpha(root.panelState.error ? root.theme.error : root.theme.ui.accent, 0.18) : "transparent"
1482 + width: parent.width
1483 + height: commandText.implicitHeight + 20
1484 + radius: 16
1485 + color: root.theme ? root.theme.withAlpha(root.theme.ui.minor, 0.08) : "transparent"
1476 - anchors.centerIn: parent
1477 - text: root.panelState.error ? "!" : "◆"
1478 - color: root.theme ? (root.panelState.error ? root.theme.error : root.theme.ui.accent) : "white"
1479 - font.family: "IBM Plex Mono"
1480 - font.pixelSize: 18
1481 - font.bold: true
1488 + id: commandText
1485 - Column {
1486 - width: parent.width - 50
1487 - spacing: 3
1489 - NuguText {
1490 - theme: root.theme
1491 - variant: "title"
1492 - text: root.panelState.error ? "authentication unavailable" : "authorization required"
1493 - width: parent.width
1494 - elide: Text.ElideRight
1497 - NuguText {
1498 - theme: root.theme
1499 - variant: "meta"
1490 + anchors.left: parent.left
1491 + anchors.right: parent.right
1492 + anchors.top: parent.top
1493 + anchors.margins: 10
1500 1494 text: root.request.message || "A system change needs your password."
1501 - width: parent.width
1502 - wrapMode: Text.WordWrap
1503 - color: root.theme ? root.theme.ui.minor : "white"
1508 - Rectangle {
1509 - objectName: "requestIdentityCard"
1510 - width: parent.width
1511 - height: identityColumn.implicitHeight + 18
1512 - radius: 16
1513 - color: root.theme ? root.theme.withAlpha(root.theme.ui.minor, 0.07) : "transparent"
1515 - Column {
1516 - id: identityColumn
1518 - anchors.left: parent.left
1519 - anchors.right: parent.right
1520 - anchors.top: parent.top
1521 - anchors.margins: 10
1522 - spacing: 4
1524 - NuguText {
1525 - theme: root.theme
1526 - variant: "meta"
1527 - text: root.request.app || "system policy"
1528 - width: parent.width
1529 1495 color: root.theme ? root.theme.content.normal : "white"
1530 - elide: Text.ElideRight
1533 - NuguText {
1534 - visible: (root.request.actionId || "").length > 0
1535 - theme: root.theme
1536 - variant: "meta"
1537 - text: root.request.actionId || ""
1538 - width: parent.width
1539 - color: root.theme ? root.theme.ui.minor : "white"
1540 - elide: Text.ElideMiddle
1496 + font.family: "IBM Plex Sans"
1497 + font.pixelSize: 14
1498 + wrapMode: Text.WordWrap
1499 + elide: Text.ElideNone
1561 1520 width: parent.width
1562 1521 height: 48
1563 1522 radius: 16
1564 - color: root.theme ? root.theme.withAlpha(root.theme.ui.focus, 0.1) : "transparent"
1523 + color: root.theme ? root.theme.withAlpha(root.theme.ui.focus, secretInput.activeFocus ? 0.16 : 0.1) : "transparent"
1565 1524 border.width: 1
1566 - border.color: root.theme ? root.theme.withAlpha(root.panelState.error ? root.theme.error : root.theme.ui.focus, root.panelState.error ? 0.45 : 0.22) : "transparent"
1525 + border.color: root.theme ? root.theme.withAlpha(root.panelState.error ? root.theme.error : root.theme.ui.focus, root.panelState.error ? 0.55 : (secretInput.activeFocus ? 0.82 : 0.32)) : "transparent"
1568 1527 NuguText {
1569 1528 anchors.left: parent.left
1572 1531 theme: root.theme
1573 1532 variant: "meta"
1574 1533 text: root.request.prompt || "password"
1575 - opacity: 0.68
1534 + visible: secretInput.text.length === 0
1535 + opacity: secretInput.activeFocus ? 0.42 : 0.68
1538 + MouseArea {
1539 + anchors.fill: parent
1540 + cursorShape: Qt.IBeamCursor
1541 + onClicked: secretInput.forceActiveFocus()
1578 1544 TextInput {
1579 1545 id: secretInput
1581 - anchors.left: parent.left
1582 - anchors.leftMargin: 104
1583 - anchors.right: parent.right
1547 + anchors.fill: parent
1548 + anchors.leftMargin: 14
1584 1549 anchors.rightMargin: 14
1585 - anchors.verticalCenter: parent.verticalCenter
1550 + verticalAlignment: TextInput.AlignVCenter
1586 1551 color: root.theme ? root.theme.content.normal : "white"
1587 1552 selectionColor: root.theme ? root.theme.ui.focus : "white"
1588 1553 selectedTextColor: root.theme ? root.theme.content.backdrop : "black"
1590 1555 echoMode: root.request.responseVisible ? TextInput.Normal : TextInput.Password
1591 1556 inputMethodHints: Qt.ImhSensitiveData
1592 1557 focus: root.panelState.active
1593 - onActiveFocusChanged: {
1594 - if (!activeFocus && root.panelState.active)
1595 - forceActiveFocus();
1558 + activeFocusOnTab: true
1559 + onActiveFocusChanged: if (!activeFocus && root.panelState.active)
1560 + Qt.callLater(root.focusSecret)
1597 1561 Keys.onReturnPressed: event => {
1598 1562 event.accepted = true;
1599 1563 root.submitSecret(text);
1663 1627 anchors.centerIn: parent
1664 1628 theme: root.theme
1665 1629 variant: "meta"
1666 - selected: true
1667 1630 text: "authorize"
1668 - color: root.theme ? (parent.enabled ? root.theme.ui.accent : root.theme.ui.normal) : "white"
1631 + color: root.theme ? (parent.enabled ? root.theme.content.normal : root.theme.ui.normal) : "white"
1671 1634 MouseArea {