From dd2df931a3be1a6518c1e9fbff438de4274456cd Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 11 Sep 2025 22:52:35 +0200 Subject: ... --- _sources/generated.json | 48 +- _sources/generated.nix | 42 +- accounts/gkleen@sif/default.nix | 14 - accounts/gkleen@sif/niri/default.nix | 11 - .../shell/quickshell-plugins/CMakeLists.txt | 37 +- .../shell/quickshell-plugins/Systemd.cpp | 207 +++++- .../shell/quickshell-plugins/Systemd.hpp | 129 ++++ .../org.freedesktop.DBus.Properties.xml | 28 + .../org.freedesktop.login1.Manager.xml | 445 +++++++++++ .../org.freedesktop.login1.Session.xml | 146 ++++ .../org.freedesktop.systemd1.Manager.xml | 817 +++++++++++++++++++++ .../gkleen@sif/shell/quickshell/Lockscreen.qml | 34 + accounts/gkleen@sif/shell/quickshell/NiriIdle.qml | 30 + .../shell/quickshell/WorkspaceSwitcher.qml | 2 +- accounts/gkleen@sif/shell/quickshell/shell.qml | 1 + accounts/gkleen@sif/systemd.nix | 5 - nvfetcher.toml | 4 + overlays/quickshell/default.nix | 12 +- 18 files changed, 1934 insertions(+), 78 deletions(-) create mode 100644 accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.DBus.Properties.xml create mode 100644 accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.login1.Manager.xml create mode 100644 accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.login1.Session.xml create mode 100644 accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.systemd1.Manager.xml create mode 100644 accounts/gkleen@sif/shell/quickshell/NiriIdle.qml diff --git a/_sources/generated.json b/_sources/generated.json index 62c68113..037f97e2 100644 --- a/_sources/generated.json +++ b/_sources/generated.json @@ -22,7 +22,7 @@ }, "bpf-examples": { "cargoLocks": null, - "date": "2025-08-18", + "date": "2025-09-09", "extract": null, "name": "bpf-examples", "passthru": null, @@ -34,12 +34,12 @@ "name": null, "owner": "xdp-project", "repo": "bpf-examples", - "rev": "f19bc1a9402b6fb014e3b7114f06ffba5abdf5cc", - "sha256": "sha256-syYoC3XOJTUaL/Db0T10mSUak83qAl6Tx2fE6k4XLpI=", + "rev": "19e2dfa93a9f472d3e53226fab4b63be12e93d22", + "sha256": "sha256-6SGT4izVWrxwoYkAhxtaAeIsVLqLPmg71kY/7NSS4BI=", "sparseCheckout": [], "type": "github" }, - "version": "f19bc1a9402b6fb014e3b7114f06ffba5abdf5cc" + "version": "19e2dfa93a9f472d3e53226fab4b63be12e93d22" }, "emacs-scratch_el": { "cargoLocks": null, @@ -99,7 +99,7 @@ }, "mako": { "cargoLocks": null, - "date": "2025-04-17", + "date": "2025-09-11", "extract": null, "name": "mako", "passthru": null, @@ -109,13 +109,13 @@ "fetchSubmodules": false, "leaveDotGit": false, "name": null, - "rev": "84637d1cb42def0ef74d6ec961e05c3900b4c23f", - "sha256": "sha256-5Mv0P/SoUiJIiYvGm5wvNZhtz2ytwsqqRc3Pk3ju0WA=", + "rev": "8318972590420c042c0177af16e26a1768550fab", + "sha256": "sha256-Y/exF/Pv60E31Zl+M1zboWkmkZgOUCA3l93OKbtvZ+g=", "sparseCheckout": [], "type": "git", "url": "https://github.com/emersion/mako" }, - "version": "84637d1cb42def0ef74d6ec961e05c3900b4c23f" + "version": "8318972590420c042c0177af16e26a1768550fab" }, "mpv-autosave": { "cargoLocks": null, @@ -327,11 +327,11 @@ "passthru": null, "pinned": false, "src": { - "sha256": "sha256-JDKt+MzxxyaFWnzuq/7FfT/JPUknH/RRw4Cb8XDOtlk=", + "sha256": "sha256-mg4iyp/heYzSoK+pGSMYfZb5UauoBMrEL1QPH6EoJ8o=", "type": "tarball", - "url": "https://github.com/hansmi/prometheus-lvm-exporter/archive/refs/tags/v0.6.0.tar.gz" + "url": "https://github.com/hansmi/prometheus-lvm-exporter/archive/refs/tags/v0.6.1.tar.gz" }, - "version": "0.6.0" + "version": "0.6.1" }, "psql-versioning": { "cargoLocks": null, @@ -353,6 +353,26 @@ }, "version": "330cb9da36651b701085ad53ae75ff296d02202a" }, + "quickshell": { + "cargoLocks": null, + "date": "2025-09-04", + "extract": null, + "name": "quickshell", + "passthru": null, + "pinned": false, + "src": { + "deepClone": false, + "fetchSubmodules": false, + "leaveDotGit": false, + "name": null, + "rev": "6eb12551baf924f8fdecdd04113863a754259c34", + "sha256": "sha256-GhuD9QVimjynHI0OOyZsqJsnlXr2orowh9H+HYz4YMs=", + "sparseCheckout": [], + "type": "git", + "url": "https://git.outfoxxed.me/quickshell/quickshell.git" + }, + "version": "6eb12551baf924f8fdecdd04113863a754259c34" + }, "scutiger": { "cargoLocks": null, "date": null, @@ -486,10 +506,10 @@ "pinned": false, "src": { "name": null, - "sha256": "sha256-2oc7z0JBd6tcO3AfqU6kzawXvzrsXvN7kfUwyQ3ve88=", + "sha256": "sha256-nOCA+AsiWOhy/op19HB+osZE5pdHcYbiC5oE2anqN88=", "type": "url", - "url": "https://pypi.org/packages/source/y/yt_dlp/yt_dlp-2025.8.20.tar.gz" + "url": "https://pypi.org/packages/source/y/yt_dlp/yt_dlp-2025.9.5.tar.gz" }, - "version": "2025.8.20" + "version": "2025.9.5" } } \ No newline at end of file diff --git a/_sources/generated.nix b/_sources/generated.nix index 4368c98a..f19940ba 100644 --- a/_sources/generated.nix +++ b/_sources/generated.nix @@ -18,15 +18,15 @@ }; bpf-examples = { pname = "bpf-examples"; - version = "f19bc1a9402b6fb014e3b7114f06ffba5abdf5cc"; + version = "19e2dfa93a9f472d3e53226fab4b63be12e93d22"; src = fetchFromGitHub { owner = "xdp-project"; repo = "bpf-examples"; - rev = "f19bc1a9402b6fb014e3b7114f06ffba5abdf5cc"; + rev = "19e2dfa93a9f472d3e53226fab4b63be12e93d22"; fetchSubmodules = true; - sha256 = "sha256-syYoC3XOJTUaL/Db0T10mSUak83qAl6Tx2fE6k4XLpI="; + sha256 = "sha256-6SGT4izVWrxwoYkAhxtaAeIsVLqLPmg71kY/7NSS4BI="; }; - date = "2025-08-18"; + date = "2025-09-09"; }; emacs-scratch_el = { pname = "emacs-scratch_el"; @@ -61,17 +61,17 @@ }; mako = { pname = "mako"; - version = "84637d1cb42def0ef74d6ec961e05c3900b4c23f"; + version = "8318972590420c042c0177af16e26a1768550fab"; src = fetchgit { url = "https://github.com/emersion/mako"; - rev = "84637d1cb42def0ef74d6ec961e05c3900b4c23f"; + rev = "8318972590420c042c0177af16e26a1768550fab"; fetchSubmodules = false; deepClone = false; leaveDotGit = false; sparseCheckout = [ ]; - sha256 = "sha256-5Mv0P/SoUiJIiYvGm5wvNZhtz2ytwsqqRc3Pk3ju0WA="; + sha256 = "sha256-Y/exF/Pv60E31Zl+M1zboWkmkZgOUCA3l93OKbtvZ+g="; }; - date = "2025-04-17"; + date = "2025-09-11"; }; mpv-autosave = { pname = "mpv-autosave"; @@ -196,10 +196,10 @@ }; prometheus-lvm-exporter = { pname = "prometheus-lvm-exporter"; - version = "0.6.0"; + version = "0.6.1"; src = fetchTarball { - url = "https://github.com/hansmi/prometheus-lvm-exporter/archive/refs/tags/v0.6.0.tar.gz"; - sha256 = "sha256-JDKt+MzxxyaFWnzuq/7FfT/JPUknH/RRw4Cb8XDOtlk="; + url = "https://github.com/hansmi/prometheus-lvm-exporter/archive/refs/tags/v0.6.1.tar.gz"; + sha256 = "sha256-mg4iyp/heYzSoK+pGSMYfZb5UauoBMrEL1QPH6EoJ8o="; }; }; psql-versioning = { @@ -216,6 +216,20 @@ }; date = "2023-11-23"; }; + quickshell = { + pname = "quickshell"; + version = "6eb12551baf924f8fdecdd04113863a754259c34"; + src = fetchgit { + url = "https://git.outfoxxed.me/quickshell/quickshell.git"; + rev = "6eb12551baf924f8fdecdd04113863a754259c34"; + fetchSubmodules = false; + deepClone = false; + leaveDotGit = false; + sparseCheckout = [ ]; + sha256 = "sha256-GhuD9QVimjynHI0OOyZsqJsnlXr2orowh9H+HYz4YMs="; + }; + date = "2025-09-04"; + }; scutiger = { pname = "scutiger"; version = "0.2.0"; @@ -294,10 +308,10 @@ }; yt-dlp = { pname = "yt-dlp"; - version = "2025.8.20"; + version = "2025.9.5"; src = fetchurl { - url = "https://pypi.org/packages/source/y/yt_dlp/yt_dlp-2025.8.20.tar.gz"; - sha256 = "sha256-2oc7z0JBd6tcO3AfqU6kzawXvzrsXvN7kfUwyQ3ve88="; + url = "https://pypi.org/packages/source/y/yt_dlp/yt_dlp-2025.9.5.tar.gz"; + sha256 = "sha256-nOCA+AsiWOhy/op19HB+osZE5pdHcYbiC5oE2anqN88="; }; }; } diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index c786c629..8e68eda9 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix @@ -450,20 +450,6 @@ in { serverUrl = "https://etesync.yggdrasil.li"; }; - swayidle = { - enable = true; - events = [ - { event = "before-sleep"; command = lockCommand; } - { event = "lock"; command = lockCommand; } - ]; - timeouts = [ - { timeout = 600; command = lockCommand; } - ]; - extraArgs = [ - "-w" - "idlehint" "30" - ]; - }; poweralertd.enable = true; }; diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index 10b85169..32d55f97 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix @@ -231,17 +231,6 @@ in { config = { home.packages = [ pkgs.xwayland-satellite-unstable ]; - services.swayidle = { - events = [ - { event = "after-resume"; command = "${lib.getExe niri} msg action power-on-monitors"; } - ]; - timeouts = [ - { timeout = 540; - command = "${lib.getExe niri} msg action power-off-monitors"; - } - ]; - }; - systemd.user.sockets.niri-workspace-history = { Socket = { ListenStream = "%t/niri-workspace-history.sock"; diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/CMakeLists.txt b/accounts/gkleen@sif/shell/quickshell-plugins/CMakeLists.txt index a7e88fa7..020c0515 100644 --- a/accounts/gkleen@sif/shell/quickshell-plugins/CMakeLists.txt +++ b/accounts/gkleen@sif/shell/quickshell-plugins/CMakeLists.txt @@ -106,12 +106,47 @@ set_source_files_properties(org.keepassxc.KeePassXC.MainWindow.xml PROPERTIES CLASSNAME DBusKeePassXC NO_NAMESPACE TRUE ) - qt_add_dbus_interface(DBUS_INTERFACES org.keepassxc.KeePassXC.MainWindow.xml dbus_keepassxc ) +set_source_files_properties(org.freedesktop.systemd1.Manager.xml PROPERTIES + CLASSNAME DBusSystemdManager + NO_NAMESPACE TRUE +) +qt_add_dbus_interface(DBUS_INTERFACES + org.freedesktop.systemd1.Manager.xml + dbus_systemd_manager +) + +set_source_files_properties(org.freedesktop.login1.Manager.xml PROPERTIES + CLASSNAME DBusLogindManager + NO_NAMESPACE TRUE +) +qt_add_dbus_interface(DBUS_INTERFACES + org.freedesktop.login1.Manager.xml + dbus_logind_manager +) + +set_source_files_properties(org.freedesktop.login1.Session.xml PROPERTIES + CLASSNAME DBusLogindSession + NO_NAMESPACE TRUE +) +qt_add_dbus_interface(DBUS_INTERFACES + org.freedesktop.login1.Session.xml + dbus_logind_session +) + +set_source_files_properties(org.freedesktop.DBus.Properties.xml PROPERTIES + CLASSNAME DBusProperties + NO_NAMESPACE TRUE +) +qt_add_dbus_interface(DBUS_INTERFACES + org.freedesktop.DBus.Properties.xml + dbus_properties +) + include_directories(${CMAKE_SOURCE_DIR}/build) target_compile_features(customplugin PUBLIC cxx_std_26) diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.cpp b/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.cpp index 5e607709..790f514f 100644 --- a/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.cpp +++ b/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.cpp @@ -1,24 +1,205 @@ #include "Systemd.hpp" +#include + #include -#include +#include +#include +#include +#include -void Systemd::stopUserUnit(const QString& unit, const QString& mode) { - QDBusMessage m = QDBusMessage::createMethodCall( +Systemd::Systemd(QObject* parent) : QObject(parent) { + this->systemdManager = new DBusSystemdManager( "org.freedesktop.systemd1", "/org/freedesktop/systemd1", - "org.freedesktop.systemd1.Manager", - "StopUnit" - ) << unit << mode; - QDBusConnection::sessionBus().send(m); + QDBusConnection::sessionBus(), + this + ); + this->logindManager = new DBusLogindManager( + "org.freedesktop.login1", + "/org/freedesktop/login1", + QDBusConnection::systemBus(), + this + ); + + QDBusReply sessionPath = this->logindManager->GetSession("auto"); + qDebug() << sessionPath; + this->logindSession = new DBusLogindSession( + "org.freedesktop.login1", + sessionPath.value().path(), + QDBusConnection::systemBus(), + this + ); + this->logindSessionProperties = new DBusProperties( + "org.freedesktop.login1", + sessionPath.value().path(), + QDBusConnection::systemBus(), + this + ); + + QObject::connect(this->logindManager, &DBusLogindManager::PrepareForShutdown, this, &Systemd::shutdown); + QObject::connect(this->logindManager, &DBusLogindManager::PrepareForSleep, this, &Systemd::sleep); + QObject::connect(this->logindSession, &DBusLogindSession::Lock, this, &Systemd::lock); + QObject::connect(this->logindSession, &DBusLogindSession::Unlock, this, &Systemd::unlock); + QObject::connect(this->logindSessionProperties, &DBusProperties::PropertiesChanged, this, &Systemd::onLogindSessionPropertiesChanged); +} + +void Systemd::onLogindSessionPropertiesChanged(const QString& interface_name, const QVariantMap& changed_properties, const QStringList& invalidated_properties) { + if (changed_properties.contains("IdleHint") || invalidated_properties.contains("IdleHint")) + emit this->idleHintChanged(); + if (changed_properties.contains("LockedHint") || invalidated_properties.contains("LockedHint")) + emit this->lockedHintChanged(); +} + +void Systemd::stopUserUnit(const QString& unit, const QString& mode) { + this->systemdManager->StopUnit(unit, mode); } void Systemd::setBrightness(const QString& subsystem, const QString& name, quint32 brightness) { - QDBusMessage m = QDBusMessage::createMethodCall( + this->logindSession->SetBrightness(subsystem, name, brightness); +} + +bool Systemd::idleHint() { + return this->logindSession->idleHint(); +} +void Systemd::setIdleHint(bool idle) { + this->logindSession->SetIdleHint(idle); +} +bool Systemd::lockedHint() { + return this->logindSession->lockedHint(); +} +void Systemd::setLockedHint(bool locked) { + this->logindSession->SetLockedHint(locked); +} + +std::string SystemdInhibitorParams::toString(SystemdInhibitorParams::WhatItem what) { + if (what == SystemdInhibitorParams::Shutdown) + return "shutdown"; + else if (what == SystemdInhibitorParams::Sleep) + return "sleep"; + else if (what == SystemdInhibitorParams::Idle) + return "idle"; + else if (what == SystemdInhibitorParams::HandlePowerKey) + return "handle-power-key"; + else if (what == SystemdInhibitorParams::HandleSuspendKey) + return "handle-suspend-key"; + else if (what == SystemdInhibitorParams::HandleHibernateKey) + return "handle-hibernate-key"; + else if (what == SystemdInhibitorParams::HandleLidSwitch) + return "handle-lid-switch"; + return ""; +} + +std::string SystemdInhibitorParams::toString(SystemdInhibitorParams::What what) { + std::ostringstream res; + bool first = true; + for (const WhatItem& item: SystemdInhibitorParams::allWhatItems) { + if (!(what & item)) + continue; + + if (!first) + res << ":"; + else + first = false; + res << SystemdInhibitorParams::toString(item); + } + return res.str(); +} + +std::string SystemdInhibitorParams::toString(SystemdInhibitorParams::Mode mode) { + if (mode == SystemdInhibitorParams::Block) + return "block"; + else if (mode == SystemdInhibitorParams::BlockWeak) + return "block-weak"; + else if (mode == SystemdInhibitorParams::Delay) + return "delay"; + return ""; +} + +bool SystemdInhibitor::enabled() const { return static_cast(this->activeInhibitor); } +void SystemdInhibitor::setEnabled(bool enabled) { + if (enabled) + this->update(); + else + this->release(); +} + +SystemdInhibitorParams::What SystemdInhibitor::what() const { return this->mWhat; } +void SystemdInhibitor::setWhat(SystemdInhibitorParams::What what) { + this->mWhat = what; + this->update(); +} + +QString SystemdInhibitor::who() const { return this->mWho; } +void SystemdInhibitor::setWho(QString who) { + this->mWho = who; + this->update(); +} + +QString SystemdInhibitor::why() const { return this->mWhy; } +void SystemdInhibitor::setWhy(QString why) { + this->mWhy = why; + this->update(); +} + +SystemdInhibitorParams::Mode SystemdInhibitor::mode() const { return this->mMode; } +void SystemdInhibitor::setMode(SystemdInhibitorParams::Mode mode) { + this->mMode = mode; + this->update(); +} + +SystemdInhibitor::ActiveSystemdInhibitor::ActiveSystemdInhibitor(SystemdInhibitorParams::What what_, QString who_, QString why_, SystemdInhibitorParams::Mode mode_): what(what_), who(who_), why(why_), mode(mode_) { + DBusLogindManager logindManager( "org.freedesktop.login1", - "/org/freedesktop/login1/session/auto", - "org.freedesktop.login1.Session", - "SetBrightness" - ) << subsystem << name << brightness; - QDBusConnection::systemBus().send(m); + "/org/freedesktop/login1", + QDBusConnection::systemBus() + ); + QDBusReply fd_ = logindManager.Inhibit(QString::fromStdString(SystemdInhibitorParams::toString(what)), who, why, QString::fromStdString(SystemdInhibitorParams::toString(mode))); + if (fd_.error().isValid()) + throw fd_.error(); + this->fd = ::dup(fd_.value().fileDescriptor()); +} +SystemdInhibitor::ActiveSystemdInhibitor::~ActiveSystemdInhibitor() { + if (this->fd != -1) + ::close(this->fd); +} + +void SystemdInhibitor::release() { + if (!this->activeInhibitor) + return; + + this->activeInhibitor.reset(); + emit this->enabledChanged(); +} + +void SystemdInhibitor::update() { + if (!this->mWhat || this->mWho.isEmpty() || this->mWhy.isEmpty() || !this->mMode) + if (this->activeInhibitor) + this->release(); + else + return; + + if (this->activeInhibitor && this->mWhat == this->activeInhibitor->what && this->mWho == this->activeInhibitor->who && this->mWhy == this->activeInhibitor->why && this->mMode == this->activeInhibitor->mode) + return; + + std::unique_ptr otherInhibitor; + try { + otherInhibitor.reset(new SystemdInhibitor::ActiveSystemdInhibitor(this->mWhat, this->mWho, this->mWhy, this->mMode)); + } catch (const QDBusError& err) { + qCritical().noquote() + << err.name().toStdString() << " " << err.message().toStdString(); + return; + } + this->activeInhibitor.swap(otherInhibitor); + + if (!otherInhibitor && this->activeInhibitor) + emit this->enabledChanged(); + if (otherInhibitor && otherInhibitor->what != this->activeInhibitor->what) + emit this->whatChanged(); + if (otherInhibitor && otherInhibitor->who != this->activeInhibitor->who) + emit this->whoChanged(); + if (otherInhibitor && otherInhibitor->why != this->activeInhibitor->why) + emit this->whyChanged(); + if (otherInhibitor && otherInhibitor->mode != this->activeInhibitor->mode) + emit this->modeChanged(); } diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp b/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp index f8841518..cf978fea 100644 --- a/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp +++ b/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp @@ -1,14 +1,143 @@ #pragma once +#include +#include +#include + #include +#include #include +#include "dbus_systemd_manager.h" +#include "dbus_logind_manager.h" +#include "dbus_logind_session.h" +#include "dbus_properties.h" + class Systemd : public QObject { Q_OBJECT; QML_SINGLETON; QML_ELEMENT; public: + explicit Systemd(QObject* parent = nullptr); + + Q_PROPERTY(bool idleHint READ idleHint WRITE setIdleHint NOTIFY idleHintChanged) + Q_PROPERTY(bool lockedHint READ lockedHint WRITE setLockedHint NOTIFY lockedHintChanged) + Q_INVOKABLE void stopUserUnit(const QString& unit, const QString& mode); Q_INVOKABLE void setBrightness(const QString& subsystem, const QString& name, quint32 brightness); + Q_INVOKABLE void setIdleHint(bool idle); + Q_INVOKABLE void setLockedHint(bool locked); + + bool idleHint(); + bool lockedHint(); + +signals: + void shutdown(bool before); + void sleep(bool before); + void lock(); + void unlock(); + void idleHintChanged(); + void lockedHintChanged(); + +private slots: + void onLogindSessionPropertiesChanged(const QString& interface_name, const QVariantMap& changed_properties, const QStringList& invalidated_properties); + +private: + DBusSystemdManager* systemdManager; + DBusLogindManager* logindManager; + DBusLogindSession* logindSession; + DBusProperties* logindSessionProperties; +}; + +class SystemdInhibitorParams : public QObject { + Q_OBJECT; + QML_ELEMENT; + QML_SINGLETON; + +public: + enum WhatItem : uint8_t { + Shutdown = 0b1, + Sleep = 0b10, + Idle = 0b100, + HandlePowerKey = 0b1000, + HandleSuspendKey = 0b10000, + HandleHibernateKey = 0b100000, + HandleLidSwitch = 0b1000000, + }; + Q_ENUM(WhatItem); + Q_DECLARE_FLAGS(What, WhatItem); + + enum Mode : uint8_t { + Block = 1, + BlockWeak = 2, + Delay = 3, + }; + Q_ENUM(Mode); + + Q_INVOKABLE static std::string toString(WhatItem what); + Q_INVOKABLE static std::string toString(What what); + Q_INVOKABLE static std::string toString(Mode mode); + + static constexpr WhatItem allWhatItems[] = { Shutdown, Sleep, Idle, HandlePowerKey, HandleSuspendKey, HandleHibernateKey, HandleLidSwitch }; }; +Q_DECLARE_OPERATORS_FOR_FLAGS(SystemdInhibitorParams::What) + +class SystemdInhibitor : public QObject { + Q_OBJECT; + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged); + Q_PROPERTY(SystemdInhibitorParams::What what READ what WRITE setWhat NOTIFY whatChanged); + Q_PROPERTY(QString who READ who WRITE setWho NOTIFY whoChanged); + Q_PROPERTY(QString why READ why WRITE setWhy NOTIFY whyChanged); + Q_PROPERTY(SystemdInhibitorParams::Mode mode READ mode WRITE setMode NOTIFY modeChanged); + QML_ELEMENT; + +public: + explicit SystemdInhibitor(QObject* parent = nullptr): QObject(parent) {} + + bool enabled() const; + void setEnabled(bool enabled); + + SystemdInhibitorParams::What what() const; + void setWhat(SystemdInhibitorParams::What what); + + QString who() const; + void setWho(QString who); + + QString why() const; + void setWhy(QString why); + + SystemdInhibitorParams::Mode mode() const; + void setMode(SystemdInhibitorParams::Mode mode); + + Q_INVOKABLE void release(); + +signals: + void enabledChanged(); + void whatChanged(); + void whoChanged(); + void whyChanged(); + void modeChanged(); + +private: + class ActiveSystemdInhibitor { + public: + uint32_t fd = -1; + SystemdInhibitorParams::What what; + QString who; + QString why; + SystemdInhibitorParams::Mode mode; + + ActiveSystemdInhibitor(SystemdInhibitorParams::What what_, QString who_, QString why_, SystemdInhibitorParams::Mode mode_); + ~ActiveSystemdInhibitor(); + }; + + void update(); + + std::unique_ptr activeInhibitor; + SystemdInhibitorParams::What mWhat = static_cast(0); + QString mWho; + QString mWhy; + SystemdInhibitorParams::Mode mMode = static_cast(0); +}; + diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.DBus.Properties.xml b/accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.DBus.Properties.xml new file mode 100644 index 00000000..7588e7a5 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.DBus.Properties.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.login1.Manager.xml b/accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.login1.Manager.xml new file mode 100644 index 00000000..120a06d9 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.login1.Manager.xml @@ -0,0 +1,445 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.login1.Session.xml b/accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.login1.Session.xml new file mode 100644 index 00000000..7d6fc8ee --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.login1.Session.xml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.systemd1.Manager.xml b/accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.systemd1.Manager.xml new file mode 100644 index 00000000..b4f84a13 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell-plugins/org.freedesktop.systemd1.Manager.xml @@ -0,0 +1,817 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml b/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml index 8e739359..e4f8e1c9 100644 --- a/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml +++ b/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml @@ -38,6 +38,38 @@ Scope { function getLocked(): bool { return lock.locked; } } + Connections { + target: Custom.Systemd + function onSleep(before: bool) { + console.log(`received prepare for sleep ${before}`); + if (before) + lock.locked = true; + } + function onLock() { lock.locked = true; } + function onUnlock() { lock.locked = false; } + } + + IdleMonitor { + id: idleMonitor + enabled: !lock.secure + timeout: 600 + respectInhibitors: true + + onIsIdleChanged: { + if (idleMonitor.isIdle) + lock.locked = true; + } + } + + Custom.SystemdInhibitor { + enabled: !lock.secure + + what: Custom.SystemdInhibitorParams.Sleep + who: "quickshell" + why: "Lock session" + mode: Custom.SystemdInhibitorParams.Delay + } + WlSessionLock { id: lock @@ -56,6 +88,8 @@ Scope { } } + onSecureStateChanged: Custom.Systemd.lockedHint = lock.secure + WlSessionLockSurface { id: lockSurface diff --git a/accounts/gkleen@sif/shell/quickshell/NiriIdle.qml b/accounts/gkleen@sif/shell/quickshell/NiriIdle.qml new file mode 100644 index 00000000..faa77c3f --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/NiriIdle.qml @@ -0,0 +1,30 @@ +import QtQml +import Quickshell +import Quickshell.Wayland +import qs.Services +import Custom as Custom + +Scope { + IdleMonitor { + id: idleMonitor30 + timeout: 30 + + onIsIdleChanged: Custom.Systemd.setIdleHint(idleMonitor30.isIdle) + } + IdleMonitor { + id: idleMonitor540 + timeout: 540 + + onIsIdleChanged: { + if (idleMonitor540.isIdle) + NiriService.sendCommand({ "Action": "PowerOffMonitors" }); + } + } + Connections { + target: Custom.Systemd + function onSleep(before: bool) { + if (!before) + NiriService.sendCommand({ "Action": "PowerOnMonitors" }); + } + } +} diff --git a/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml b/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml index c8c017c3..4cbebcc9 100644 --- a/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml +++ b/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml @@ -48,7 +48,7 @@ Row { cursorShape: Qt.PointingHandCursor enabled: true onClicked: { - NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {}) + NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {}); } Rectangle { diff --git a/accounts/gkleen@sif/shell/quickshell/shell.qml b/accounts/gkleen@sif/shell/quickshell/shell.qml index 0fa45f79..693d741f 100644 --- a/accounts/gkleen@sif/shell/quickshell/shell.qml +++ b/accounts/gkleen@sif/shell/quickshell/shell.qml @@ -41,6 +41,7 @@ ShellRoot { } Lockscreen {} + NiriIdle {} VolumeOSD {} BrightnessOSD {} diff --git a/accounts/gkleen@sif/systemd.nix b/accounts/gkleen@sif/systemd.nix index 4543103f..e601b49c 100644 --- a/accounts/gkleen@sif/systemd.nix +++ b/accounts/gkleen@sif/systemd.nix @@ -205,11 +205,6 @@ in { StartLimitBurst = 7; }; }; - swayidle = { - Service = { - RuntimeDirectory = "swayidle"; - }; - }; psi-notify = { Install = { WantedBy = ["graphical-session.target"]; diff --git a/nvfetcher.toml b/nvfetcher.toml index 72c0d99d..8e3ba905 100644 --- a/nvfetcher.toml +++ b/nvfetcher.toml @@ -123,3 +123,7 @@ fetch.url = "https://github.com/netbootxyz/netboot.xyz/releases/download/$ver/ne [netbootxyz-lkrn] src.github = "netbootxyz/netboot.xyz" fetch.url = "https://github.com/netbootxyz/netboot.xyz/releases/download/$ver/netboot.xyz.lkrn" + +[quickshell] +src.git = "https://git.outfoxxed.me/quickshell/quickshell.git" +fetch.git = "https://git.outfoxxed.me/quickshell/quickshell.git" diff --git a/overlays/quickshell/default.nix b/overlays/quickshell/default.nix index d806753f..c01fac20 100644 --- a/overlays/quickshell/default.nix +++ b/overlays/quickshell/default.nix @@ -1,11 +1,13 @@ -{ final, prev, ... }: +{ final, prev, sources, ... }: { quickshell = prev.quickshell.overrideAttrs (oldAttrs: { + inherit (sources.quickshell) version src; + patches = (oldAttrs.patches or []) ++ [ - ./greetd-response.patch - ./lock-state-changed.patch - ./pipewire.patch - ./io.patch + ./greetd-response.patch + ./lock-state-changed.patch + ./pipewire.patch + ./io.patch ]; }); } -- cgit v1.2.3