feat: updates, work on qs

This commit is contained in:
Kat Inskip 2025-12-05 10:37:39 -08:00
parent 5686454354
commit 4be1b9f090
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
30 changed files with 773 additions and 74 deletions

View file

@ -0,0 +1,12 @@
import QtQuick
import QtQuick.Layouts
import "root:/DataSources"
Text {
id: clock
font.pointSize: 13
color: Settings.variable
Layout.alignment: Qt.AlignCenter
text: Time.time
}

View file

@ -0,0 +1,11 @@
import Quickshell
import QtQuick
import "root:/Helpers"
Image {
id: root
source: ThemeIcons.iconFromName("nix-snowflake", "")
sourceSize.width: 24
sourceSize.height: 24
visible: true
}

View file

@ -0,0 +1,49 @@
import QtQuick
import QtQuick.Layouts
import Quickshell
import Niri 0.1
import "root:/DataSources"
import "root:/Helpers"
RowLayout {
id: root
property string title: get_text()
property string icon_path: get_icon()
property string app_id: get_app_id()
function get_app_id() {
var app_id = niri.focusedWindow?.appId;
return app_id
}
function get_text() {
var full_title = niri.focusedWindow?.title ?? "";
var shortened_title = full_title.substring(0, 20);
if (full_title.length > 20) {
shortened_title += "…"
}
return shortened_title
}
function get_icon() {
var icon = ThemeIcons.iconForAppId(app_id);
if (icon && icon !== "") {
return icon
}
}
spacing: 10
Image {
anchors.verticalCenter: parent.verticalCenter
source: icon_path
visible: title != ""
sourceSize.width: 24
sourceSize.height: 24
smooth: true
}
Text {
text: title
color: Settings.defaultFg
}
}

View file

@ -0,0 +1,126 @@
import QtQuick
import QtQuick.Layouts
import Quickshell
import QtQuick.Controls
import Quickshell.Widgets
import Quickshell.Services.SystemTray
import "root:/DataSources"
RowLayout {
id: systray
Layout.alignment: Qt.AlignCenter
Repeater {
model: SystemTray.items
delegate: Item {
id: delagate
required property SystemTrayItem modelData
property var openItem
width: 24
height: 24
IconImage {
source: modelData.icon
width: 20
height: 20
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: popupLoader.item.visible = !popupLoader.item.visible
}
QsMenuOpener {
id: menu
menu: modelData.menu
}
LazyLoader {
id: popupLoader
loading: true
PopupWindow {
id: popup
anchor.window: delagate.QsWindow.window
anchor.rect.x: parentWindow.width * 1.15
anchor.rect.y: parentWindow.height / 1.25
color: "transparent"
implicitWidth: 200
implicitHeight: 200
Rectangle {
anchors.fill: parent
color: Settings.colors.background
radius: 5
}
ListView {
model: menu.children
anchors {
top: parent.top
topMargin: 5
bottom: parent.bottom
bottomMargin: 5
}
width: parent.width
height: parent.height
spacing: 5
ScrollBar.horizontal: ScrollBar {}
delegate: Item {
required property QsMenuHandle modelData
width: parent.width
height: 40
Rectangle {
anchors {
fill: parent
leftMargin: 5
rightMargin: 5
}
color: Settings.colors.backgroundLighter
radius: 5
Text {
anchors.centerIn: parent
text: modelData.text
color: Settings.colors.foreground
font.pointSize: 12
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: mouse => {
modelData.triggered();
// TODO: moar
var idx = ObjectModel.indexOf(modelData);
if (openItem && openItem.idx != idx) {
}
popup.visible = false;
}
}
}
}
}
}
}
}
}
}

View file

@ -0,0 +1,70 @@
import QtQuick
import QtQuick.Layouts
import "root:/DataSources"
Item {
property var modelData
property var screenData
property int index: modelData.index
property string name: modelData.name
property string generated_name: gen_text()
property bool isVisible: modelData.output == screenData.name
id: root
function gen_text() {
if (name.length == 0) {
return index
} else {
return name
}
}
function gen_width() {
if (isVisible) {
return 10 + (generated_name.length * 15)
} else {
return 0
}
}
function get_color() {
if (modelData.isUrgent) {
return Settings.base0F
}
if (modelData.isFocused) {
return Settings.base0E
}
if (modelData.isActive) {
return Settings.base0C
}
if (modelData.activeWindowId > 0) {
return Settings.base0F
}
return Settings.lighterBg
}
visible: isVisible
implicitHeight: 25
implicitWidth: gen_width()
Rectangle {
anchors.fill: parent
color: get_color()
radius: 5
Text {
anchors.centerIn: parent
color: Settings.defaultBg
text: gen_text()
font.pixelSize: 20
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: niri.focusWorkspaceById(modelData.id)
}
}
}

