diff options
Diffstat (limited to 'accounts')
17 files changed, 802 insertions, 239 deletions
diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index f2978b6e..190a5016 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix | |||
@@ -374,7 +374,7 @@ in { | |||
374 | 374 | ||
375 | services = { | 375 | services = { |
376 | wpaperd = { | 376 | wpaperd = { |
377 | enable = true; | 377 | enable = false; |
378 | settings.default = { | 378 | settings.default = { |
379 | path = "~/.wallpapers"; | 379 | path = "~/.wallpapers"; |
380 | duration = "15m"; | 380 | duration = "15m"; |
diff --git a/accounts/gkleen@sif/shell/default.nix b/accounts/gkleen@sif/shell/default.nix index 26c8bd98..84140072 100644 --- a/accounts/gkleen@sif/shell/default.nix +++ b/accounts/gkleen@sif/shell/default.nix | |||
@@ -7,8 +7,75 @@ | |||
7 | config = { | 7 | config = { |
8 | src = ./quickshell; | 8 | src = ./quickshell; |
9 | replacements = { | 9 | replacements = { |
10 | coreutils = toString pkgs.coreutils; | ||
11 | ignore_workspaces = builtins.toJSON (map ({ name, ... }: name) config.programs.niri.scratchspaces); | 10 | ignore_workspaces = builtins.toJSON (map ({ name, ... }: name) config.programs.niri.scratchspaces); |
11 | wallpapers = builtins.toJSON (pkgs.stdenvNoCC.mkDerivation { | ||
12 | name = "wallpapers"; | ||
13 | srcs = [ | ||
14 | (pkgs.fetchurl { | ||
15 | url = "https://esawebb.org/media/archives/images/publicationtiff10k/carinanebula3.tif"; | ||
16 | hash = "sha256-YxZEweDKJfvfrdxb/QFmgJhcZDEJYxotoHrG+RRn1tw="; | ||
17 | }) | ||
18 | (pkgs.fetchurl { | ||
19 | url = "https://esawebb.org/media/archives/images/original/pillarsofcreation_composite.tif"; | ||
20 | hash = "sha256-qRiODxR0lZWdxgYXna0fNRFFDErpBJDwOJuQl6sNjRc="; | ||
21 | }) | ||
22 | (pkgs.fetchurl { | ||
23 | url = "https://esawebb.org/media/archives/images/publicationtiff10k/weic2212a.tif"; | ||
24 | hash = "sha256-l2fqE/z//C1a0xkvZwsnwPbTSb+WuA11h+SUl3E1dhw="; | ||
25 | }) | ||
26 | (pkgs.fetchurl { | ||
27 | url = "https://esawebb.org/media/archives/images/publicationtiff10k/weic2415a.tif"; | ||
28 | hash = "sha256-onBy7cPoUpDuzQStbY2E+qmlGgSLXPwFCLX53ukAb4c="; | ||
29 | }) | ||
30 | (pkgs.fetchurl { | ||
31 | url = "https://esawebb.org/media/archives/images/publicationtiff10k/weic2330a.tif"; | ||
32 | hash = "sha256-nn0ZtjZIrPcpj3YcLTsrL7XiXvyh3QYgCSmdDMD+3OM="; | ||
33 | }) | ||
34 | (pkgs.fetchurl { | ||
35 | url = "https://esawebb.org/media/archives/images/original/weic2426a.tif"; | ||
36 | hash = "sha256-EDnfPn3GE9jt6XPqiGInP7E2F3Az7d25NqATSWltDv0="; | ||
37 | }) | ||
38 | (pkgs.fetchurl { | ||
39 | url = "https://esawebb.org/media/archives/images/original/weic2503a.tif"; | ||
40 | hash = "sha256-3/RX6RQp8naELcgReHPd5/zhJkoCjnA10w5BEnNo+qI="; | ||
41 | }) | ||
42 | (pkgs.fetchurl { | ||
43 | url = "https://esawebb.org/media/archives/images/original/weic2506a.tif"; | ||
44 | hash = "sha256-aDld0aoY1owRxDVf7Jcyw71TH42M1foYotxn2thyFYw="; | ||
45 | }) | ||
46 | (pkgs.fetchurl { | ||
47 | url = "https://esawebb.org/media/archives/images/original/weic2514a.tif"; | ||
48 | hash = "sha256-jTi1G1Ofo5xsF6ggrbtYJHxqLaCQ7edM5B3uORiVQtg="; | ||
49 | }) | ||
50 | (pkgs.fetchurl { | ||
51 | url = "https://esawebb.org/media/archives/images/original/weic2425c.tif"; | ||
52 | hash = "sha256-oaEOexSJHEGj090dJF3ct5HAoR+Y5gRiPrUlxdvnTRo="; | ||
53 | }) | ||
54 | ]; | ||
55 | |||
56 | dontUnpack = true; | ||
57 | |||
58 | buildInputs = [ pkgs.imagemagick ]; | ||
59 | buildPhase = '' | ||
60 | runHook preBuild | ||
61 | |||
62 | typeset sources=($srcs) | ||
63 | |||
64 | mkdir -p $out | ||
65 | magick ''${sources[0]} -crop 10000x5625+0+79 +repage -define jpeg:extent=10MB $out/carinanebula3.jpeg | ||
66 | magick ''${sources[1]} -crop 6716x3778+329+80 +repage -define jpeg:extent=10MB $out/pillarsofcreation_composite.jpeg | ||
67 | magick ''${sources[2]} -crop 10000x5625+0+79 +repage -define jpeg:extent=10MB $out/weic2212a.jpeg | ||
68 | magick ''${sources[3]} -crop 7650x4302+1166+389 +repage -define jpeg:extent=10MB $out/weic2415a.jpeg | ||
69 | magick ''${sources[4]} -crop 8732x4912+0+434 +repage -define jpeg:extent=10MB $out/weic2330a.jpeg | ||
70 | magick ''${sources[5]} -crop 5302x2982+636+0 +repage -define jpeg:extent=10MB $out/weic2426a.jpeg | ||
71 | magick ''${sources[6]} -crop 4328x2434+0+906 +repage -define jpeg:extent=10MB $out/weic2503a.jpeg | ||
72 | magick ''${sources[7]} -crop 4152x2335+0+666 +repage -define jpeg:extent=10MB $out/weic2506a.jpeg | ||
73 | magick ''${sources[8]} -crop 4320x2430+0+0 +repage -define jpeg:extent=10MB $out/weic2514a.jpeg | ||
74 | magick ''${sources[9]} -crop 5863x3298+0+477 +repage -define jpeg:extent=10MB $out/weic2425c.jpeg | ||
75 | |||
76 | runHook postBuild | ||
77 | ''; | ||
78 | }); | ||
12 | }; | 79 | }; |
13 | }; | 80 | }; |
14 | }; | 81 | }; |
diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/CMakeLists.txt b/accounts/gkleen@sif/shell/quickshell-plugins/CMakeLists.txt index aa363c4c..2123ed35 100644 --- a/accounts/gkleen@sif/shell/quickshell-plugins/CMakeLists.txt +++ b/accounts/gkleen@sif/shell/quickshell-plugins/CMakeLists.txt | |||
@@ -104,6 +104,7 @@ qt6_add_qml_module(customplugin | |||
104 | 104 | ||
105 | target_sources(customplugin PRIVATE | 105 | target_sources(customplugin PRIVATE |
106 | Chrono.cpp Chrono.hpp | 106 | Chrono.cpp Chrono.hpp |
107 | FileSelector.cpp FileSelector.hpp | ||
107 | ) | 108 | ) |
108 | 109 | ||
109 | target_compile_features(customplugin PUBLIC cxx_std_26) | 110 | target_compile_features(customplugin PUBLIC cxx_std_26) |
diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.cpp b/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.cpp index 929b7be6..df0c5781 100644 --- a/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.cpp +++ b/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.cpp | |||
@@ -75,14 +75,10 @@ void Chrono::schedule(const std::chrono::time_point<std::chrono::system_clock>& | |||
75 | this->timer.start(delay); | 75 | this->timer.start(delay); |
76 | } | 76 | } |
77 | 77 | ||
78 | QString Chrono::format() const { return this->mFormat; } | 78 | QString Chrono::format(const QString& fmt) const { |
79 | void Chrono::setFormat(QString format) { | 79 | return QString::fromStdString(std::format(std::runtime_format(fmt.toStdString()), std::chrono::zoned_time(std::chrono::current_zone(), std::chrono::time_point_cast<std::chrono::seconds>(this->currentTime)))); |
80 | if (format == this->mFormat) return; | ||
81 | this->mFormat = format; | ||
82 | emit this->formatChanged(); | ||
83 | this->update(); | ||
84 | } | 80 | } |
85 | 81 | ||
86 | QString Chrono::date() const { | 82 | QDateTime Chrono::date() const { |
87 | return QString::fromStdString(std::format(std::runtime_format(this->mFormat.toStdString()), std::chrono::zoned_time(std::chrono::current_zone(), std::chrono::time_point_cast<std::chrono::seconds>(this->currentTime)))); | 83 | return QDateTime::fromStdTimePoint(std::chrono::time_point_cast<std::chrono::milliseconds>(this->currentTime)); |
88 | } | 84 | } |
diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp b/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp index 788fa88e..04080187 100644 --- a/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp +++ b/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp | |||
@@ -1,17 +1,18 @@ | |||
1 | #pragma once | 1 | #pragma once |
2 | 2 | ||
3 | #include <chrono> | ||
4 | |||
5 | #include <QDateTime> | ||
3 | #include <QObject> | 6 | #include <QObject> |
4 | #include <QTimer> | 7 | #include <QTimer> |
5 | 8 | ||
6 | #include <qqmlintegration.h> | 9 | #include <qqmlintegration.h> |
7 | #include <chrono> | ||
8 | 10 | ||
9 | class Chrono : public QObject { | 11 | class Chrono : public QObject { |
10 | Q_OBJECT; | 12 | Q_OBJECT; |
11 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged); | 13 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged); |
12 | Q_PROPERTY(Chrono::Precision precision READ precision WRITE setPrecision NOTIFY precisionChanged); | 14 | Q_PROPERTY(Chrono::Precision precision READ precision WRITE setPrecision NOTIFY precisionChanged); |
13 | Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged); | 15 | Q_PROPERTY(QDateTime date READ date NOTIFY dateChanged) |
14 | Q_PROPERTY(QString date READ date NOTIFY dateChanged); | ||
15 | QML_ELEMENT; | 16 | QML_ELEMENT; |
16 | 17 | ||
17 | public: | 18 | public: |
@@ -30,15 +31,13 @@ public: | |||
30 | Chrono::Precision precision() const; | 31 | Chrono::Precision precision() const; |
31 | void setPrecision(Chrono::Precision precision); | 32 | void setPrecision(Chrono::Precision precision); |
32 | 33 | ||
33 | QString format() const; | 34 | Q_INVOKABLE QString format(const QString& fmt) const; |
34 | void setFormat (QString format); | ||
35 | 35 | ||
36 | QString date() const; | 36 | QDateTime date() const; |
37 | 37 | ||
38 | signals: | 38 | signals: |
39 | void enabledChanged(); | 39 | void enabledChanged(); |
40 | void precisionChanged(); | 40 | void precisionChanged(); |
41 | void formatChanged(); | ||
42 | void dateChanged(); | 41 | void dateChanged(); |
43 | 42 | ||
44 | private slots: | 43 | private slots: |
@@ -47,7 +46,6 @@ private slots: | |||
47 | private: | 46 | private: |
48 | bool mEnabled = true; | 47 | bool mEnabled = true; |
49 | Chrono::Precision mPrecision = Chrono::Seconds; | 48 | Chrono::Precision mPrecision = Chrono::Seconds; |
50 | QString mFormat = "{:%c}"; | ||
51 | QTimer timer; | 49 | QTimer timer; |
52 | std::chrono::time_point<std::chrono::system_clock> currentTime, targetTime; | 50 | std::chrono::time_point<std::chrono::system_clock> currentTime, targetTime; |
53 | 51 | ||
diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/FileSelector.cpp b/accounts/gkleen@sif/shell/quickshell-plugins/FileSelector.cpp new file mode 100644 index 00000000..3a0537b6 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell-plugins/FileSelector.cpp | |||
@@ -0,0 +1,99 @@ | |||
1 | #include "FileSelector.hpp" | ||
2 | |||
3 | #include <sstream> | ||
4 | #include <vector> | ||
5 | #include <random> | ||
6 | #include <algorithm> | ||
7 | |||
8 | #include <iostream> | ||
9 | #include <format> | ||
10 | |||
11 | namespace fs = std::filesystem; | ||
12 | |||
13 | FileSelector::FileSelector(QObject* parent): QObject(parent) { | ||
14 | QObject::connect(&this->timer, &QTimer::timeout, this, &FileSelector::onTimeout); | ||
15 | } | ||
16 | |||
17 | QString FileSelector::directory() const { | ||
18 | return QString::fromStdString(this->mDirectory->string()); | ||
19 | } | ||
20 | void FileSelector::setDirectory(QString directory) { | ||
21 | this->mDirectory = directory.toStdString(); | ||
22 | if (this->mDirectory && this->mEpoch) | ||
23 | this->update(); | ||
24 | emit this->directoryChanged(); | ||
25 | } | ||
26 | |||
27 | unsigned int FileSelector::epoch() const { | ||
28 | return std::chrono::duration_cast<std::chrono::milliseconds>(*this->mEpoch).count(); | ||
29 | } | ||
30 | void FileSelector::setEpoch(unsigned int epoch) { | ||
31 | this->mEpoch = std::chrono::milliseconds{epoch}; | ||
32 | if (this->mDirectory && this->mEpoch) | ||
33 | this->update(); | ||
34 | emit this->epochChanged(); | ||
35 | } | ||
36 | |||
37 | QString FileSelector::seed() const { | ||
38 | return this->mSeed; | ||
39 | } | ||
40 | void FileSelector::setSeed(QString seed) { | ||
41 | this->mSeed = seed; | ||
42 | emit this->seedChanged(); | ||
43 | } | ||
44 | |||
45 | QString FileSelector::selected() const { | ||
46 | if (!this->mDirectory || !this->mEpoch) | ||
47 | return QString(); | ||
48 | |||
49 | std::vector<fs::path> shuffled(this->mFiles.begin(), this->mFiles.end()); | ||
50 | std::sort(shuffled.begin(), shuffled.end()); | ||
51 | |||
52 | auto currentTime = std::chrono::system_clock::now(); | ||
53 | uint64_t currentEpoch = currentTime.time_since_epoch() / *this->mEpoch; | ||
54 | std::chrono::milliseconds timeInEpoch = std::chrono::duration_cast<std::chrono::milliseconds>(currentTime.time_since_epoch()) % *this->mEpoch; | ||
55 | |||
56 | std::ostringstream seed; | ||
57 | seed << this->mSeed.size() << ";" << this->mSeed.toStdString() << ";"; | ||
58 | seed << *this->mEpoch << ";"; | ||
59 | seed << currentEpoch << ";"; | ||
60 | seed << this->mDirectory->string().size() << ";" << *this->mDirectory << ";"; | ||
61 | seed << this->mFiles.size() << ";"; | ||
62 | for (const fs::path& p: this->mFiles) | ||
63 | seed << p.string().size() << ";" << p << ";"; | ||
64 | |||
65 | std::vector<std::seed_seq::result_type> v; | ||
66 | v.reserve(seed.str().size()); | ||
67 | for (const char& c: seed.str()) | ||
68 | v.push_back(c); | ||
69 | |||
70 | std::seed_seq engine_seed(v.begin(), v.end()); | ||
71 | std::mt19937 g(engine_seed); | ||
72 | std::shuffle(shuffled.begin(), shuffled.end(), g); | ||
73 | |||
74 | std::vector<fs::path>::size_type ix = shuffled.size() * timeInEpoch / *this->mEpoch; | ||
75 | return QString::fromStdString((*this->mDirectory / shuffled[ix]).string()); | ||
76 | } | ||
77 | |||
78 | void FileSelector::onTimeout() { | ||
79 | if (!this->mFiles.size()) | ||
80 | return; | ||
81 | |||
82 | auto currentTime = std::chrono::system_clock::now(); | ||
83 | uint64_t currentMinorEpoch = currentTime.time_since_epoch() / (*this->mEpoch / this->mFiles.size()); | ||
84 | auto nextTime = std::chrono::time_point<std::chrono::system_clock>((2 * currentMinorEpoch + 3) * (*this->mEpoch / (this->mFiles.size() * 2))); | ||
85 | this->timer.start(std::chrono::duration_cast<std::chrono::milliseconds>(nextTime - currentTime).count()); | ||
86 | |||
87 | emit this->selectedChanged(); | ||
88 | } | ||
89 | |||
90 | void FileSelector::update() { | ||
91 | this->mFiles = std::set<fs::path>{}; | ||
92 | for (const fs::directory_entry& entry: | ||
93 | fs::recursive_directory_iterator(*this->mDirectory, fs::directory_options::follow_directory_symlink)) | ||
94 | { | ||
95 | this->mFiles.insert(fs::relative(entry, *this->mDirectory)); | ||
96 | } | ||
97 | |||
98 | this->onTimeout(); | ||
99 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/FileSelector.hpp b/accounts/gkleen@sif/shell/quickshell-plugins/FileSelector.hpp new file mode 100644 index 00000000..72c4f2a7 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell-plugins/FileSelector.hpp | |||
@@ -0,0 +1,52 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <filesystem> | ||
4 | #include <chrono> | ||
5 | #include <set> | ||
6 | #include <optional> | ||
7 | |||
8 | #include <QObject> | ||
9 | #include <QTimer> | ||
10 | |||
11 | #include <qqmlintegration.h> | ||
12 | |||
13 | class FileSelector : public QObject { | ||
14 | Q_OBJECT; | ||
15 | Q_PROPERTY(QString directory READ directory WRITE setDirectory NOTIFY directoryChanged REQUIRED); | ||
16 | Q_PROPERTY(unsigned int epoch READ epoch WRITE setEpoch NOTIFY epochChanged REQUIRED); | ||
17 | Q_PROPERTY(QString seed READ seed WRITE setSeed NOTIFY seedChanged); | ||
18 | Q_PROPERTY(QString selected READ selected NOTIFY selectedChanged); | ||
19 | QML_ELEMENT; | ||
20 | |||
21 | public: | ||
22 | explicit FileSelector(QObject* parent = nullptr); | ||
23 | |||
24 | QString directory() const; | ||
25 | void setDirectory(QString directory); | ||
26 | |||
27 | unsigned int epoch() const; | ||
28 | void setEpoch(unsigned int epoch); | ||
29 | |||
30 | QString seed() const; | ||
31 | void setSeed(QString seed); | ||
32 | |||
33 | QString selected() const; | ||
34 | |||
35 | signals: | ||
36 | void directoryChanged(); | ||
37 | void epochChanged(); | ||
38 | void seedChanged(); | ||
39 | void selectedChanged(); | ||
40 | |||
41 | private slots: | ||
42 | void onTimeout(); | ||
43 | |||
44 | private: | ||
45 | std::optional<std::filesystem::path> mDirectory; | ||
46 | std::optional<std::chrono::milliseconds> mEpoch; | ||
47 | std::set<std::filesystem::path> mFiles; | ||
48 | QString mSeed; | ||
49 | QTimer timer; | ||
50 | |||
51 | void update(); | ||
52 | }; | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml b/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml index d7e8e7c5..57ade488 100644 --- a/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml +++ b/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml | |||
@@ -7,10 +7,11 @@ Item { | |||
7 | id: activeWindowDisplay | 7 | id: activeWindowDisplay |
8 | 8 | ||
9 | required property int maxWidth | 9 | required property int maxWidth |
10 | required property var screen | ||
10 | 11 | ||
11 | property var activeWindow: { | 12 | property var activeWindow: { |
12 | let currWindowId = Array.from(NiriService.workspaces).find(ws => { | 13 | let currWindowId = Array.from(NiriService.workspaces).find(ws => { |
13 | return ws.output === bar.screen.name && ws.is_active; | 14 | return ws.output === screen.name && ws.is_active; |
14 | })?.active_window_id; | 15 | })?.active_window_id; |
15 | 16 | ||
16 | return currWindowId ? Array.from(NiriService.windows).find(win => win.id == currWindowId) : null; | 17 | return currWindowId ? Array.from(NiriService.windows).find(win => win.id == currWindowId) : null; |
diff --git a/accounts/gkleen@sif/shell/quickshell/Bar.qml b/accounts/gkleen@sif/shell/quickshell/Bar.qml index accad2a9..aab1607f 100644 --- a/accounts/gkleen@sif/shell/quickshell/Bar.qml +++ b/accounts/gkleen@sif/shell/quickshell/Bar.qml | |||
@@ -5,7 +5,9 @@ import QtQuick | |||
5 | PanelWindow { | 5 | PanelWindow { |
6 | id: bar | 6 | id: bar |
7 | 7 | ||
8 | property var modelData | 8 | required property var screen |
9 | |||
10 | property var calendarMouseArea: clock.calendarMouseArea | ||
9 | 11 | ||
10 | anchors { | 12 | anchors { |
11 | top: true | 13 | top: true |
@@ -17,7 +19,6 @@ PanelWindow { | |||
17 | right: 26 + 8 | 19 | right: 26 + 8 |
18 | } | 20 | } |
19 | 21 | ||
20 | screen: modelData | ||
21 | implicitHeight: 21 | 22 | implicitHeight: 21 |
22 | color: "transparent" | 23 | color: "transparent" |
23 | 24 | ||
@@ -50,6 +51,7 @@ PanelWindow { | |||
50 | spacing: 5 | 51 | spacing: 5 |
51 | 52 | ||
52 | ActiveWindowDisplay { | 53 | ActiveWindowDisplay { |
54 | screen: bar.screen | ||
53 | maxWidth: bar.width - 2*Math.max(left.width, right.width) - 2*8 | 55 | maxWidth: bar.width - 2*Math.max(left.width, right.width) - 2*8 |
54 | } | 56 | } |
55 | } | 57 | } |
@@ -78,6 +80,8 @@ PanelWindow { | |||
78 | width: 4 | 80 | width: 4 |
79 | } | 81 | } |
80 | 82 | ||
81 | Clock {} | 83 | Clock { |
84 | id: clock | ||
85 | } | ||
82 | } | 86 | } |
83 | } \ No newline at end of file | 87 | } \ No newline at end of file |
diff --git a/accounts/gkleen@sif/shell/quickshell/Clock.qml b/accounts/gkleen@sif/shell/quickshell/Clock.qml index 68efb558..edce57e3 100644 --- a/accounts/gkleen@sif/shell/quickshell/Clock.qml +++ b/accounts/gkleen@sif/shell/quickshell/Clock.qml | |||
@@ -7,11 +7,13 @@ import QtQuick.Layouts | |||
7 | import Quickshell.Widgets | 7 | import Quickshell.Widgets |
8 | 8 | ||
9 | Item { | 9 | Item { |
10 | id: clockItem | ||
11 | |||
10 | width: clock.contentWidth | 12 | width: clock.contentWidth |
11 | height: parent.height | 13 | height: parent.height |
12 | anchors.verticalCenter: parent.verticalCenter | 14 | anchors.verticalCenter: parent.verticalCenter |
13 | 15 | ||
14 | MouseArea { | 16 | WrapperMouseArea { |
15 | id: clockMouseArea | 17 | id: clockMouseArea |
16 | 18 | ||
17 | anchors.fill: parent | 19 | anchors.fill: parent |
@@ -21,202 +23,236 @@ Item { | |||
21 | property real angleRem: 0 | 23 | property real angleRem: 0 |
22 | property real sensitivity: 1 / 120 | 24 | property real sensitivity: 1 / 120 |
23 | 25 | ||
24 | onWheel: event => { | 26 | function scrollYear(event) { |
25 | angleRem += event.angleDelta.y; | 27 | angleRem += event.angleDelta.y; |
26 | const d = Math.round(angleRem * sensitivity); | 28 | const d = Math.round(angleRem * sensitivity); |
27 | yearCalendar.year += d; | 29 | yearCalendar.year += d; |
28 | angleRem -= d / sensitivity; | 30 | angleRem -= d / sensitivity; |
29 | } | 31 | } |
30 | } | ||
31 | 32 | ||
32 | Text { | 33 | onWheel: event => scrollYear(event) |
33 | id: clock | ||
34 | color: "white" | ||
35 | 34 | ||
36 | anchors.verticalCenter: parent.verticalCenter | 35 | Item { |
36 | anchors.fill: parent | ||
37 | 37 | ||
38 | Custom.Chrono { | 38 | Text { |
39 | id: chrono | 39 | id: clock |
40 | format: "W{0:%V-%u} {0:%F} {0:%H:%M:%S%Ez}" | 40 | color: "white" |
41 | } | ||
42 | 41 | ||
43 | text: chrono.date | 42 | anchors.verticalCenter: parent.verticalCenter |
43 | |||
44 | Custom.Chrono { | ||
45 | id: chrono | ||
46 | |||
47 | onDateChanged: clock.text = format("W{0:%V-%u} {0:%F} {0:%H:%M:%S%Ez}") | ||
48 | } | ||
44 | 49 | ||
45 | font.pointSize: 10 | 50 | font.pointSize: 10 |
46 | font.family: "Fira Sans" | 51 | font.family: "Fira Sans" |
47 | font.features: { "tnum": 1 } | 52 | font.features: { "tnum": 1 } |
53 | } | ||
54 | } | ||
48 | } | 55 | } |
49 | 56 | ||
50 | PopupWindow { | 57 | PopupWindow { |
58 | id: tooltip | ||
59 | |||
60 | property bool nextVisible: clockMouseArea.containsMouse || tooltipMouseArea.containsMouse | ||
61 | |||
51 | anchor { | 62 | anchor { |
52 | item: clockMouseArea | 63 | item: clockMouseArea |
53 | edges: Edges.Bottom | 64 | edges: Edges.Bottom | Edges.Left |
65 | } | ||
66 | visible: false | ||
67 | |||
68 | onNextVisibleChanged: hangTimer.restart() | ||
69 | |||
70 | Timer { | ||
71 | id: hangTimer | ||
72 | interval: 100 | ||
73 | onTriggered: tooltip.visible = tooltip.nextVisible | ||
54 | } | 74 | } |
55 | visible: clockMouseArea.containsMouse | ||
56 | 75 | ||
57 | implicitWidth: clockTooltipContent.width | 76 | implicitWidth: clockTooltipContent.width |
58 | implicitHeight: clockTooltipContent.height | 77 | implicitHeight: clockTooltipContent.height |
59 | color: "black" | 78 | color: "black" |
60 | 79 | ||
61 | onVisibleChanged: { | 80 | onVisibleChanged: { |
62 | const d = new Date(); | 81 | yearCalendar.year = chrono.date.getFullYear(); |
63 | yearCalendar.year = d.getFullYear(); | ||
64 | clockMouseArea.angleRem = 0; | 82 | clockMouseArea.angleRem = 0; |
65 | } | 83 | } |
66 | 84 | ||
67 | WrapperItem { | 85 | WrapperMouseArea { |
68 | id: clockTooltipContent | 86 | id: tooltipMouseArea |
69 | |||
70 | margin: 8 | ||
71 | leftMargin: 0 | ||
72 | 87 | ||
73 | ColumnLayout { | 88 | hoverEnabled: true |
74 | Text { | 89 | enabled: true |
75 | id: yearLabel | ||
76 | 90 | ||
77 | horizontalAlignment: Text.AlignHCenter | 91 | onWheel: event => clockMouseArea.scrollYear(event) |
78 | 92 | ||
79 | font.pointSize: 14 | 93 | anchors.fill: parent |
80 | font.family: "Fira Sans" | ||
81 | font.features: { "tnum": 1 } | ||
82 | color: "white" | ||
83 | 94 | ||
84 | text: yearCalendar.year | 95 | WrapperItem { |
96 | id: clockTooltipContent | ||
85 | 97 | ||
86 | Layout.fillWidth: true | 98 | margin: 8 |
87 | Layout.bottomMargin: 8 | 99 | leftMargin: 0 |
88 | } | ||
89 | 100 | ||
90 | GridLayout { | 101 | ColumnLayout { |
91 | property int year: { const d = new Date(); return d.getFullYear(); } | 102 | Text { |
103 | id: yearLabel | ||
92 | 104 | ||
93 | id: yearCalendar | 105 | horizontalAlignment: Text.AlignHCenter |
94 | 106 | ||
95 | columns: 3 | 107 | font.pointSize: 14 |
96 | columnSpacing: 16 | 108 | font.family: "Fira Sans" |
97 | rowSpacing: 16 | 109 | font.features: { "tnum": 1 } |
110 | color: "white" | ||
98 | 111 | ||
99 | Layout.alignment: Qt.AlignHCenter | 112 | text: yearCalendar.year |
100 | Layout.fillWidth: false | ||
101 | 113 | ||
102 | Repeater { | 114 | Layout.fillWidth: true |
103 | model: 12 | 115 | Layout.bottomMargin: 8 |
116 | } | ||
104 | 117 | ||
105 | GridLayout { | 118 | GridLayout { |
106 | columns: 2 | 119 | property int year: chrono.date.getFullYear() |
107 | 120 | ||
108 | required property int index | 121 | id: yearCalendar |
109 | property int month: index | ||
110 | 122 | ||
111 | id: monthCalendar | 123 | columns: 3 |
124 | columnSpacing: 16 | ||
125 | rowSpacing: 16 | ||
112 | 126 | ||
113 | Layout.alignment: Qt.AlignTop | Qt.AlignRight | 127 | Layout.alignment: Qt.AlignHCenter |
114 | Layout.fillWidth: false | 128 | Layout.fillWidth: false |
115 | 129 | ||
116 | Text { | 130 | Repeater { |
117 | Layout.column: 1 | 131 | model: 12 |
118 | Layout.fillWidth: true | ||
119 | 132 | ||
120 | horizontalAlignment: Text.AlignHCenter | 133 | GridLayout { |
134 | columns: 2 | ||
121 | 135 | ||
122 | font.pointSize: 10 | 136 | required property int index |
123 | font.family: "Fira Sans" | 137 | property int month: index |
124 | 138 | ||
125 | text: { | 139 | id: monthCalendar |
126 | const date = Date.fromLocaleDateString(Qt.locale(), `${yearCalendar.year}-${monthCalendar.month + 1}-01`, "yyyy-M-dd"); | ||
127 | return date.toLocaleString(Qt.locale("en_DK"), "MMMM") | ||
128 | } | ||
129 | 140 | ||
130 | color: "#ffead3" | 141 | Layout.alignment: Qt.AlignTop | Qt.AlignRight |
131 | } | 142 | Layout.fillWidth: false |
132 | 143 | ||
133 | DayOfWeekRow { | 144 | Text { |
134 | locale: grid.locale | 145 | Layout.column: 1 |
146 | Layout.fillWidth: true | ||
135 | 147 | ||
136 | Layout.row: 1 | 148 | horizontalAlignment: Text.AlignHCenter |
137 | Layout.column: 1 | ||
138 | Layout.fillWidth: true | ||
139 | |||
140 | delegate: Text { | ||
141 | required property string shortName | ||
142 | 149 | ||
143 | font.pointSize: 10 | 150 | font.pointSize: 10 |
144 | font.family: "Fira Mono" | 151 | font.family: "Fira Sans" |
145 | 152 | ||
146 | text: shortName | 153 | text: new Date(yearCalendar.year, monthCalendar.month, 1).toLocaleString(Qt.locale("en_DK"), "MMMM") |
147 | color: "#ffcc66" | ||
148 | 154 | ||
149 | horizontalAlignment: Text.AlignRight | 155 | color: "#ffead3" |
150 | verticalAlignment: Text.AlignVCenter | ||
151 | } | 156 | } |
152 | } | ||
153 | 157 | ||
154 | WeekNumberColumn { | 158 | DayOfWeekRow { |
155 | month: grid.month | 159 | locale: grid.locale |
156 | year: grid.year | ||
157 | locale: grid.locale | ||
158 | 160 | ||
159 | Layout.fillHeight: true | 161 | Layout.row: 1 |
162 | Layout.column: 1 | ||
163 | Layout.fillWidth: true | ||
160 | 164 | ||
161 | delegate: Text { | 165 | delegate: WrapperItem { |
162 | required property int weekNumber | 166 | required property string shortName |
163 | 167 | ||
164 | opacity: { | 168 | width: dowLabel.contentWidth + 6 |
165 | const simple = new Date(weekNumber == 1 && monthCalendar.month == 12 ? yearCalendar.year + 1 : yearCalendar.year, 0, 1 + (weekNumber - 1) * 7); | ||
166 | const dayOfWeek = simple.getDay(); | ||
167 | const isoWeekStart = simple; | ||
168 | 169 | ||
169 | isoWeekStart.setDate(simple.getDate() - dayOfWeek + 1); | 170 | Text { |
170 | if (dayOfWeek > 4) { | 171 | id: dowLabel |
171 | isoWeekStart.setDate(isoWeekStart.getDate() + 7); | ||
172 | } | ||
173 | 172 | ||
174 | for (let i = 0; i < 7; i++) { | 173 | anchors.fill: parent |
175 | const dayInWeek = new Date(isoWeekStart); | ||
176 | dayInWeek.setDate(dayInWeek.getDate() + i); | ||
177 | if (dayInWeek.getMonth() == monthCalendar.month) | ||
178 | return 1; | ||
179 | } | ||
180 | 174 | ||
181 | return 0; | 175 | font.pointSize: 10 |
182 | } | 176 | font.family: "Fira Sans" |
183 | |||
184 | font.pointSize: 10 | ||
185 | font.family: "Fira Sans" | ||
186 | font.features: { "tnum": 1 } | ||
187 | 177 | ||
188 | text: weekNumber | 178 | text: parent.shortName |
189 | color: "#99ffdd" | 179 | color: "#ffcc66" |
190 | 180 | ||
191 | horizontalAlignment: Text.AlignRight | 181 | horizontalAlignment: Text.AlignHCenter |
192 | verticalAlignment: Text.AlignVCenter | 182 | verticalAlignment: Text.AlignVCenter |
183 | } | ||
184 | } | ||
193 | } | 185 | } |
194 | } | ||
195 | 186 | ||
196 | MonthGrid { | 187 | WeekNumberColumn { |
197 | id: grid | 188 | month: grid.month |
189 | year: grid.year | ||
190 | locale: grid.locale | ||
191 | |||
192 | Layout.fillHeight: true | ||
198 | 193 | ||
199 | year: yearCalendar.year | 194 | delegate: Text { |
200 | month: monthCalendar.month | 195 | required property int weekNumber |
201 | locale: Qt.locale("en_DK") | ||
202 | 196 | ||
203 | Layout.fillWidth: true | 197 | opacity: { |
204 | Layout.fillHeight: true | 198 | const simple = new Date(weekNumber == 1 && monthCalendar.month == 12 ? yearCalendar.year + 1 : yearCalendar.year, 0, 1 + (weekNumber - 1) * 7); |
199 | const dayOfWeek = simple.getDay(); | ||
200 | const isoWeekStart = simple; | ||
205 | 201 | ||
206 | delegate: Text { | 202 | isoWeekStart.setDate(simple.getDate() - dayOfWeek + 1); |
207 | required property var model | 203 | if (dayOfWeek > 4) { |
204 | isoWeekStart.setDate(isoWeekStart.getDate() + 7); | ||
205 | } | ||
208 | 206 | ||
209 | opacity: model.month === monthCalendar.month ? 1 : 0 | 207 | for (let i = 0; i < 7; i++) { |
208 | const dayInWeek = new Date(isoWeekStart); | ||
209 | dayInWeek.setDate(dayInWeek.getDate() + i); | ||
210 | if (dayInWeek.getMonth() == monthCalendar.month) | ||
211 | return 1; | ||
212 | } | ||
213 | |||
214 | return 0; | ||
215 | } | ||
210 | 216 | ||
211 | font.pointSize: 10 | 217 | font.pointSize: 10 |
212 | font.family: "Fira Sans" | 218 | font.family: "Fira Sans" |
213 | font.features: { "tnum": 1 } | 219 | font.features: { "tnum": 1 } |
214 | 220 | ||
215 | text: model.day | 221 | text: weekNumber |
216 | color: model.today ? "#ff6699" : "white" | 222 | color: "#99ffdd" |
217 | 223 | ||
218 | horizontalAlignment: Text.AlignRight | 224 | horizontalAlignment: Text.AlignRight |
219 | verticalAlignment: Text.AlignVCenter | 225 | verticalAlignment: Text.AlignVCenter |
226 | } | ||
227 | } | ||
228 | |||
229 | MonthGrid { | ||
230 | id: grid | ||
231 | |||
232 | year: yearCalendar.year | ||
233 | month: monthCalendar.month | ||
234 | locale: Qt.locale("en_DK") | ||
235 | |||
236 | Layout.fillWidth: true | ||
237 | Layout.fillHeight: true | ||
238 | |||
239 | delegate: Text { | ||
240 | required property var model | ||
241 | |||
242 | opacity: model.month === monthCalendar.month ? 1 : 0 | ||
243 | |||
244 | font.pointSize: 10 | ||
245 | font.family: "Fira Sans" | ||
246 | font.features: { "tnum": 1 } | ||
247 | |||
248 | property bool today: chrono.date.getFullYear() == model.year && chrono.date.getMonth() == model.month && chrono.date.getDate() == model.day | ||
249 | |||
250 | text: model.day | ||
251 | color: today ? "#ff6699" : "white" | ||
252 | |||
253 | horizontalAlignment: Text.AlignRight | ||
254 | verticalAlignment: Text.AlignVCenter | ||
255 | } | ||
220 | } | 256 | } |
221 | } | 257 | } |
222 | } | 258 | } |
@@ -225,4 +261,4 @@ Item { | |||
225 | } | 261 | } |
226 | } | 262 | } |
227 | } | 263 | } |
228 | } \ No newline at end of file | 264 | } |
diff --git a/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml b/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml index 710ea10c..bc3750f9 100644 --- a/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml +++ b/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml | |||
@@ -1,77 +1,105 @@ | |||
1 | import Quickshell | 1 | import Quickshell |
2 | import QtQuick | 2 | import QtQuick |
3 | import qs.Services | 3 | import qs.Services |
4 | import Quickshell.Widgets | ||
4 | 5 | ||
5 | Rectangle { | 6 | Item { |
6 | id: kbdWidget | ||
7 | |||
8 | property var keyboardAbbrev: { "English (programmer Dvorak)": "dvp", "English (US)": "us" } | ||
9 | |||
10 | width: kbdLabel.contentWidth + 8 | 7 | width: kbdLabel.contentWidth + 8 |
11 | color: { | ||
12 | if (kbdMouseArea.containsMouse) { | ||
13 | return "#33808080"; | ||
14 | } | ||
15 | return "transparent"; | ||
16 | } | ||
17 | height: parent.height | 8 | height: parent.height |
18 | anchors.verticalCenter: parent.verticalCenter | 9 | anchors.verticalCenter: parent.verticalCenter |
19 | 10 | ||
20 | MouseArea { | 11 | WrapperMouseArea { |
21 | id: kbdMouseArea | 12 | id: kbdMouseArea |
22 | 13 | ||
23 | anchors.fill: parent | 14 | anchors.fill: parent |
15 | |||
24 | hoverEnabled: true | 16 | hoverEnabled: true |
25 | cursorShape: Qt.PointingHandCursor | 17 | cursorShape: Qt.PointingHandCursor |
26 | enabled: true | 18 | enabled: true |
27 | onClicked: { | 19 | onClicked: { |
28 | NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": "Next" } } }, _ => {}) | 20 | NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": "Next" } } }, _ => {}) |
29 | } | 21 | } |
30 | } | 22 | onWheel: event => { |
23 | NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": event.angleDelta > 0 ? "Next" : "Prev" } } }, _ => {}) | ||
24 | } | ||
31 | 25 | ||
32 | Text { | 26 | Rectangle { |
33 | id: kbdLabel | 27 | id: kbdWidget |
34 | 28 | ||
35 | font.pointSize: 10 | 29 | property var keyboardAbbrev: { "English (programmer Dvorak)": "dvp", "English (US)": "us" } |
36 | font.family: "Fira Sans" | 30 | |
37 | color: { | 31 | anchors.fill: parent |
38 | if (NiriService.keyboardLayouts?.current_idx === 0) | 32 | color: { |
39 | return "#555"; | 33 | if (kbdMouseArea.containsMouse) { |
40 | return "white"; | 34 | return "#33808080"; |
41 | } | 35 | } |
42 | anchors.centerIn: parent | 36 | return "transparent"; |
37 | } | ||
43 | 38 | ||
44 | text: { | 39 | Text { |
45 | const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; | 40 | id: kbdLabel |
46 | if (!currentLayout) | 41 | |
47 | return ""; | 42 | font.pointSize: 10 |
48 | return kbdWidget.keyboardAbbrev[currentLayout] ? kbdWidget.keyboardAbbrev[currentLayout] : currentLayout; | 43 | font.family: "Fira Sans" |
44 | color: { | ||
45 | if (NiriService.keyboardLayouts?.current_idx === 0) | ||
46 | return "#555"; | ||
47 | return "white"; | ||
48 | } | ||
49 | anchors.centerIn: parent | ||
50 | |||
51 | text: { | ||
52 | const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; | ||
53 | if (!currentLayout) | ||
54 | return ""; | ||
55 | return kbdWidget.keyboardAbbrev[currentLayout] ? kbdWidget.keyboardAbbrev[currentLayout] : currentLayout; | ||
56 | } | ||
57 | } | ||
49 | } | 58 | } |
50 | } | 59 | } |
51 | 60 | ||
52 | PopupWindow { | 61 | PopupWindow { |
62 | id: tooltip | ||
63 | |||
64 | property bool nextVisible: kbdMouseArea.containsMouse || tooltipMouseArea.containsMouse | ||
65 | |||
53 | anchor { | 66 | anchor { |
54 | item: kbdMouseArea | 67 | item: kbdMouseArea |
55 | edges: Edges.Bottom | 68 | edges: Edges.Bottom | Edges.Left |
69 | } | ||
70 | visible: false | ||
71 | |||
72 | onNextVisibleChanged: hangTimer.restart() | ||
73 | |||
74 | Timer { | ||
75 | id: hangTimer | ||
76 | interval: 100 | ||
77 | onTriggered: tooltip.visible = tooltip.nextVisible | ||
56 | } | 78 | } |
57 | visible: kbdMouseArea.containsMouse | ||
58 | 79 | ||
59 | implicitWidth: kbdTooltipText.contentWidth + 16 | 80 | implicitWidth: kbdTooltipText.contentWidth + 16 |
60 | implicitHeight: kbdTooltipText.contentHeight + 16 | 81 | implicitHeight: kbdTooltipText.contentHeight + 16 |
61 | color: "black" | 82 | color: "black" |
62 | 83 | ||
63 | Text { | 84 | WrapperMouseArea { |
64 | id: kbdTooltipText | 85 | id: tooltipMouseArea |
86 | |||
87 | hoverEnabled: true | ||
88 | enabled: true | ||
65 | 89 | ||
66 | anchors.centerIn: parent | 90 | anchors.centerIn: parent |
67 | 91 | ||
68 | font.pointSize: 10 | 92 | Text { |
69 | font.family: "Fira Sans" | 93 | id: kbdTooltipText |
70 | color: "white" | 94 | |
95 | font.pointSize: 10 | ||
96 | font.family: "Fira Sans" | ||
97 | color: "white" | ||
71 | 98 | ||
72 | text: { | 99 | text: { |
73 | const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; | 100 | const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; |
74 | return currentLayout || ""; | 101 | return currentLayout || ""; |
102 | } | ||
75 | } | 103 | } |
76 | } | 104 | } |
77 | } | 105 | } |
diff --git a/accounts/gkleen@sif/shell/quickshell/Services/NiriService.qml b/accounts/gkleen@sif/shell/quickshell/Services/NiriService.qml index c82caaa6..af522ec4 100644 --- a/accounts/gkleen@sif/shell/quickshell/Services/NiriService.qml +++ b/accounts/gkleen@sif/shell/quickshell/Services/NiriService.qml | |||
@@ -28,9 +28,12 @@ Singleton { | |||
28 | path: root.socketPath | 28 | path: root.socketPath |
29 | connected: true | 29 | connected: true |
30 | 30 | ||
31 | property bool acked: false | ||
32 | |||
31 | onConnectionStateChanged: { | 33 | onConnectionStateChanged: { |
32 | if (connected) { | 34 | if (connected) { |
33 | write('"EventStream"\n') | 35 | acked = false; |
36 | write('"EventStream"\n'); | ||
34 | } | 37 | } |
35 | } | 38 | } |
36 | 39 | ||
@@ -66,6 +69,9 @@ Singleton { | |||
66 | eventWindowUrgencyChanged(event.WindowUrgencyChanged); | 69 | eventWindowUrgencyChanged(event.WindowUrgencyChanged); |
67 | else if (event.WindowLayoutsChanged) | 70 | else if (event.WindowLayoutsChanged) |
68 | eventWindowLayoutsChanged(event.WindowLayoutsChanged); | 71 | eventWindowLayoutsChanged(event.WindowLayoutsChanged); |
72 | else if (event.Ok && !eventStreamSocket.acked) { eventStreamSocket.acked = true; } | ||
73 | else if (event.OverviewOpenedOrClosed) {} | ||
74 | else if (event.ConfigLoaded) {} | ||
69 | else | 75 | else |
70 | console.log(JSON.stringify(event)); | 76 | console.log(JSON.stringify(event)); |
71 | } catch (e) { | 77 | } catch (e) { |
@@ -154,7 +160,11 @@ Singleton { | |||
154 | }); | 160 | }); |
155 | } | 161 | } |
156 | function eventWindowOpenedOrChanged(data) { | 162 | function eventWindowOpenedOrChanged(data) { |
157 | root.windows = Array.from(root.windows).filter(win => win.id !== data.window.id).concat([data.window]); | 163 | root.windows = Array.from(root.windows).map(win => { |
164 | if (data.window.is_focused) | ||
165 | win.is_focused = false; | ||
166 | return win; | ||
167 | }).filter(win => win.id !== data.window.id).concat([data.window]); | ||
158 | } | 168 | } |
159 | function eventWindowClosed(data) { | 169 | function eventWindowClosed(data) { |
160 | root.windows = Array.from(root.windows).filter(win => win.id !== data.id); | 170 | root.windows = Array.from(root.windows).filter(win => win.id !== data.id); |
diff --git a/accounts/gkleen@sif/shell/quickshell/Services/WallpaperSelector.qml b/accounts/gkleen@sif/shell/quickshell/Services/WallpaperSelector.qml new file mode 100644 index 00000000..3c524955 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Services/WallpaperSelector.qml | |||
@@ -0,0 +1,8 @@ | |||
1 | import Custom as Custom | ||
2 | |||
3 | Custom.FileSelector { | ||
4 | id: root | ||
5 | |||
6 | directory: @wallpapers@ | ||
7 | epoch: 72000000 | ||
8 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/SystemTray.qml b/accounts/gkleen@sif/shell/quickshell/SystemTray.qml index afed4bf0..55b1690e 100644 --- a/accounts/gkleen@sif/shell/quickshell/SystemTray.qml +++ b/accounts/gkleen@sif/shell/quickshell/SystemTray.qml | |||
@@ -17,13 +17,17 @@ Item { | |||
17 | spacing: 0 | 17 | spacing: 0 |
18 | 18 | ||
19 | Repeater { | 19 | Repeater { |
20 | model: { | 20 | model: ScriptModel { |
21 | var trayItems = Array.from(SystemTray.items.values).filter(item => item.status !== Status.Passive); | 21 | values: { |
22 | trayItems.sort((a, b) => a.category !== b.category ? b.category - a.category : a.id.localeCompare(b.id)) | 22 | var trayItems = Array.from(SystemTray.items.values).filter(item => item.status !== Status.Passive); |
23 | return trayItems; | 23 | trayItems.sort((a, b) => a.category !== b.category ? b.category - a.category : a.id.localeCompare(b.id)) |
24 | return trayItems; | ||
25 | } | ||
24 | } | 26 | } |
25 | 27 | ||
26 | delegate: Item { | 28 | delegate: Item { |
29 | id: trayItemWrapper | ||
30 | |||
27 | property var trayItem: modelData | 31 | property var trayItem: modelData |
28 | property string iconSource: { | 32 | property string iconSource: { |
29 | let icon = trayItem && trayItem.icon | 33 | let icon = trayItem && trayItem.icon |
@@ -47,17 +51,7 @@ Item { | |||
47 | height: parent.height | 51 | height: parent.height |
48 | anchors.verticalCenter: parent.verticalCenter | 52 | anchors.verticalCenter: parent.verticalCenter |
49 | 53 | ||
50 | IconImage { | 54 | WrapperMouseArea { |
51 | anchors.centerIn: parent | ||
52 | width: parent.width | ||
53 | height: parent.width | ||
54 | source: parent.iconSource | ||
55 | asynchronous: true | ||
56 | smooth: true | ||
57 | mipmap: true | ||
58 | } | ||
59 | |||
60 | MouseArea { | ||
61 | id: trayItemArea | 55 | id: trayItemArea |
62 | 56 | ||
63 | anchors.fill: parent | 57 | anchors.fill: parent |
@@ -88,21 +82,48 @@ Item { | |||
88 | menuAnchor.open() | 82 | menuAnchor.open() |
89 | } | 83 | } |
90 | } | 84 | } |
85 | |||
86 | IconImage { | ||
87 | anchors.centerIn: parent | ||
88 | width: parent.width | ||
89 | height: parent.width | ||
90 | source: trayItemWrapper.iconSource | ||
91 | asynchronous: true | ||
92 | smooth: true | ||
93 | mipmap: true | ||
94 | } | ||
91 | } | 95 | } |
92 | 96 | ||
93 | PopupWindow { | 97 | PopupWindow { |
98 | id: tooltip | ||
99 | |||
100 | property bool nextVisible: (trayItem.tooltipTitle || trayItem.tooltipDescription) && (trayItemArea.containsMouse || tooltipMouseArea.containsMouse) && !menuAnchor.visible | ||
101 | |||
94 | anchor { | 102 | anchor { |
95 | item: trayItemArea | 103 | item: trayItemArea |
96 | edges: Edges.Bottom | 104 | edges: Edges.Bottom |
97 | } | 105 | } |
98 | visible: (trayItem.tooltipTitle || trayItem.tooltipDescription) && trayItemArea.containsMouse && !menuAnchor.visible | 106 | |
107 | visible: false | ||
108 | onNextVisibleChanged: hangTimer.restart() | ||
109 | |||
110 | Timer { | ||
111 | id: hangTimer | ||
112 | interval: 100 | ||
113 | onTriggered: tooltip.visible = tooltip.nextVisible | ||
114 | } | ||
99 | 115 | ||
100 | color: "black" | 116 | color: "black" |
101 | 117 | ||
102 | implicitWidth: Math.max(tooltipTitle.contentWidth, tooltipDescription.contentWidth) + 16 | 118 | implicitWidth: Math.max(tooltipTitle.contentWidth, tooltipDescription.contentWidth) + 16 |
103 | implicitHeight: tooltipTitle.contentHeight + tooltipDescription.contentHeight + 16 | 119 | implicitHeight: tooltipTitle.contentHeight + tooltipDescription.contentHeight + 16 |
104 | 120 | ||
105 | WrapperItem { | 121 | WrapperMouseArea { |
122 | id: tooltipMouseArea | ||
123 | |||
124 | hoverEnabled: true | ||
125 | enabled: true | ||
126 | |||
106 | margin: 8 | 127 | margin: 8 |
107 | 128 | ||
108 | Column { | 129 | Column { |
diff --git a/accounts/gkleen@sif/shell/quickshell/WallpaperBackground.qml b/accounts/gkleen@sif/shell/quickshell/WallpaperBackground.qml new file mode 100644 index 00000000..de31915f --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/WallpaperBackground.qml | |||
@@ -0,0 +1,85 @@ | |||
1 | import QtQuick | ||
2 | import Quickshell | ||
3 | import qs.Services | ||
4 | |||
5 | Item { | ||
6 | id: root | ||
7 | |||
8 | anchors.fill: parent | ||
9 | |||
10 | required property string screen | ||
11 | |||
12 | property Img current: one | ||
13 | property string source: selector.selected | ||
14 | |||
15 | WallpaperSelector { | ||
16 | id: selector | ||
17 | seed: screen | ||
18 | } | ||
19 | |||
20 | onSourceChanged: { | ||
21 | if (!source) | ||
22 | current = null; | ||
23 | else if (current === one) | ||
24 | two.update() | ||
25 | else | ||
26 | one.update() | ||
27 | } | ||
28 | |||
29 | Img { id: one } | ||
30 | Img { id: two } | ||
31 | |||
32 | component Img: Image { | ||
33 | id: img | ||
34 | |||
35 | function update() { | ||
36 | source = root.source || "" | ||
37 | } | ||
38 | |||
39 | anchors.fill: parent | ||
40 | fillMode: Image.PreserveAspectCrop | ||
41 | smooth: true | ||
42 | asynchronous: true | ||
43 | cache: false | ||
44 | |||
45 | opacity: 0 | ||
46 | |||
47 | onStatusChanged: { | ||
48 | if (status === Image.Ready) { | ||
49 | root.current = this | ||
50 | } | ||
51 | } | ||
52 | |||
53 | states: State { | ||
54 | name: "visible" | ||
55 | when: root.current === img | ||
56 | |||
57 | PropertyChanges { | ||
58 | img.opacity: 1 | ||
59 | } | ||
60 | StateChangeScript { | ||
61 | name: "unloadOther" | ||
62 | script: { | ||
63 | if (img === one) | ||
64 | two.source = "" | ||
65 | if (img === two) | ||
66 | one.source = "" | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | |||
71 | transitions: Transition { | ||
72 | SequentialAnimation { | ||
73 | NumberAnimation { | ||
74 | target: img | ||
75 | properties: "opacity" | ||
76 | duration: 5000 | ||
77 | easing.type: Easing.OutCubic | ||
78 | } | ||
79 | ScriptAction { | ||
80 | scriptName: "unloadOther" | ||
81 | } | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml b/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml index 153c56bb..c8c017c3 100644 --- a/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml +++ b/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml | |||
@@ -1,5 +1,8 @@ | |||
1 | import Quickshell | ||
1 | import QtQuick | 2 | import QtQuick |
2 | import qs.Services | 3 | import qs.Services |
4 | import Quickshell.Widgets | ||
5 | import QtQuick.Layouts | ||
3 | 6 | ||
4 | Row { | 7 | Row { |
5 | id: workspaces | 8 | id: workspaces |
@@ -11,61 +14,188 @@ Row { | |||
11 | spacing: 0 | 14 | spacing: 0 |
12 | 15 | ||
13 | Repeater { | 16 | Repeater { |
14 | model: { | 17 | model: ScriptModel { |
15 | let currWorkspaces = NiriService.workspaces; | 18 | values: { |
16 | const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces); | 19 | let currWorkspaces = NiriService.workspaces; |
17 | currWorkspaces = currWorkspaces.filter(ws => ws.is_active || ignoreWorkspaces.every(iws => iws !== ws.name)); | 20 | const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces); |
18 | currWorkspaces.sort((a, b) => { | 21 | currWorkspaces = currWorkspaces.filter(ws => ws.is_active || ignoreWorkspaces.every(iws => iws !== ws.name)); |
19 | if (NiriService.outputs?.[a.output]?.logical?.x !== NiriService.outputs?.[b.output]?.logical?.x) | 22 | currWorkspaces.sort((a, b) => { |
20 | return NiriService.outputs?.[a.output]?.logical?.x - NiriService.outputs?.[b.output]?.logical?.x | 23 | if (NiriService.outputs?.[a.output]?.logical?.x !== NiriService.outputs?.[b.output]?.logical?.x) |
21 | if (NiriService.outputs?.[a.output]?.logical?.y !== NiriService.outputs?.[b.output]?.logical?.y) | 24 | return NiriService.outputs?.[a.output]?.logical?.x - NiriService.outputs?.[b.output]?.logical?.x |
22 | return NiriService.outputs?.[a.output]?.logical?.y - NiriService.outputs?.[b.output]?.logical?.y | 25 | if (NiriService.outputs?.[a.output]?.logical?.y !== NiriService.outputs?.[b.output]?.logical?.y) |
23 | return a.idx - b.idx; | 26 | return NiriService.outputs?.[a.output]?.logical?.y - NiriService.outputs?.[b.output]?.logical?.y |
24 | }); | 27 | return a.idx - b.idx; |
25 | return currWorkspaces; | 28 | }); |
29 | return currWorkspaces; | ||
30 | } | ||
26 | } | 31 | } |
27 | 32 | ||
28 | Rectangle { | 33 | Item { |
34 | id: wsItem | ||
35 | |||
29 | property var workspaceData: modelData | 36 | property var workspaceData: modelData |
30 | 37 | ||
31 | width: wsLabel.contentWidth + 8 | 38 | width: wsLabel.contentWidth + 8 |
32 | color: { | ||
33 | if (mouseArea.containsMouse) { | ||
34 | return "#33808080"; | ||
35 | } | ||
36 | return "transparent"; | ||
37 | } | ||
38 | height: parent.height | 39 | height: parent.height |
39 | anchors.verticalCenter: parent.verticalCenter | 40 | anchors.verticalCenter: parent.verticalCenter |
40 | 41 | ||
41 | MouseArea { | 42 | WrapperMouseArea { |
42 | id: mouseArea | 43 | id: mouseArea |
43 | 44 | ||
44 | anchors.fill: parent | 45 | anchors.fill: parent |
46 | |||
45 | hoverEnabled: true | 47 | hoverEnabled: true |
46 | cursorShape: Qt.PointingHandCursor | 48 | cursorShape: Qt.PointingHandCursor |
47 | enabled: true | 49 | enabled: true |
48 | onClicked: { | 50 | onClicked: { |
49 | NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {}) | 51 | NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {}) |
50 | } | 52 | } |
53 | |||
54 | Rectangle { | ||
55 | anchors.fill: parent | ||
56 | |||
57 | color: { | ||
58 | if (mouseArea.containsMouse) { | ||
59 | return "#33808080"; | ||
60 | } | ||
61 | return "transparent"; | ||
62 | } | ||
63 | |||
64 | Text { | ||
65 | id: wsLabel | ||
66 | |||
67 | anchors.centerIn: parent | ||
68 | |||
69 | font.pointSize: 10 | ||
70 | font.family: "Fira Sans" | ||
71 | color: { | ||
72 | if (workspaceData.is_active) | ||
73 | return "#23fd00"; | ||
74 | if (workspaceData.active_window_id === null) | ||
75 | return "#555"; | ||
76 | return "white"; | ||
77 | } | ||
78 | |||
79 | text: workspaceData.name ? workspaceData.name : workspaceData.idx | ||
80 | } | ||
81 | } | ||
51 | } | 82 | } |
52 | 83 | ||
53 | Text { | 84 | PopupWindow { |
54 | id: wsLabel | 85 | id: tooltip |
55 | 86 | ||
56 | font.pointSize: 10 | 87 | property bool nextVisible: (mouseArea.containsMouse || tooltipMouseArea.containsMouse) && [...windowsModel.values].length > 0 |
57 | font.family: "Fira Sans" | 88 | |
58 | color: { | 89 | anchor { |
59 | if (workspaceData.is_active) | 90 | item: mouseArea |
60 | return "#23fd00"; | 91 | edges: Edges.Bottom | Edges.Left |
61 | if (workspaceData.active_window_id === null) | 92 | } |
62 | return "#555"; | 93 | visible: false |
63 | return "white"; | 94 | |
95 | onNextVisibleChanged: hangTimer.restart() | ||
96 | |||
97 | Timer { | ||
98 | id: hangTimer | ||
99 | interval: 100 | ||
100 | onTriggered: tooltip.visible = tooltip.nextVisible | ||
64 | } | 101 | } |
65 | anchors.centerIn: parent | ||
66 | 102 | ||
67 | text: workspaceData.name ? workspaceData.name : workspaceData.idx | 103 | implicitWidth: tooltipContent.implicitWidth |
104 | implicitHeight: tooltipContent.implicitHeight | ||
105 | color: "black" | ||
106 | |||
107 | WrapperMouseArea { | ||
108 | id: tooltipMouseArea | ||
109 | |||
110 | hoverEnabled: true | ||
111 | enabled: true | ||
112 | |||
113 | anchors.fill: parent | ||
114 | |||
115 | WrapperItem { | ||
116 | id: tooltipContent | ||
117 | |||
118 | margin: 0 | ||
119 | |||
120 | ColumnLayout { | ||
121 | spacing: 0 | ||
122 | |||
123 | Repeater { | ||
124 | model: ScriptModel { | ||
125 | id: windowsModel | ||
126 | |||
127 | values: { | ||
128 | let currWindows = Array.from(NiriService.windows).filter(win => win.workspace_id == wsItem.workspaceData.id); | ||
129 | currWindows.sort((a, b) => { | ||
130 | if (a.is_floating !== b.is_floating) | ||
131 | return b.is_floating - a.is_floating; | ||
132 | if (a.layout.tile_pos_in_workspace_view?.[0] !== b.layout.tile_pos_in_workspace_view?.[0]) | ||
133 | return a.layout.tile_pos_in_workspace_view?.[0] - b.layout.tile_pos_in_workspace_view?.[0] | ||
134 | if (a.layout.tile_pos_in_workspace_view?.[1] !== b.layout.tile_pos_in_workspace_view?.[1]) | ||
135 | return a.layout.tile_pos_in_workspace_view?.[1] - b.layout.tile_pos_in_workspace_view?.[1] | ||
136 | if (a.layout.pos_in_scrolling_layout?.[0] !== b.layout.pos_in_scrolling_layout?.[0]) | ||
137 | return a.layout.pos_in_scrolling_layout?.[0] - b.layout.pos_in_scrolling_layout?.[0] | ||
138 | if (a.layout.pos_in_scrolling_layout?.[1] !== b.layout.pos_in_scrolling_layout?.[1]) | ||
139 | return a.layout.pos_in_scrolling_layout?.[1] - b.layout.pos_in_scrolling_layout?.[1] | ||
140 | if (a.app_id !== b.app_id) | ||
141 | return a.app_id.localeCompare(b.app_id); | ||
142 | |||
143 | return a.title.localeCompare(b.title); | ||
144 | }); | ||
145 | return currWindows; | ||
146 | } | ||
147 | } | ||
148 | |||
149 | WrapperMouseArea { | ||
150 | id: windowMouseArea | ||
151 | |||
152 | property var windowData: modelData | ||
153 | |||
154 | hoverEnabled: true | ||
155 | cursorShape: Qt.PointingHandCursor | ||
156 | enabled: true | ||
157 | |||
158 | Layout.fillWidth: true | ||
159 | |||
160 | onClicked: { | ||
161 | NiriService.sendCommand({ "Action": { "FocusWindow": { "id": windowData.id } } }, _ => {}) | ||
162 | } | ||
163 | |||
164 | WrapperRectangle { | ||
165 | color: windowMouseArea.containsMouse ? "#33808080" : "transparent"; | ||
166 | |||
167 | anchors.fill: parent | ||
168 | |||
169 | WrapperItem { | ||
170 | anchors.fill: parent | ||
171 | |||
172 | margin: 4 | ||
173 | |||
174 | Text { | ||
175 | id: windowLabel | ||
176 | |||
177 | font.pointSize: 10 | ||
178 | font.family: "Fira Sans" | ||
179 | color: { | ||
180 | if (windowData.is_focused) | ||
181 | return "#23fd00"; | ||
182 | if (NiriService.workspaces.find(ws => ws.id == windowData.workspace_id)?.active_window_id == windowData.id) | ||
183 | return "white"; | ||
184 | return "#555"; | ||
185 | } | ||
186 | |||
187 | text: windowData.title | ||
188 | |||
189 | horizontalAlignment: Text.AlignLeft | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | } | ||
196 | } | ||
197 | } | ||
68 | } | 198 | } |
69 | } | 199 | } |
70 | } | 200 | } |
71 | } \ No newline at end of file | 201 | } |
diff --git a/accounts/gkleen@sif/shell/quickshell/shell.qml b/accounts/gkleen@sif/shell/quickshell/shell.qml index 2abd1fef..2ddecad9 100644 --- a/accounts/gkleen@sif/shell/quickshell/shell.qml +++ b/accounts/gkleen@sif/shell/quickshell/shell.qml | |||
@@ -1,6 +1,7 @@ | |||
1 | //@ pragma UseQApplication | 1 | //@ pragma UseQApplication |
2 | 2 | ||
3 | import Quickshell | 3 | import Quickshell |
4 | import Quickshell.Wayland | ||
4 | 5 | ||
5 | ShellRoot { | 6 | ShellRoot { |
6 | settings.watchFiles: false | 7 | settings.watchFiles: false |
@@ -8,8 +9,34 @@ ShellRoot { | |||
8 | Variants { | 9 | Variants { |
9 | model: Quickshell.screens | 10 | model: Quickshell.screens |
10 | 11 | ||
11 | delegate: Bar { | 12 | delegate: Scope { |
12 | modelData: item | 13 | id: screenScope |
14 | |||
15 | required property var modelData | ||
16 | |||
17 | PanelWindow { | ||
18 | id: bgWindow | ||
19 | |||
20 | screen: screenScope.modelData | ||
21 | |||
22 | WlrLayershell.layer: WlrLayer.Background | ||
23 | WlrLayershell.exclusionMode: ExclusionMode.Ignore | ||
24 | |||
25 | anchors.top: true | ||
26 | anchors.bottom: true | ||
27 | anchors.left: true | ||
28 | anchors.right: true | ||
29 | |||
30 | color: "black" | ||
31 | |||
32 | WallpaperBackground { | ||
33 | screen: bgWindow.screen.name | ||
34 | } | ||
35 | } | ||
36 | |||
37 | Bar { | ||
38 | screen: screenScope.modelData | ||
39 | } | ||
13 | } | 40 | } |
14 | } | 41 | } |
15 | } | 42 | } |