quickshell and hyprland additions

This commit is contained in:
2026-03-15 13:56:00 +02:00
parent c9c27d1554
commit 1ad06b82a6
509 changed files with 68371 additions and 19 deletions

View File

@@ -0,0 +1,52 @@
pragma Singleton
import ".."
import qs.services
import qs.config
import qs.utils
import Quickshell
import QtQuick
Searcher {
id: root
function transformSearch(search: string): string {
return search.slice(Config.launcher.actionPrefix.length);
}
list: variants.instances
useFuzzy: Config.launcher.useFuzzy.actions
Variants {
id: variants
model: Config.launcher.actions.filter(a => (a.enabled ?? true) && (Config.launcher.enableDangerousActions || !(a.dangerous ?? false)))
Action {}
}
component Action: QtObject {
required property var modelData
readonly property string name: modelData.name ?? qsTr("Unnamed")
readonly property string desc: modelData.description ?? qsTr("No description")
readonly property string icon: modelData.icon ?? "help_outline"
readonly property list<string> command: modelData.command ?? []
readonly property bool enabled: modelData.enabled ?? true
readonly property bool dangerous: modelData.dangerous ?? false
function onClicked(list: AppList): void {
if (command.length === 0)
return;
if (command[0] === "autocomplete" && command.length > 1) {
list.search.text = `${Config.launcher.actionPrefix}${command[1]} `;
} else if (command[0] === "setMode" && command.length > 1) {
list.visibilities.launcher = false;
Colours.setMode(command[1]);
} else {
list.visibilities.launcher = false;
Quickshell.execDetached(command);
}
}
}
}

View File

@@ -0,0 +1,78 @@
pragma Singleton
import qs.config
import qs.utils
import Caelestia
import Quickshell
Searcher {
id: root
function launch(entry: DesktopEntry): void {
appDb.incrementFrequency(entry.id);
if (entry.runInTerminal)
Quickshell.execDetached({
command: ["app2unit", "--", ...Config.general.apps.terminal, `${Quickshell.shellDir}/assets/wrap_term_launch.sh`, ...entry.command],
workingDirectory: entry.workingDirectory
});
else
Quickshell.execDetached({
command: ["app2unit", "--", ...entry.command],
workingDirectory: entry.workingDirectory
});
}
function search(search: string): list<var> {
const prefix = Config.launcher.specialPrefix;
if (search.startsWith(`${prefix}i `)) {
keys = ["id", "name"];
weights = [0.9, 0.1];
} else if (search.startsWith(`${prefix}c `)) {
keys = ["categories", "name"];
weights = [0.9, 0.1];
} else if (search.startsWith(`${prefix}d `)) {
keys = ["comment", "name"];
weights = [0.9, 0.1];
} else if (search.startsWith(`${prefix}e `)) {
keys = ["execString", "name"];
weights = [0.9, 0.1];
} else if (search.startsWith(`${prefix}w `)) {
keys = ["startupClass", "name"];
weights = [0.9, 0.1];
} else if (search.startsWith(`${prefix}g `)) {
keys = ["genericName", "name"];
weights = [0.9, 0.1];
} else if (search.startsWith(`${prefix}k `)) {
keys = ["keywords", "name"];
weights = [0.9, 0.1];
} else {
keys = ["name"];
weights = [1];
if (!search.startsWith(`${prefix}t `))
return query(search).map(e => e.entry);
}
const results = query(search.slice(prefix.length + 2)).map(e => e.entry);
if (search.startsWith(`${prefix}t `))
return results.filter(a => a.runInTerminal);
return results;
}
function selector(item: var): string {
return keys.map(k => item[k]).join(" ");
}
list: appDb.apps
useFuzzy: Config.launcher.useFuzzy.apps
AppDb {
id: appDb
path: `${Paths.state}/apps.sqlite`
// favouriteApps: Config.launcher.favouriteApps
entries: DesktopEntries.applications.values.filter(a => !Strings.testRegexList(Config.launcher.hiddenApps, a.id))
}
}

View File