View file

@ -0,0 +1,24 @@
import QtQuick
import QtQuick.Layouts
import "root:/DataSources"
import "root:/Components"
import Niri 0.1
import QtQuick
import QtQuick.Layouts
import Quickshell
RowLayout {
id: root
property var screen
spacing: 10
Repeater {
model: niri.workspaces
WorkspaceButton {
modelData: model
screenData: screen
}
}
}

View file

@ -0,0 +1,97 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
Singleton {
id: root
readonly property Scheme scheme: Scheme {}
readonly property color base00: scheme.base00
readonly property color base01: scheme.base01
readonly property color base02: scheme.base02
readonly property color base03: scheme.base03
readonly property color base04: scheme.base04
readonly property color base05: scheme.base05
readonly property color base06: scheme.base06
readonly property color base07: scheme.base07
readonly property color base08: scheme.base08
readonly property color base09: scheme.base09
readonly property color base0A: scheme.base0A
readonly property color base0B: scheme.base0B
readonly property color base0C: scheme.base0C
readonly property color base0D: scheme.base0D
readonly property color base0E: scheme.base0E
readonly property color base0F: scheme.base0F
readonly property color defaultBg: scheme.defaultBg
readonly property color lighterBg: scheme.lighterBg
readonly property color selectionBg: scheme.selectionBg
readonly property color comments: scheme.comments
readonly property color darkFg: scheme.darkFg
readonly property color defaultFg: scheme.defaultFg
readonly property color lightFg: scheme.lightFg
readonly property color lightBg: scheme.lightBg
readonly property color variable: scheme.variable
readonly property color integer: scheme.integer
readonly property color classy: scheme.classy
readonly property color stringy: scheme.stringy
readonly property color support: scheme.support
readonly property color functiony: scheme.functiony
readonly property color keyword: scheme.keyword
readonly property color deprecated: scheme.deprecated
function load(data: string): void {
const colours = scheme;
const scheme_json = JSON.parse(data);
for (const [name, colour] of Object.entries(scheme_json)) {
colours[name] = colour
}
}
FileView {
path: "./stylix.json"
blockLoading: true
watchChanges: true
onFileChanged: reload()
onLoaded: root.load(text(), false)
}
component Scheme: QtObject {
property string author: ""
property string scheme: ""
property string slug: ""
property color base00: "#000000"
property color base01: "#000000"
property color base02: "#000000"
property color base03: "#000000"
property color base04: "#000000"
property color base05: "#000000"
property color base06: "#000000"
property color base07: "#000000"
property color base08: "#000000"
property color base09: "#000000"
property color base0A: "#000000"
property color base0B: "#000000"
property color base0C: "#000000"
property color base0D: "#000000"
property color base0E: "#000000"
property color base0F: "#000000"
property color defaultBg: "#000000"
property color lighterBg: "#000000"
property color selectionBg: "#000000"
property color comments: "#000000"
property color darkFg: "#000000"
property color defaultFg: "#000000"
property color lightFg: "#000000"
property color lightBg: "#000000"
property color variable: "#000000"
property color integer: "#000000"
property color classy: "#000000"
property color stringy: "#000000"
property color support: "#000000"
property color functiony: "#000000"
property color keyword: "#000000"
property color deprecated: "#000000"
}
}

View file

@ -0,0 +1,16 @@
pragma Singleton
import Quickshell
import QtQuick
Singleton {
id: root
readonly property string time: {
Qt.formatDateTime(clock.date, "yyyy-MM-dd hh:mm:ss t")
}
SystemClock {
id: clock
precision: SystemClock.Seconds
}
}

View file

@ -0,0 +1,53 @@
// https://github.com/noctalia-dev/noctalia-shell/blob/main/Commons/ThemeIcons.qml
pragma Singleton
import QtQuick
import Quickshell
Singleton {
id: root
function iconFromName(iconName, fallbackName) {
const fallback = fallbackName || "application-x-executable";
try {
if (iconName && typeof Quickshell !== 'undefined' && Quickshell.iconPath) {
const p = Quickshell.iconPath(iconName, fallback);
if (p && p !== "")
return p;
}
} catch (e)
// ignore and fall back
{}
try {
return Quickshell.iconPath ? (Quickshell.iconPath(fallback, true) || "") : "";
} catch (e2) {
return "";
}
}
// Resolve icon path for a DesktopEntries appId - safe on missing entries
function iconForAppId(appId, fallbackName) {
const fallback = fallbackName || "application-x-executable";
if (!appId)
return iconFromName(fallback, fallback);
try {
if (typeof DesktopEntries === 'undefined' || !DesktopEntries.byId)
return iconFromName(fallback, fallback);
const entry = (DesktopEntries.heuristicLookup) ? DesktopEntries.heuristicLookup(appId) : DesktopEntries.byId(appId);
const name = entry && entry.icon ? entry.icon : "";
return iconFromName(name || fallback, fallback);
} catch (e) {
return iconFromName(fallback, fallback);
}
}
// Distro logo helper (absolute path or empty string)
function distroLogoPath() {
try {
return (typeof OSInfo !== 'undefined' && OSInfo.distroIconPath) ? OSInfo.distroIconPath : "";
} catch (e) {
return "";
}
}
}

