pax_global_header00006660000000000000000000000064150426725050014520gustar00rootroot0000000000000052 comment=7e4054410f6d6331b239fea1c659ad6a917fbf6a hyprpolkitagent-0.1.3/000077500000000000000000000000001504267250500147455ustar00rootroot00000000000000hyprpolkitagent-0.1.3/.clang-format000066400000000000000000000034161504267250500173240ustar00rootroot00000000000000--- Language: Cpp BasedOnStyle: LLVM AccessModifierOffset: -2 AlignAfterOpenBracket: Align AlignConsecutiveMacros: true AlignConsecutiveAssignments: true AlignEscapedNewlines: Right AlignOperands: false AlignTrailingComments: true AllowAllArgumentsOnNextLine: true AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: true AllowShortCaseLabelsOnASingleLine: true AllowShortFunctionsOnASingleLine: Empty AllowShortIfStatementsOnASingleLine: Never AllowShortLambdasOnASingleLine: All AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: Yes BreakBeforeBraces: Attach BreakBeforeTernaryOperators: false BreakConstructorInitializers: AfterColon ColumnLimit: 180 CompactNamespaces: false ConstructorInitializerAllOnOneLineOrOnePerLine: false ExperimentalAutoDetectBinPacking: false FixNamespaceComments: false IncludeBlocks: Preserve IndentCaseLabels: true IndentWidth: 4 PointerAlignment: Left ReflowComments: false SortIncludes: false SortUsingDeclarations: false SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true SpaceBeforeCtorInitializerColon: true SpaceBeforeInheritanceColon: true SpaceBeforeParens: ControlStatements SpaceBeforeRangeBasedForLoopColon: true SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 SpacesInAngles: false SpacesInCStyleCastParentheses: false SpacesInContainerLiterals: false SpacesInParentheses: false SpacesInSquareBrackets: false Standard: Auto TabWidth: 4 UseTab: Never AllowShortEnumsOnASingleLine: false BraceWrapping: AfterEnum: false AlignConsecutiveDeclarations: AcrossEmptyLines NamespaceIndentation: All hyprpolkitagent-0.1.3/.envrc000066400000000000000000000000121504267250500160540ustar00rootroot00000000000000use flake hyprpolkitagent-0.1.3/.github/000077500000000000000000000000001504267250500163055ustar00rootroot00000000000000hyprpolkitagent-0.1.3/.github/workflows/000077500000000000000000000000001504267250500203425ustar00rootroot00000000000000hyprpolkitagent-0.1.3/.github/workflows/nix.yml000066400000000000000000000031011504267250500216560ustar00rootroot00000000000000name: Build on: [push, pull_request, workflow_dispatch] jobs: nix: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install Nix uses: nixbuild/nix-quick-install-action@v31 with: nix_conf: | keep-env-derivations = true keep-outputs = true - name: Restore and save Nix store uses: nix-community/cache-nix-action@v6 with: # restore and save a cache using this key primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} # if there's no cache hit, restore a cache by this prefix restore-prefixes-first-match: nix-${{ runner.os }}- # collect garbage until the Nix store size (in bytes) is at most this number # before trying to save a new cache # 1G = 1073741824 gc-max-store-size-linux: 1G # do purge caches purge: true # purge all versions of the cache purge-prefixes: nix-${{ runner.os }}- # created more than this number of seconds ago purge-created: 0 # or, last accessed more than this number of seconds ago # relative to the start of the `Post Restore and save Nix store` phase purge-last-accessed: 0 # except any version with the key that is the same as the `primary-key` purge-primary-key: never # not needed (yet) # - uses: cachix/cachix-action@v12 # with: # name: hyprland # authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - name: Build run: nix build --print-build-logs --keep-going hyprpolkitagent-0.1.3/.gitignore000066400000000000000000000004761504267250500167440ustar00rootroot00000000000000# Prerequisites *.d # Compiled Object files *.slo *.lo *.o *.obj # Precompiled Headers *.gch *.pch # Compiled Dynamic libraries *.so *.dylib *.dll # Fortran module files *.mod *.smod # Compiled Static libraries *.lai *.la *.a *.lib # Executables *.exe *.out *.app .vscode/ .cache/ build/ compile_commands.json hyprpolkitagent-0.1.3/.gitmodules000066400000000000000000000001651504267250500171240ustar00rootroot00000000000000[submodule "subprojects/sdbus-cpp"] path = subprojects/sdbus-cpp url = https://github.com/Kistler-Group/sdbus-cpp/ hyprpolkitagent-0.1.3/CMakeLists.txt000066400000000000000000000030711504267250500175060ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.16) # Get version file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW) string(STRIP ${VER_RAW} VER) project(hpa VERSION ${VER} LANGUAGES CXX) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt6 6.5 REQUIRED COMPONENTS Widgets Quick QuickControls2) find_package(PkgConfig REQUIRED) set(CMAKE_CXX_STANDARD 23) pkg_check_modules( deps REQUIRED IMPORTED_TARGET hyprutils polkit-agent-1 polkit-qt6-1) qt_standard_project_setup(REQUIRES 6.5) qt_add_executable(hyprpolkitagent src/main.cpp src/core/Agent.cpp src/core/Agent.hpp src/core/PolkitListener.hpp src/core/PolkitListener.cpp src/QMLIntegration.cpp src/QMLIntegration.hpp ) qt_add_qml_module(hyprpolkitagent URI hpa VERSION 1.0 QML_FILES qml/main.qml SOURCES src/QMLIntegration.cpp src/QMLIntegration.hpp ) target_link_libraries(hyprpolkitagent PRIVATE Qt6::Widgets Qt6::Quick Qt6::Gui Qt6::QuickControls2 PkgConfig::deps ) include(GNUInstallDirs) set(LIBEXECDIR ${CMAKE_INSTALL_FULL_LIBEXECDIR}) configure_file(assets/hyprpolkitagent-service.in hyprpolkitagent.service @ONLY) configure_file(assets/hyprpolkitagent-dbus.in hyprpolkitagent-dbus.service @ONLY) install(TARGETS hyprpolkitagent DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}) install(FILES ${CMAKE_BINARY_DIR}/hyprpolkitagent.service DESTINATION "lib/systemd/user") install(FILES ${CMAKE_BINARY_DIR}/hyprpolkitagent-dbus.service DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services RENAME org.hyprland.hyprpolkitagent.service) hyprpolkitagent-0.1.3/LICENSE000066400000000000000000000027371504267250500157630ustar00rootroot00000000000000BSD 3-Clause License Copyright (c) 2024, Hypr Development Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. hyprpolkitagent-0.1.3/README.md000066400000000000000000000003231504267250500162220ustar00rootroot00000000000000# hyprpolkitagent A simple polkit authentication agent for Hyprland, written in QT/QML. ![](./assets/screenshot.png) ## Usage See [the hyprland wiki](https://wiki.hyprland.org/Hypr-Ecosystem/hyprpolkitagent/)hyprpolkitagent-0.1.3/VERSION000066400000000000000000000000051504267250500160100ustar00rootroot000000000000000.1.3hyprpolkitagent-0.1.3/assets/000077500000000000000000000000001504267250500162475ustar00rootroot00000000000000hyprpolkitagent-0.1.3/assets/hyprpolkitagent-dbus.in000066400000000000000000000001731504267250500227570ustar00rootroot00000000000000[D-BUS Service] Name=org.hyprland.hyprpolkitagent Exec=@LIBEXECDIR@/hyprpolkitagent SystemdService=hyprpolkitagent.service hyprpolkitagent-0.1.3/assets/hyprpolkitagent-service.in000066400000000000000000000004671504267250500234700ustar00rootroot00000000000000[Unit] Description=Hyprland Polkit Authentication Agent PartOf=graphical-session.target After=graphical-session.target ConditionEnvironment=WAYLAND_DISPLAY [Service] ExecStart=@LIBEXECDIR@/hyprpolkitagent Slice=session.slice TimeoutStopSec=5sec Restart=on-failure [Install] WantedBy=graphical-session.target hyprpolkitagent-0.1.3/assets/screenshot.png000066400000000000000000000534541504267250500211450ustar00rootroot00000000000000PNG  IHDRB (ف cHRMz&u0`:pQ<bKGDCtIME ,BvV IDATxwxUlI-z )*+/^?vc (4ޓ!mMYvS\\2̙;g(OikJB!h,&_G}!P4򵆖s" !K=TZ<W^}B!|QxWc_ϛt_~PԘ!Im{0T_0:Zr|iI= !"0wk5k^ jL`_υB860h8=lV"Ԕi߆~ !"p >{OKc| CB?T=x?W Aށ;US#Py^B!wCB pz=lt| B~> !ScZ ǠxZ!_-Bwy7l!B_}38N?r[ϽÐg7x#wː/B"._LwBÂg)]!B!,敔_rJU1aHT- w a!!(!B(J^l_u {\~hl-ÄBќH^ 0j/{|<]MNgi^fsB!`EUBau2x-5h4{ŅB! !֠W:|{ "/BEQ Au-Cvz9w'i=`4W5/MT&CGSFi"X ]=5NbX~~_+q띗3(7QUŇ[ʡ漊n[W c<]O;)OghDX7˼)9}5ʡ(5wVl^p>dާI- k΍I$EhC5'dHZ/籽#>i:虂uǕjFr-WsHnP]^gsWpḎzSYӆWDI709%SXo/Y|ButƦA w|#>_('MAQjЯ(H3c3G _>B+$OAP.!c?)=c6@MjO L4ڶɃS1;ʦvm-i1_| cnCher˽?qIGxVBWj`}M˛.Hԧ1-An{y;!m`R@fؗBGϨ?hƨ$EAuQ~ʫ{HN&Ҩ:J(9BKChB"UGt#z}!ߺV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p|P$B{~ B._ai~OyB*Du`q%;0y _Aއ< !"p>z_ڻU3 y y, / cςVRA=,&H!jLV:k< Uݫ_0N5HB=H*+ 9s =xC)B AZ;j&G!Z| yv5[l|ƪۼw >-A9$&!H!<"@+fP:KW/nufx<B!D`y0| DO}7\Y!k$ǟ%9T'IkB!5UW됯pV :+8)!s!BƞE櫅~[IENDB`hyprpolkitagent-0.1.3/flake.lock000066400000000000000000000067421504267250500167120ustar00rootroot00000000000000{ "nodes": { "hyprland-qt-support": { "inputs": { "hyprlang": "hyprlang", "nixpkgs": [ "nixpkgs" ], "systems": [ "systems" ] }, "locked": { "lastModified": 1749154592, "narHash": "sha256-DO7z5CeT/ddSGDEnK9mAXm1qlGL47L3VAHLlLXoCjhE=", "owner": "hyprwm", "repo": "hyprland-qt-support", "rev": "4c8053c3c888138a30c3a6c45c2e45f5484f2074", "type": "github" }, "original": { "owner": "hyprwm", "repo": "hyprland-qt-support", "type": "github" } }, "hyprlang": { "inputs": { "hyprutils": "hyprutils", "nixpkgs": [ "hyprland-qt-support", "nixpkgs" ], "systems": [ "hyprland-qt-support", "systems" ] }, "locked": { "lastModified": 1749145882, "narHash": "sha256-qr0KXeczF8Sma3Ae7+dR2NHhvG7YeLBJv19W4oMu6ZE=", "owner": "hyprwm", "repo": "hyprlang", "rev": "1bfb84f54d50c7ae6558c794d3cfd5f6a7e6e676", "type": "github" }, "original": { "owner": "hyprwm", "repo": "hyprlang", "type": "github" } }, "hyprutils": { "inputs": { "nixpkgs": [ "hyprland-qt-support", "hyprlang", "nixpkgs" ], "systems": [ "hyprland-qt-support", "hyprlang", "systems" ] }, "locked": { "lastModified": 1749135356, "narHash": "sha256-Q8mAKMDsFbCEuq7zoSlcTuxgbIBVhfIYpX0RjE32PS0=", "owner": "hyprwm", "repo": "hyprutils", "rev": "e36db00dfb3a3d3fdcc4069cb292ff60d2699ccb", "type": "github" }, "original": { "owner": "hyprwm", "repo": "hyprutils", "type": "github" } }, "hyprutils_2": { "inputs": { "nixpkgs": [ "nixpkgs" ], "systems": [ "systems" ] }, "locked": { "lastModified": 1749135356, "narHash": "sha256-Q8mAKMDsFbCEuq7zoSlcTuxgbIBVhfIYpX0RjE32PS0=", "owner": "hyprwm", "repo": "hyprutils", "rev": "e36db00dfb3a3d3fdcc4069cb292ff60d2699ccb", "type": "github" }, "original": { "owner": "hyprwm", "repo": "hyprutils", "type": "github" } }, "nixpkgs": { "locked": { "lastModified": 1748929857, "narHash": "sha256-lcZQ8RhsmhsK8u7LIFsJhsLh/pzR9yZ8yqpTzyGdj+Q=", "owner": "NixOS", "repo": "nixpkgs", "rev": "c2a03962b8e24e669fb37b7df10e7c79531ff1a4", "type": "github" }, "original": { "owner": "NixOS", "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { "hyprland-qt-support": "hyprland-qt-support", "hyprutils": "hyprutils_2", "nixpkgs": "nixpkgs", "systems": "systems" } }, "systems": { "locked": { "lastModified": 1689347949, "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", "owner": "nix-systems", "repo": "default-linux", "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", "type": "github" }, "original": { "owner": "nix-systems", "repo": "default-linux", "type": "github" } } }, "root": "root", "version": 7 } hyprpolkitagent-0.1.3/flake.nix000066400000000000000000000023431504267250500165510ustar00rootroot00000000000000{ description = "A polkit authentication agent written in QT/QML"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; systems.url = "github:nix-systems/default-linux"; hyprutils = { url = "github:hyprwm/hyprutils"; inputs.nixpkgs.follows = "nixpkgs"; inputs.systems.follows = "systems"; }; hyprland-qt-support = { url = "github:hyprwm/hyprland-qt-support"; inputs.nixpkgs.follows = "nixpkgs"; inputs.systems.follows = "systems"; }; }; outputs = { self, nixpkgs, systems, ... } @ inputs: let inherit (nixpkgs) lib; eachSystem = lib.genAttrs (import systems); pkgsFor = eachSystem ( system: import nixpkgs { localSystem = system; overlays = [self.overlays.default]; } ); in { overlays = import ./nix/overlays.nix {inherit inputs self lib;}; packages = eachSystem (system: { default = self.packages.${system}.hyprpolkitagent; inherit (pkgsFor.${system}) hyprpolkitagent; }); devShells = eachSystem (system: { default = import ./nix/shell.nix { pkgs = pkgsFor.${system}; inherit (pkgsFor.${system}) hyprpolkitagent; }; }); }; } hyprpolkitagent-0.1.3/nix/000077500000000000000000000000001504267250500155435ustar00rootroot00000000000000hyprpolkitagent-0.1.3/nix/default.nix000066400000000000000000000020521504267250500177060ustar00rootroot00000000000000{ lib, stdenv, cmake, pkg-config, hyprutils, hyprland-qt-support, kdePackages, polkit, qt6, version ? "0", }: let inherit (lib.sources) cleanSource cleanSourceWith; inherit (lib.strings) hasSuffix; in stdenv.mkDerivation { pname = "hyprpolkitagent"; inherit version; src = cleanSourceWith { filter = name: _type: let baseName = baseNameOf (toString name); in ! (hasSuffix ".nix" baseName); src = cleanSource ../.; }; nativeBuildInputs = [ cmake pkg-config qt6.wrapQtAppsHook ]; buildInputs = [ hyprutils hyprland-qt-support polkit kdePackages.polkit-qt-1 qt6.qtbase qt6.qtsvg qt6.qtwayland ]; meta = { description = "A polkit authentication agent written in QT/QML"; homepage = "https://github.com/hyprwm/hyprpolkitagent"; license = lib.licenses.bsd3; maintainers = [lib.maintainers.fufexan]; mainProgram = "hyprpolkitagent"; platforms = lib.platforms.linux; }; } hyprpolkitagent-0.1.3/nix/overlays.nix000066400000000000000000000013031504267250500201240ustar00rootroot00000000000000{ inputs, self, lib, }: let mkDate = longDate: (lib.concatStringsSep "-" [ (builtins.substring 0 4 longDate) (builtins.substring 4 2 longDate) (builtins.substring 6 2 longDate) ]); date = mkDate (self.lastModifiedDate or "19700101"); version = lib.removeSuffix "\n" (builtins.readFile ../VERSION); in { default = self.overlays.hyprpolkitagent; hyprpolkitagent = lib.composeManyExtensions [ inputs.hyprutils.overlays.default inputs.hyprland-qt-support.overlays.default (final: prev: { hyprpolkitagent = final.callPackage ./. { stdenv = final.gcc15Stdenv; version = "${version}+date=${date}_${self.shortRev or "dirty"}"; }; }) ]; } hyprpolkitagent-0.1.3/nix/shell.nix000066400000000000000000000013471504267250500173770ustar00rootroot00000000000000{ pkgs ? import {}, hyprpolkitagent ? pkgs.callPackage ./default.nix {}, ... }: pkgs.mkShell { inputsFrom = [ hyprpolkitagent ]; nativeBuildInputs = [ pkgs.clang-tools ]; shellHook = let inherit (pkgs.lib.strings) concatMapStringsSep; qtLibPath = f: concatMapStringsSep ":" f (with pkgs.qt6; [ qtbase qtdeclarative qtwayland pkgs.hyprland-qt-support ]); in '' # Add Qt-related environment variables. export QT_PLUGIN_PATH=${qtLibPath (p: "${p}/lib/qt-6/plugins")} export QML2_IMPORT_PATH=${qtLibPath (p: "${p}/lib/qt-6/qml")} # Generate compile_commands.json CMAKE_EXPORT_COMPILE_COMMANDS=1 cmake -S . -B ./build ln -s build/compile_commands.json . ''; } hyprpolkitagent-0.1.3/qml/000077500000000000000000000000001504267250500155365ustar00rootroot00000000000000hyprpolkitagent-0.1.3/qml/main.qml000066400000000000000000000106651504267250500172050ustar00rootroot00000000000000import QtQuick import QtQuick.Controls import QtQuick.Layouts ApplicationWindow { id: window property var windowWidth: Math.round(fontMetrics.height * 32.2856) property var windowHeight: Math.round(fontMetrics.height * 13.9528) property var heightSafeMargin: 15 minimumWidth: Math.max(windowWidth, mainLayout.Layout.minimumWidth) + mainLayout.anchors.margins * 2 minimumHeight: Math.max(windowHeight, mainLayout.Layout.minimumHeight) + mainLayout.anchors.margins * 2 + heightSafeMargin maximumWidth: minimumWidth maximumHeight: minimumHeight visible: true onClosing: { hpa.setResult("fail"); } FontMetrics { id: fontMetrics } SystemPalette { id: system colorGroup: SystemPalette.Active } Item { id: mainLayout anchors.fill: parent Keys.onEscapePressed: (e) => { hpa.setResult("fail"); } Keys.onReturnPressed: (e) => { hpa.setResult("auth:" + passwordField.text); } Keys.onEnterPressed: (e) => { hpa.setResult("auth:" + passwordField.text); } ColumnLayout { anchors.fill: parent anchors.margins: 4 Label { color: Qt.darker(system.windowText, 0.8) font.bold: true font.pointSize: Math.round(fontMetrics.height * 1.05) text: "Authenticating for " + hpa.getUser() Layout.alignment: Qt.AlignHCenter Layout.maximumWidth: parent.width elide: Text.ElideRight wrapMode: Text.WordWrap } HSeparator { Layout.topMargin: fontMetrics.height / 2 Layout.bottomMargin: fontMetrics.height / 2 } Label { color: system.windowText text: hpa.getMessage() Layout.maximumWidth: parent.width elide: Text.ElideRight wrapMode: Text.WordWrap } TextField { id: passwordField Layout.topMargin: fontMetrics.height / 2 placeholderText: "Password" Layout.alignment: Qt.AlignHCenter hoverEnabled: true persistentSelection: true echoMode: TextInput.Password focus: true Connections { target: hpa function onFocusField() { passwordField.focus = true; } function onBlockInput(block) { passwordField.readOnly = block; if (!block) { passwordField.focus = true; passwordField.selectAll(); } } } } Label { id: errorLabel color: "red" font.italic: true Layout.topMargin: 0 text: "" Layout.alignment: Qt.AlignHCenter Connections { target: hpa function onSetErrorString(e) { errorLabel.text = e; } } } Rectangle { color: "transparent" Layout.fillHeight: true } HSeparator { Layout.topMargin: fontMetrics.height / 2 Layout.bottomMargin: fontMetrics.height / 2 } RowLayout { Layout.alignment: Qt.AlignRight Layout.rightMargin: fontMetrics.height / 2 Button { text: "Cancel" onClicked: (e) => { hpa.setResult("fail"); } } Button { text: "Authenticate" onClicked: (e) => { hpa.setResult("auth:" + passwordField.text); } } } } } component Separator: Rectangle { color: Qt.darker(window.palette.text, 1.5) } component HSeparator: Separator { implicitHeight: 1 Layout.fillWidth: true Layout.leftMargin: fontMetrics.height * 8 Layout.rightMargin: fontMetrics.height * 8 } } hyprpolkitagent-0.1.3/src/000077500000000000000000000000001504267250500155345ustar00rootroot00000000000000hyprpolkitagent-0.1.3/src/QMLIntegration.cpp000066400000000000000000000015621504267250500211010ustar00rootroot00000000000000#include "QMLIntegration.hpp" #include "core/Agent.hpp" #include "core/PolkitListener.hpp" void CQMLIntegration::onExit() { g_pAgent->submitResultThreadSafe(result.toStdString()); } void CQMLIntegration::setResult(QString str) { result = str; g_pAgent->submitResultThreadSafe(result.toStdString()); } QString CQMLIntegration::getMessage() { return g_pAgent->listener.session.inProgress ? g_pAgent->listener.session.message : "An application is requesting authentication."; } QString CQMLIntegration::getUser() { return g_pAgent->listener.session.inProgress ? g_pAgent->listener.session.selectedUser.toString() : "an unknown user"; } void CQMLIntegration::setError(QString str) { emit setErrorString(str); } void CQMLIntegration::focus() { emit focusField(); } void CQMLIntegration::setInputBlocked(bool blocked) { emit blockInput(blocked); } hyprpolkitagent-0.1.3/src/QMLIntegration.hpp000066400000000000000000000014701504267250500211040ustar00rootroot00000000000000#pragma once #include #include #include #include class CQMLIntegration : public QObject { Q_OBJECT; Q_PROPERTY(QString errorText MEMBER errorText); public: explicit CQMLIntegration(QObject* parent = nullptr) : QObject(parent) { ; } virtual ~CQMLIntegration() { ; } void setError(QString str); void focus(); void setInputBlocked(bool blocked); QString result = "fail", errorText = ""; Q_INVOKABLE QString getMessage(); Q_INVOKABLE QString getUser(); Q_INVOKABLE void setResult(QString str); public slots: void onExit(); signals: void setErrorString(QString err); void focusField(); void blockInput(bool block); }; hyprpolkitagent-0.1.3/src/core/000077500000000000000000000000001504267250500164645ustar00rootroot00000000000000hyprpolkitagent-0.1.3/src/core/Agent.cpp000066400000000000000000000044211504267250500202270ustar00rootroot00000000000000#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1 #include #include #include using namespace Qt::Literals::StringLiterals; #include "Agent.hpp" #include "../QMLIntegration.hpp" CAgent::CAgent() { ; } CAgent::~CAgent() { ; } bool CAgent::start() { sessionSubject = makeShared(getpid()); listener.registerListener(*sessionSubject, "/org/hyprland/PolicyKit1/AuthenticationAgent"); int argc = 1; char* argv = (char*)"hyprpolkitagent"; QApplication app(argc, &argv); app.setApplicationName("Hyprland Polkit Agent"); QGuiApplication::setQuitOnLastWindowClosed(false); app.exec(); return true; } void CAgent::resetAuthState() { if (authState.authing) { authState.authing = false; if (authState.qmlEngine) authState.qmlEngine->deleteLater(); if (authState.qmlIntegration) authState.qmlIntegration->deleteLater(); authState.qmlEngine = nullptr; authState.qmlIntegration = nullptr; } } void CAgent::initAuthPrompt() { resetAuthState(); if (!listener.session.inProgress) { std::print(stderr, "INTERNAL ERROR: Spawning qml prompt but session isn't in progress\n"); return; } std::print("Spawning qml prompt\n"); authState.authing = true; authState.qmlIntegration = new CQMLIntegration(); if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) QQuickStyle::setStyle("org.hyprland.style"); authState.qmlEngine = new QQmlApplicationEngine(); authState.qmlEngine->rootContext()->setContextProperty("hpa", authState.qmlIntegration); authState.qmlEngine->load(QUrl{u"qrc:/qt/qml/hpa/qml/main.qml"_s}); authState.qmlIntegration->focusField(); } bool CAgent::resultReady() { return !lastAuthResult.used; } void CAgent::submitResultThreadSafe(const std::string& result) { lastAuthResult.used = false; lastAuthResult.result = result; const bool PASS = result.starts_with("auth:"); std::print("Got result from qml: {}\n", PASS ? "auth:**PASSWORD**" : result); if (PASS) listener.submitPassword(result.substr(result.find(":") + 1).c_str()); else listener.cancelPending(); } hyprpolkitagent-0.1.3/src/core/Agent.hpp000066400000000000000000000021321504267250500202310ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include "PolkitListener.hpp" #include #include using namespace Hyprutils::Memory; #define SP CSharedPointer #define WP CWeakPointer class CQMLIntegration; class CAgent { public: CAgent(); ~CAgent(); void submitResultThreadSafe(const std::string& result); void resetAuthState(); bool start(); void initAuthPrompt(); private: struct { bool authing = false; QQmlApplicationEngine* qmlEngine = nullptr; CQMLIntegration* qmlIntegration = nullptr; } authState; struct { std::string result; bool used = true; } lastAuthResult; CPolkitListener listener; SP sessionSubject; bool resultReady(); friend class CQMLIntegration; friend class CPolkitListener; }; inline std::unique_ptr g_pAgent;hyprpolkitagent-0.1.3/src/core/PolkitListener.cpp000066400000000000000000000103731504267250500221440ustar00rootroot00000000000000#include #include #include "PolkitListener.hpp" #include "../QMLIntegration.hpp" #include "Agent.hpp" #include #include using namespace PolkitQt1::Agent; CPolkitListener::CPolkitListener(QObject* parent) : Listener(parent) { ; } void CPolkitListener::initiateAuthentication(const QString& actionId, const QString& message, const QString& iconName, const PolkitQt1::Details& details, const QString& cookie, const PolkitQt1::Identity::List& identities, AsyncResult* result) { std::print("> New authentication session\n"); if (session.inProgress) { result->setError("Authentication in progress"); result->setCompleted(); std::print("> REJECTING: Another session present\n"); return; } if (identities.isEmpty()) { result->setError("No identities, this is a problem with your system configuration."); result->setCompleted(); std::print("> REJECTING: No idents\n"); return; } session.selectedUser = identities.at(0); session.cookie = cookie; session.result = result; session.actionId = actionId; session.message = message; session.iconName = iconName; session.gainedAuth = false; session.cancelled = false; session.inProgress = true; g_pAgent->initAuthPrompt(); reattempt(); } void CPolkitListener::reattempt() { session.cancelled = false; session.session = new Session(session.selectedUser, session.cookie, session.result); connect(session.session, SIGNAL(request(QString, bool)), this, SLOT(request(QString, bool))); connect(session.session, SIGNAL(completed(bool)), this, SLOT(completed(bool))); connect(session.session, SIGNAL(showError(QString)), this, SLOT(showError(QString))); connect(session.session, SIGNAL(showInfo(QString)), this, SLOT(showInfo(QString))); session.session->initiate(); } bool CPolkitListener::initiateAuthenticationFinish() { std::print("> initiateAuthenticationFinish()\n"); return true; } void CPolkitListener::cancelAuthentication() { std::print("> cancelAuthentication()\n"); session.cancelled = true; finishAuth(); } void CPolkitListener::request(const QString& request, bool echo) { std::print("> PKS request: {} echo: {}\n", request.toStdString(), echo); } void CPolkitListener::completed(bool gainedAuthorization) { std::print("> PKS completed: {}\n", gainedAuthorization ? "Auth successful" : "Auth unsuccessful"); session.gainedAuth = gainedAuthorization; if (!gainedAuthorization && g_pAgent->authState.qmlIntegration) g_pAgent->authState.qmlIntegration->setError("Authentication failed"); finishAuth(); } void CPolkitListener::showError(const QString& text) { std::print("> PKS showError: {}\n", text.toStdString()); if (g_pAgent->authState.qmlIntegration) g_pAgent->authState.qmlIntegration->setError(text); } void CPolkitListener::showInfo(const QString& text) { std::print("> PKS showInfo: {}\n", text.toStdString()); } void CPolkitListener::finishAuth() { if (!session.inProgress) { std::print("> finishAuth: ODD. !session.inProgress\n"); return; } if (!session.gainedAuth && !session.cancelled) { std::print("> finishAuth: Did not gain auth. Reattempting.\n"); if (g_pAgent->authState.qmlIntegration) g_pAgent->authState.qmlIntegration->blockInput(false); session.session->deleteLater(); reattempt(); return; } std::print("> finishAuth: Gained auth, cleaning up.\n"); session.inProgress = false; if (session.session) { session.session->result()->setCompleted(); session.session->deleteLater(); } else session.result->setCompleted(); g_pAgent->resetAuthState(); } void CPolkitListener::submitPassword(const QString& pass) { if (!session.session) return; session.session->setResponse(pass); if (g_pAgent->authState.qmlIntegration) g_pAgent->authState.qmlIntegration->blockInput(true); } void CPolkitListener::cancelPending() { if (!session.session) return; session.session->cancel(); session.cancelled = true; finishAuth(); } hyprpolkitagent-0.1.3/src/core/PolkitListener.hpp000066400000000000000000000030101504267250500221370ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include class CPolkitListener : public PolkitQt1::Agent::Listener { Q_OBJECT; Q_DISABLE_COPY(CPolkitListener); public: CPolkitListener(QObject* parent = nullptr); ~CPolkitListener() override {}; void submitPassword(const QString& pass); void cancelPending(); public Q_SLOTS: void initiateAuthentication(const QString& actionId, const QString& message, const QString& iconName, const PolkitQt1::Details& details, const QString& cookie, const PolkitQt1::Identity::List& identities, PolkitQt1::Agent::AsyncResult* result) override; bool initiateAuthenticationFinish() override; void cancelAuthentication() override; void request(const QString& request, bool echo); void completed(bool gainedAuthorization); void showError(const QString& text); void showInfo(const QString& text); private: struct { bool inProgress = false, cancelled = false, gainedAuth = false; QString cookie, message, iconName, actionId; PolkitQt1::Agent::AsyncResult* result = nullptr; PolkitQt1::Identity selectedUser; PolkitQt1::Agent::Session* session = nullptr; } session; void reattempt(); void finishAuth(); friend class CAgent; friend class CQMLIntegration; }; hyprpolkitagent-0.1.3/src/main.cpp000066400000000000000000000002331504267250500171620ustar00rootroot00000000000000#include "core/Agent.hpp" int main(int argc, char* argv[]) { g_pAgent = std::make_unique(); return g_pAgent->start() == false ? 1 : 0; }