mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 23:09:26 -05:00
quickshell polkit agent
This commit is contained in:
@@ -7,7 +7,6 @@ exec-once = qs -c $qsConfig &
|
||||
|
||||
# Core components (authentication, lock screen, notification daemon)
|
||||
exec-once = gnome-keyring-daemon --start --components=secrets
|
||||
exec-once = /usr/lib/polkit-kde-authentication-agent-1 || /usr/libexec/polkit-kde-authentication-agent-1 || /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 || /usr/libexec/polkit-gnome-authentication-agent-1
|
||||
exec-once = hypridle
|
||||
exec-once = dbus-update-activation-environment --all
|
||||
exec-once = sleep 1 && dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP # Some fix idk
|
||||
|
||||
@@ -10,7 +10,8 @@ Rectangle {
|
||||
|
||||
property bool show: false
|
||||
default property alias data: contentColumn.data
|
||||
property real backgroundHeight: 600
|
||||
property real backgroundHeight: dialogBackground.implicitHeight
|
||||
property real backgroundWidth: 350
|
||||
property real backgroundAnimationMovementDistance: 60
|
||||
|
||||
signal dismiss()
|
||||
@@ -49,7 +50,7 @@ Rectangle {
|
||||
|
||||
property real targetY: root.height / 2 - root.backgroundHeight / 2
|
||||
y: root.show ? targetY : (targetY - root.backgroundAnimationMovementDistance)
|
||||
implicitWidth: 350
|
||||
implicitWidth: root.backgroundWidth
|
||||
implicitHeight: contentColumn.implicitHeight + dialogBackground.radius * 2
|
||||
Behavior on implicitHeight {
|
||||
NumberAnimation {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import qs.modules.common
|
||||
import qs.modules.common.functions
|
||||
import qs.modules.common.widgets
|
||||
|
||||
StyledText {
|
||||
text: "Some body content"
|
||||
color: Appearance.colors.colOnSurfaceVariant
|
||||
font.pixelSize: Appearance.font.pixelSize.small
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
@@ -35,7 +35,7 @@ Column {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
leftMargin: 4
|
||||
rightMargin: leftMargin
|
||||
rightMargin: 4
|
||||
}
|
||||
configuration: StyledSlider.Configuration.S
|
||||
onMoved: root.moved()
|
||||
|
||||
@@ -6,6 +6,8 @@ import qs.modules.common.widgets
|
||||
|
||||
StyledText {
|
||||
text: "Dialog Title"
|
||||
color: Appearance.colors.colOnSurface
|
||||
wrapMode: Text.Wrap
|
||||
font {
|
||||
pixelSize: Appearance.font.pixelSize.title
|
||||
family: Appearance.font.family.title
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import qs
|
||||
import qs.services
|
||||
import qs.modules.common
|
||||
import qs.modules.common.widgets
|
||||
import qs.modules.common.functions
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Hyprland
|
||||
|
||||
Scope {
|
||||
id: root
|
||||
|
||||
Loader {
|
||||
active: PolkitService.active
|
||||
sourceComponent: Variants {
|
||||
model: Quickshell.screens
|
||||
delegate: PanelWindow {
|
||||
id: panelWindow
|
||||
required property var modelData
|
||||
screen: modelData
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
left: true
|
||||
right: true
|
||||
bottom: true
|
||||
}
|
||||
|
||||
color: "transparent"
|
||||
WlrLayershell.namespace: "quickshell:polkit"
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
exclusionMode: ExclusionMode.Ignore
|
||||
|
||||
PolkitContent {
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
import qs.services
|
||||
import qs.modules.common
|
||||
import qs.modules.common.widgets
|
||||
|
||||
Item {
|
||||
id: root
|
||||
readonly property bool usePasswordChars: !PolkitService.flow?.responseVisible ?? true
|
||||
|
||||
Keys.onPressed: event => { // Esc to close
|
||||
if (event.key === Qt.Key_Escape) {
|
||||
PolkitService.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
function submit() {
|
||||
PolkitService.submit(inputField.text);
|
||||
}
|
||||
Connections {
|
||||
target: PolkitService
|
||||
function onInteractionAvailableChanged() {
|
||||
if (!PolkitService.interactionAvailable) return;
|
||||
inputField.text = "";
|
||||
inputField.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: bg
|
||||
anchors.fill: parent
|
||||
color: Appearance.colors.colScrim
|
||||
opacity: 0
|
||||
Component.onCompleted: {
|
||||
opacity = 1
|
||||
}
|
||||
Behavior on opacity {
|
||||
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
|
||||
}
|
||||
}
|
||||
|
||||
WindowDialog {
|
||||
anchors.centerIn: parent
|
||||
backgroundWidth: 450
|
||||
show: false
|
||||
Component.onCompleted: {
|
||||
show = true
|
||||
}
|
||||
|
||||
MaterialSymbol {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
iconSize: 26
|
||||
text: "shield_locked"
|
||||
color: Appearance.colors.colSecondary
|
||||
}
|
||||
|
||||
WindowDialogTitle {
|
||||
id: titleText
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: Translation.tr("Authentication")
|
||||
}
|
||||
|
||||
WindowDialogParagraph {
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
text: {
|
||||
if (!PolkitService.flow) return;
|
||||
return PolkitService.flow.message.endsWith(".")
|
||||
? PolkitService.flow.message.slice(0, -1)
|
||||
: PolkitService.flow.message
|
||||
}
|
||||
}
|
||||
|
||||
MaterialTextField {
|
||||
id: inputField
|
||||
Layout.fillWidth: true
|
||||
focus: true
|
||||
enabled: PolkitService.interactionAvailable
|
||||
placeholderText: {
|
||||
const inputPrompt = PolkitService.flow?.inputPrompt.trim() ?? "";
|
||||
const cleanedInputPrompt = inputPrompt.endsWith(":") ? inputPrompt.slice(0, -1) : inputPrompt;
|
||||
return cleanedInputPrompt || (root.usePasswordChars ? Translation.tr("Password") : Translation.tr("Input"))
|
||||
}
|
||||
echoMode: root.usePasswordChars ? TextInput.Password : TextInput.Normal
|
||||
onAccepted: root.submit();
|
||||
}
|
||||
|
||||
WindowDialogButtonRow {
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
DialogButton {
|
||||
buttonText: Translation.tr("Cancel")
|
||||
onClicked: PolkitService.cancel();
|
||||
}
|
||||
DialogButton {
|
||||
enabled: PolkitService.interactionAvailable
|
||||
buttonText: Translation.tr("OK")
|
||||
onClicked: root.submit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import Quickshell.Hyprland
|
||||
|
||||
WindowDialog {
|
||||
id: root
|
||||
backgroundHeight: 600
|
||||
|
||||
WindowDialogTitle {
|
||||
text: Translation.tr("Bluetooth devices")
|
||||
|
||||
@@ -15,6 +15,7 @@ WindowDialog {
|
||||
id: root
|
||||
property var screen: root.QsWindow.window?.screen
|
||||
property var brightnessMonitor: Brightness.getMonitorForScreen(screen)
|
||||
backgroundHeight: 600
|
||||
|
||||
WindowDialogTitle {
|
||||
text: Translation.tr("Eye protection")
|
||||
|
||||
@@ -9,6 +9,7 @@ import Quickshell
|
||||
|
||||
WindowDialog {
|
||||
id: root
|
||||
backgroundHeight: 600
|
||||
|
||||
WindowDialogTitle {
|
||||
text: Translation.tr("Connect to Wi-Fi")
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Services.Polkit
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
property alias agent: polkitAgent
|
||||
property alias active: polkitAgent.isActive
|
||||
property alias flow: polkitAgent.flow
|
||||
property bool interactionAvailable: false
|
||||
|
||||
function cancel() {
|
||||
root.flow.cancelAuthenticationRequest()
|
||||
}
|
||||
|
||||
function submit(string) {
|
||||
root.flow.submit(string)
|
||||
root.interactionAvailable = false
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root.flow
|
||||
function onAuthenticationFailed() {
|
||||
root.interactionAvailable = true;
|
||||
}
|
||||
}
|
||||
|
||||
PolkitAgent {
|
||||
id: polkitAgent
|
||||
onAuthenticationRequestStarted: {
|
||||
root.interactionAvailable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,6 @@ Singleton {
|
||||
signal contentLoaded(var data)
|
||||
|
||||
function reread() { // Proper reload in case the file was incorrect before
|
||||
print("rereading translations for", translationReader.languageCode);
|
||||
translationReader.path = "";
|
||||
translationReader.path = `${translationReader.translationsDir}/${translationReader.languageCode}.json`;
|
||||
translationReader.reload();
|
||||
|
||||
@@ -19,6 +19,7 @@ import qs.modules.notificationPopup
|
||||
import qs.modules.onScreenDisplay
|
||||
import qs.modules.onScreenKeyboard
|
||||
import qs.modules.overview
|
||||
import qs.modules.polkit
|
||||
import qs.modules.regionSelector
|
||||
import qs.modules.screenCorners
|
||||
import qs.modules.sessionScreen
|
||||
@@ -43,6 +44,7 @@ ShellRoot {
|
||||
property bool enableLock: true
|
||||
property bool enableMediaControls: true
|
||||
property bool enableNotificationPopup: true
|
||||
property bool enablePolkit: true
|
||||
property bool enableOnScreenDisplay: true
|
||||
property bool enableOnScreenKeyboard: true
|
||||
property bool enableOverview: true
|
||||
@@ -76,6 +78,7 @@ ShellRoot {
|
||||
LazyLoader { active: enableOnScreenDisplay; component: OnScreenDisplay {} }
|
||||
LazyLoader { active: enableOnScreenKeyboard; component: OnScreenKeyboard {} }
|
||||
LazyLoader { active: enableOverview; component: Overview {} }
|
||||
LazyLoader { active: enablePolkit; component: Polkit {} }
|
||||
LazyLoader { active: enableRegionSelector; component: RegionSelector {} }
|
||||
LazyLoader { active: enableReloadPopup; component: ReloadPopup {} }
|
||||
LazyLoader { active: enableScreenCorners; component: ScreenCorners {} }
|
||||
|
||||
Reference in New Issue
Block a user