feat: add Quickshell.env

This commit is contained in:
outfoxxed 2024-03-03 02:24:33 -08:00
parent 14e1d2d162
commit b5110b759e
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
4 changed files with 15 additions and 2 deletions

2
docs

@ -1 +1 @@
Subproject commit 79579222a31dc1f6355e0c3020917c29165f766c
Subproject commit 8b40a464af5c1338d842e61f8ec517d142454cbc

View file

@ -8,8 +8,10 @@
#include <qqmlcontext.h>
#include <qqmlengine.h>
#include <qqmllist.h>
#include <qtenvironmentvariables.h>
#include <qtmetamacros.h>
#include <qtypes.h>
#include <qvariant.h>
#include "qmlscreen.hpp"
#include "rootwrapper.hpp"
@ -74,3 +76,10 @@ void QuickshellGlobal::updateScreens() {
emit this->screensChanged();
}
QVariant QuickshellGlobal::env(const QString& variable) { // NOLINT
auto vstr = variable.toStdString();
if (!qEnvironmentVariableIsSet(vstr.data())) return QVariant();
return qEnvironmentVariable(vstr.data());
}

View file

@ -6,6 +6,7 @@
#include <qqmllist.h>
#include <qtmetamacros.h>
#include <qtypes.h>
#include <qvariant.h>
#include "qmlscreen.hpp"
@ -50,6 +51,9 @@ public:
/// [Reloadable]: ../reloadable
Q_INVOKABLE void reload(bool hard);
/// Returns the string value of an environment variable or null if it is not set.
Q_INVOKABLE QVariant env(const QString& variable);
signals:
void screensChanged();

View file

@ -8,8 +8,8 @@
#include <qtclasshelpermacros.h>
#include <qtmetamacros.h>
#include "datastream.hpp"
#include "../core/reload.hpp"
#include "datastream.hpp"
///! Unix socket listener.
class Socket: public DataStream {