dotfiles bugabingas dorkfiles
owned by bugabinga
README Source History Refs Compare Notes Search Review guide improve polkit password UX
2abcaa1adcaf26c98aa72202a6882f65973a0185
Oliver Jan Krylow <oliver@bugabinga.net > · 8 Jul 2026
unsigned
Browse files Compare with HEAD
Changed files (4) quickshell/nuguland/privilege-ui.test.mjs Modified 12 12 assert.match(surface, /PrivilegeUi\.commandMarkdown/, "command text uses markdown-style formatter");
13 13 assert.match(surface, /textFormat:\s*Text\.RichText/, "command text renders rich text");
14 14 assert.match(surface, /elide:\s*Text\.ElideNone/, "command text must not truncate");
15 + assert.match(surface, /property bool secretVisible:\s*false/, "password reveal state exists");
16 + assert.match(surface, /id:\s*revealButton/, "password reveal button exists");
17 + assert.match(surface, /echoMode:\s*root\.secretVisible \|\| root\.request\.responseVisible \? TextInput\.Normal : TextInput\.Password/, "reveal button controls password echo mode");
18 + assert.match(surface, /password rejected/, "wrong password message is human-readable");
15 19 assert.match(surface, /secretInput\.forceActiveFocus\(\)/, "password input is explicitly focused");
16 20 assert.match(surface, /id:\s*focusRetry/, "focus retry timer exists for map-time focus races");
17 21 assert.match(qml, /id:\s*privilegeSurface/, "privilege surface instance is addressable from PanelWindow");
quickshell/nuguland/privilege.js Modified 9 9 .replace(
/"/ g ,
""" );
12 + function stripCommandQuotes (command) {
13 + var text
= String (command
|| "" ).trim();
14 + if (text.length
>= 2 ) {
15 + var first
= text[
0 ];
16 + var last
= text[text.length
- 1 ];
17 + if ((first
=== "`" || first
=== "'" || first
=== "\"" )
&& (last
=== "'" || last
=== "`" || last
=== "\"" ))
18 + return text.slice(
1 ,
- 1 );
12 23 function commandFromMessage (message) {
13 24 var text
= String (message
|| "" ).trim();
14 25 var match
= / ^ Authentication is needed to run\s + (. +? )\s + as the super user\. ?$ / i .exec(text);
15 - return match
? match[
1 ]
: text;
26 + return stripCommandQuotes(match
? match[
1 ]
: text);
18 29 function commandLines (command) {
19 - return String (command
|| "" )
21 - .map(
function (line) {
return line.trim(); })
30 + var text
= stripCommandQuotes(command);
31 + var shell
= / ^ (\/usr\/bin\/sh | sh)\s + -c\s + (. + ) $ / .exec(text);
32 + var lines
= shell
? [shell[
1 ]
+ " -c" ].concat(shell[
2 ].split(
/\s + &&\s + / ))
: text.split(
/\s + &&\s + / );
33 + return lines.map(
function (line) {
return line.trim(); })
22 34 .filter(
function (line) {
return line.length
> 0 ; });
25 37 function commandMarkdown (message) {
26 38 var lines
= commandLines(commandFromMessage(message));
27 39 if (lines.length
=== 0 ) lines
= [
"A system change needs your password." ];
28 - return "<pre style=\"font-family:'IBM Plex Mono'; font-size:13px; line-height:1.35; white-space:pre-wrap; margin:0\">" + 29 - lines.map(escapeHtml).join(
"\n" )
+ 40 + return "<span style=\"font-family:'IBM Plex Mono'; font-size:13px; line-height:1.35\">" + 41 + lines.map(escapeHtml).join(
"<br>" )
+ 33 45 if (
typeof module !== 'undefined' && module .
exports ) {
35 47 escapeHtml: escapeHtml,
36 48 commandFromMessage: commandFromMessage,
49 + commandLines: commandLines,
37 50 commandMarkdown: commandMarkdown
quickshell/nuguland/privilege.test.js Modified 4 4 var assert
= require (
'assert' );
5 5 var P
= require (
'./privilege.js' );
7 7 var message
= "Authentication is needed to run /usr/bin/sh -c pacman -S --needed --noconfirm ddcutil && modprobe i2c-dev && udevadm trigger --subsystem-match=i2c-dev as the super user" ;
9 9 assert.strictEqual(
P .commandFromMessage(message),
"/usr/bin/sh -c pacman -S --needed --noconfirm ddcutil && modprobe i2c-dev && udevadm trigger --subsystem-match=i2c-dev" );
10 + assert.strictEqual(
P .commandFromMessage(
"Authentication is needed to run `/usr/bin/sh -c sleep 30' as the super user" ),
"/usr/bin/sh -c sleep 30" );
10 11 assert.strictEqual(
P .commandFromMessage(
"Authentication required" ),
"Authentication required" );
12 + assert.deepStrictEqual(
P .commandLines(
"/usr/bin/sh -c pacman -S --needed --noconfirm ddcutil && modprobe i2c-dev" ), [
"/usr/bin/sh -c" ,
"pacman -S --needed --noconfirm ddcutil" ,
"modprobe i2c-dev" ]);
12 14 var html
= P .commandMarkdown(message);
13 - assert(html.indexOf(
"<pre" )
>= 0 ,
"renders a code block" );
14 - assert(html.indexOf(
"/usr/bin/sh -c" )
>= 0 ,
"keeps shell command visible" );
15 + assert(html.indexOf(
"font-family:'IBM Plex Mono'" )
>= 0 ,
"renders a monospace command block" );
16 + assert(html.indexOf(
"/usr/bin/sh -c<br>" )
>= 0 ,
"puts shell wrapper on its own line" );
15 17 assert(html.indexOf(
"pacman -S --needed --noconfirm ddcutil" )
>= 0 ,
"splits chained command onto readable line" );
16 18 assert(html.indexOf(
"modprobe i2c-dev" )
>= 0 ,
"shows modprobe line" );
17 19 assert(html.indexOf(
"udevadm trigger --subsystem-match=i2c-dev" )
>= 0 ,
"shows udevadm line" );
quickshell/nuguland/shell.qml Modified 1408 1408 readonly property var request: panelState.request
|| ({})
1409 + property bool secretVisible:
false 1409 1410 readonly property bool secretPromptField:
true 1410 1411 readonly property bool denyCancelConfirmRow:
true 1411 1412 readonly property bool failureShakeSlot:
true 1448 1449 visible: panelState.active
|| panelState.error.length
> 0 1450 1451 onVisibleChanged :
Qt .callLater(root.focusSecret)
1452 + onPanelStateChanged :
if (panelState.active)
1453 + Qt .callLater(root.focusSecret)
1451 1454 Component .onCompleted:
Qt .callLater(root.focusSecret)
1490 1493 theme : root.theme
1491 1494 variant :
"title" 1492 - text : root.panelState.error
? "authentication unavailable" : "authorization required" 1495 + text : root.panelState.error
&& ! root.panelState.active
? "authentication unavailable" : "authorization required" 1493 1496 width : parent.width
1494 1497 elide :
Text .ElideRight
1535 1538 width: parent.width
1538 - color: root.theme
? root.theme.withAlpha(root.theme.ui.focus, secretInput.activeFocus
? 0.16 : 0.1 )
: "transparent" 1541 + color: root.theme
? root.theme.withAlpha(root.panelState.error
? root.theme.error
: root.theme.ui.focus, root.panelState.error
? 0.12 : (secretInput.activeFocus
? 0.16 : 0.1 ))
: "transparent" 1539 1542 border.width:
1 1540 - 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" 1543 + border.color: root.theme
? root.theme.withAlpha(root.panelState.error
? root.theme.error
: root.theme.ui.focus, root.panelState.error
? 0.72 : (secretInput.activeFocus
? 0.82 : 0.32 ))
: "transparent" 1545 + Behavior on color {
1547 + duration : root.theme
&& root.theme.lowPowerMode
? 0 : 120 1551 + Behavior on border.color {
1553 + duration : root.theme
&& root.theme.lowPowerMode
? 0 : 120 1543 1558 anchors.left: parent.left
1562 1577 anchors.fill: parent
1563 1578 anchors.leftMargin:
14 1564 - anchors.rightMargin:
14 1579 + anchors.rightMargin:
58 1565 1580 verticalAlignment:
TextInput .AlignVCenter
1566 1581 color: root.theme
? root.theme.content.normal
: "white" 1567 1582 selectionColor: root.theme
? root.theme.ui.focus
: "white" 1568 1583 selectedTextColor: root.theme
? root.theme.content.backdrop
: "black" 1569 1584 font.family:
"IBM Plex Mono" 1570 - echoMode: root.request.responseVisible
? TextInput .Normal
: TextInput .Password
1585 + echoMode: root.secretVisible
|| root.request.responseVisible
? TextInput .Normal
: TextInput .Password
1571 1586 inputMethodHints:
Qt .ImhSensitiveData
1572 1587 focus: root.panelState.active
1573 1588 activeFocusOnTab:
true 1611 + anchors.right: parent.right
1612 + anchors.rightMargin:
8 1613 + anchors.verticalCenter: parent.verticalCenter
1617 + color : root.theme
? root.theme.withAlpha(root.secretVisible
? root.theme.ui.accent
: root.theme.ui.minor, revealArea.containsMouse
? 0.22 : 0.12 )
: "transparent" 1618 + border.width: root.secretVisible
? 1 : 0 1619 + border.color: root.theme
? root.theme.withAlpha(root.theme.ui.accent,
0.62 )
: "transparent" 1622 + anchors.centerIn: parent
1623 + text : root.secretVisible
? "hide" : "show" 1624 + color : root.theme
? root.theme.content.normal
: "white" 1625 + font.family:
"IBM Plex Sans" 1626 + font.pixelSize:
11 1632 + anchors.fill: parent
1633 + hoverEnabled :
true 1634 + cursorShape :
Qt .PointingHandCursor
1636 + root.secretVisible
= ! root.secretVisible;
1637 + secretInput.forceActiveFocus();
1595 1644 visible : root.panelState.error
&& root.panelState.error.length
> 0 1596 1645 theme : root.theme
1597 1646 variant :
"meta" 1598 - text : root.panelState.error
=== "no-active-polkit-flow" ? "No active authentication request." : root.panelState.error
1647 + text : root.panelState.error
=== "Authentication failed" ? "password rejected" : (root.panelState.error
=== "no-active-polkit-flow" ? "no active authentication request" : root.panelState.error)
1599 1648 width : parent.width
1600 1649 color : root.theme
? root.theme.error
: "white" 1601 1650 elide :
Text .ElideRight