@@ -0,0 +1,85 @@
pragma Singleton
import ".."
import qs.config
import qs.utils
import Quickshell
import QtQuick
Searcher {
id: root
function transformSearch(search: string): string {
return search.slice(`${Config.launcher.actionPrefix}variant `.length);
}
list: [
Variant {
variant: "vibrant"
icon: "sentiment_very_dissatisfied"
name: qsTr("Vibrant")
description: qsTr("A high chroma palette. The primary palette's chroma is at maximum.")
},
Variant {
variant: "tonalspot"
icon: "android"
name: qsTr("Tonal Spot")
description: qsTr("Default for Material theme colours. A pastel palette with a low chroma.")
},
Variant {
variant: "expressive"
icon: "compare_arrows"
name: qsTr("Expressive")
description: qsTr("A medium chroma palette. The primary palette's hue is different from the seed colour, for variety.")
},
Variant {
variant: "fidelity"
icon: "compare"
name: qsTr("Fidelity")
description: qsTr("Matches the seed colour, even if the seed colour is very bright (high chroma).")
},
Variant {
variant: "content"
icon: "sentiment_calm"
name: qsTr("Content")
description: qsTr("Almost identical to fidelity.")
},
Variant {
variant: "fruitsalad"
icon: "nutrition"
name: qsTr("Fruit Salad")
description: qsTr("A playful theme - the seed colour's hue does not appear in the theme.")
},
Variant {
variant: "rainbow"
icon: "looks"
name: qsTr("Rainbow")
description: qsTr("A playful theme - the seed colour's hue does not appear in the theme.")
},
Variant {
variant: "neutral"
icon: "contrast"
name: qsTr("Neutral")
description: qsTr("Close to grayscale, a hint of chroma.")
},
Variant {
variant: "monochrome"
icon: "filter_b_and_w"
name: qsTr("Monochrome")
description: qsTr("All colours are grayscale, no chroma.")
}
]
useFuzzy: Config.launcher.useFuzzy.variants
component Variant: QtObject {
required property string variant
required property string icon
required property string name
required property string description
function onClicked(list: AppList): void {
list.visibilities.launcher = false;
Quickshell.execDetached(["caelestia", "scheme", "set", "-v", variant]);
}
}
}

View File

@@ -0,0 +1,88 @@
pragma Singleton
import ".."
import qs.config
import qs.utils
import Quickshell
import Quickshell.Io
import QtQuick
Searcher {
id: root
property string currentScheme
property string currentVariant
function transformSearch(search: string): string {
return search.slice(`${Config.launcher.actionPrefix}scheme `.length);
}
function selector(item: var): string {
return `${item.name} ${item.flavour}`;
}
function reload(): void {
getCurrent.running = true;
}
list: schemes.instances
useFuzzy: Config.launcher.useFuzzy.schemes
keys: ["name", "flavour"]
weights: [0.9, 0.1]
Variants {
id: schemes
Scheme {}
}
Process {
id: getSchemes
running: true
command: ["caelestia", "scheme", "list"]
stdout: StdioCollector {
onStreamFinished: {
const schemeData = JSON.parse(text);
const list = Object.entries(schemeData).map(([name, f]) => Object.entries(f).map(([flavour, colours]) => ({
name,
flavour,
colours
})));
const flat = [];
for (const s of list)
for (const f of s)
flat.push(f);
schemes.model = flat.sort((a, b) => (a.name + a.flavour).localeCompare((b.name + b.flavour)));
}
}
}
Process {
id: getCurrent
running: true
command: ["caelestia", "scheme", "get", "-nfv"]
stdout: StdioCollector {
onStreamFinished: {
const [name, flavour, variant] = text.trim().split("\n");
root.currentScheme = `${name} ${flavour}`;
root.currentVariant = variant;
}
}
}
component Scheme: QtObject {
required property var modelData
readonly property string name: modelData.name
readonly property string flavour: modelData.flavour
readonly property var colours: modelData.colours
function onClicked(list: AppList): void {
list.visibilities.launcher = false;
Quickshell.execDetached(["caelestia", "scheme", "set", "-n", name, "-f", flavour]);
}
}
}