View file

@ -0,0 +1,80 @@
import Quickshell
import Quickshell.Io
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import "root:/DataSources"
import "root:/Components"
Scope {
id: root
Variants {
model: Quickshell.screens
PanelWindow {
property var modelData
screen: modelData
implicitHeight: 40
color: "transparent"
anchors {
top: true
left: true
right: true
}
margins {
left: 4
right: 4
top: 4
bottom: 4
}
Rectangle {
id: bar
anchors.fill: parent
radius: 10
color: Settings.defaultBg
RowLayout {
anchors {
left: parent.left
top: parent.top
bottom: parent.bottom
leftMargin: 10
}
spacing: 15
Workspaces {
screen: modelData
}
FocusedWindow {}
}
RowLayout {
anchors.centerIn: parent
spacing: 20
}
RowLayout {
anchors {
top: parent.top
bottom: parent.bottom
right: parent.right
rightMargin: 15
}
spacing: 15
SystemTray {}
Clock {}
DistroIcon {}
}
}
}
}
}

31
quickshell/expr.nix Normal file
View file

@ -0,0 +1,31 @@
{hostname}: let
nixfiles = import ../.;
inherit (nixfiles) lib nixosConfigurations;
palette' = nixosConfigurations.${hostname}.config.stylix.generated.palette;
palette = lib.mapAttrs (k: v:
if (lib.strings.hasPrefix "base" k)
then "#${lib.strings.toUpper v}"
else v)
palette';
paletteWithAliases = palette: {
defaultBg = palette.base00;
lighterBg = palette.base01;
selectionBg = palette.base02;
comments = palette.base03;
darkFg = palette.base04;
defaultFg = palette.base05;
lightFg = palette.base06;
lightBg = palette.base07;
variable = palette.base08;
integer = palette.base09;
classy = palette.base0A;
stringy = palette.base0B;
support = palette.base0C;
functiony = palette.base0D;
keyword = palette.base0E;
deprecated = palette.base0F;
};
fullPalette = palette // (paletteWithAliases palette);
in {
expr = fullPalette;
}

View file

@ -1,48 +1,22 @@
import Quickshell
import Quickshell.Io
import QtQuick
import Niri 0.1
Scope {
id: root
property string time
import "root:/Modules"
Variants {
model: Quickshell.screens
ShellRoot{
id: root
PanelWindow {
required property var modelData
screen: modelData
Niri {
id: niri
Component.onCompleted: connect()
anchors {
top: true
left: true
right: true
}
implicitHeight: 30
Text {
font.family: "M+2 Nerd Font Regular"
anchors.centerIn: parent
text: root.time
}
onConnected: console.info("Connected to niri")
onErrorOccurred: function(error) {
console.error("Niri error:", error)
}
}
}
Process {
id: dateProc
command: ["date", "+%F %T %Z"]
running: true
stdout: StdioCollector {
onStreamFinished: root.time = this.text
}
}
Timer {
interval: 1000
running: true
repeat: true
onTriggered: dateProc.running = true
}
LazyLoader{ active: true; component: Bar{} }
}

1
quickshell/stylix.json Normal file
View file

@ -0,0 +1 @@
{"author":"Stylix","base00":"#191A2D","base01":"#4F415B","base02":"#6363AC","base03":"#A39AB2","base04":"#B1B8D5","base05":"#D5CEEB","base06":"#D8CCEA","base07":"#D8CDEA","base08":"#7D8CC9","base09":"#908EAB","base0A":"#9B8AA9","base0B":"#948BB5","base0C":"#8391B0","base0D":"#6693D8","base0E":"#9C85CC","base0F":"#AB83A0","classy":"#9B8AA9","comments":"#A39AB2","darkFg":"#B1B8D5","defaultBg":"#191A2D","defaultFg":"#D5CEEB","deprecated":"#AB83A0","functiony":"#6693D8","integer":"#908EAB","keyword":"#9C85CC","lightBg":"#D8CDEA","lightFg":"#D8CCEA","lighterBg":"#4F415B","scheme":"Stylix","selectionBg":"#6363AC","slug":"stylix","stringy":"#948BB5","support":"#8391B0","variable":"#7D8CC9"}

3
quickshell/stylix.sh Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
HOST=$(hostname -s)
nix eval --argstr hostname "$HOST" -f expr.nix --json expr > ./stylix.json