feat: colorful multi-accent quickshell design system
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A8TNMgnEa7Kia5Wcz2kyDx
This commit is contained in:
1 parent
5a004b8be5
commit
215d8b7d8e
23 files changed
+1073
-577
No files matched your search
@@ -1,5 +1,4 @@
|
||||
import QtQuick
|
||||
import QtQuick.Effects
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Services.Pipewire
|
||||
@@ -12,18 +11,56 @@ PanelWindow {
|
||||
property bool enterQueued: false
|
||||
property var usageCounts: ({})
|
||||
property string lastUsedApp: ""
|
||||
property var allApps: []
|
||||
property bool appsLoaded: false
|
||||
|
||||
function scoreOf(desktopName) {
|
||||
let count = paletteWindow.usageCounts[desktopName] || 0;
|
||||
let isLast = (desktopName === paletteWindow.lastUsedApp);
|
||||
return count * 10 + (isLast ? 10000 : 0);
|
||||
}
|
||||
|
||||
function applyFilter() {
|
||||
let query = searchInput.text.trim().toLowerCase();
|
||||
let results = query.length === 0
|
||||
? paletteWindow.allApps.slice()
|
||||
: paletteWindow.allApps.filter(a => a.appName.toLowerCase().includes(query));
|
||||
|
||||
results.sort((a, b) => {
|
||||
if (b.score !== a.score) return b.score - a.score;
|
||||
return a.appName.localeCompare(b.appName);
|
||||
});
|
||||
|
||||
results = results.slice(0, 50);
|
||||
|
||||
appModel.clear();
|
||||
for (let i = 0; i < results.length; i++) {
|
||||
appModel.append(results[i]);
|
||||
}
|
||||
|
||||
appList.currentIndex = appModel.count > 0 ? 0 : -1;
|
||||
|
||||
if (paletteWindow.enterQueued && appModel.count > 0) {
|
||||
paletteWindow.enterQueued = false;
|
||||
paletteWindow.launchApp(0);
|
||||
}
|
||||
}
|
||||
|
||||
readonly property int headerHeight: 50
|
||||
readonly property int footerHeight: 24
|
||||
readonly property int emptyStateHeight: 40
|
||||
|
||||
function launchApp(index) {
|
||||
if (index < 0 || index >= appModel.count) return;
|
||||
let item = appModel.get(index);
|
||||
let desktopName = item.desktopName;
|
||||
let appPath = item.appPath;
|
||||
|
||||
|
||||
logHistoryProcess.command = ["bash", "-c", "echo '" + desktopName + "' >> ~/.cache/quickshell-app-history.txt"];
|
||||
logHistoryProcess.restart();
|
||||
|
||||
|
||||
launchProcess.command = [
|
||||
"bash", "-c",
|
||||
"bash", "-c",
|
||||
"EXEC=$(awk -F= '/^Exec=/ {print $2; exit}' \"$1\" | sed 's/ %[a-zA-Z]//g'); if command -v uwsm &>/dev/null; then eval \"uwsm app -- $EXEC\"; elif command -v niri &>/dev/null; then eval \"niri msg action spawn -- $EXEC\"; else nohup eval \"$EXEC\" </dev/null >/dev/null 2>&1 & fi",
|
||||
"_", appPath
|
||||
];
|
||||
@@ -39,7 +76,7 @@ PanelWindow {
|
||||
left: true
|
||||
right: true
|
||||
}
|
||||
|
||||
|
||||
exclusiveZone: 0
|
||||
color: "transparent"
|
||||
|
||||
@@ -49,24 +86,23 @@ PanelWindow {
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
rootState.commandPaletteOpen = false
|
||||
rootState.commandPaletteOsdMode = false
|
||||
}
|
||||
onClicked: rootState.commandPaletteOpen = false
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Surface {
|
||||
id: container
|
||||
// Sized appropriately for a 2560x1440 screen
|
||||
width: 800
|
||||
height: Math.min(600, (appList.count > 0 ? appList.contentHeight : 0) + (searchInput.text.length > 0 ? 50 + Theme.geometry.spacing : 0) + Theme.geometry.padding * 2)
|
||||
height: Math.min(600,
|
||||
headerHeight + Theme.geometry.spacing
|
||||
+ (appModel.count > 0 ? appList.contentHeight : emptyStateHeight) + Theme.geometry.spacing
|
||||
+ footerHeight
|
||||
+ Theme.geometry.padding * 2)
|
||||
anchors.centerIn: parent
|
||||
radius: Theme.geometry.radiusMedium
|
||||
color: Theme.colors.background
|
||||
border.color: Theme.colors.border
|
||||
border.width: 1
|
||||
tint: Theme.colors.primary
|
||||
glow: true
|
||||
|
||||
Behavior on scale { SpringAnimation { spring: 3; damping: 0.2 } }
|
||||
Behavior on scale { SpringAnimation { spring: Theme.motion.springSoft.spring; damping: Theme.motion.springSoft.damping } }
|
||||
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } }
|
||||
Behavior on height { NumberAnimation { duration: Theme.animation.durationFast; easing.type: Easing.OutCubic } }
|
||||
|
||||
@@ -75,100 +111,54 @@ PanelWindow {
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
|
||||
// --- App Launcher ---
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.geometry.padding
|
||||
spacing: searchInput.text.length > 0 ? Theme.geometry.spacing : 0
|
||||
|
||||
Rectangle {
|
||||
spacing: Theme.geometry.spacing
|
||||
|
||||
TextField {
|
||||
id: searchInput
|
||||
width: parent.width
|
||||
height: searchInput.text.length > 0 ? 50 : 0
|
||||
opacity: searchInput.text.length > 0 ? 1 : 0
|
||||
clip: true
|
||||
color: Theme.colors.surface
|
||||
radius: Theme.geometry.radiusSmall
|
||||
border.width: 1
|
||||
border.color: searchInput.activeFocus ? Theme.colors.primary : Theme.colors.border
|
||||
height: paletteWindow.headerHeight
|
||||
placeholder: "Search apps..."
|
||||
|
||||
Behavior on height { NumberAnimation { duration: Theme.animation.durationFast } }
|
||||
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } }
|
||||
Behavior on border.color { ColorAnimation { duration: Theme.animation.durationFast } }
|
||||
|
||||
layer.enabled: searchInput.activeFocus
|
||||
layer.effect: MultiEffect {
|
||||
shadowEnabled: true
|
||||
shadowColor: Theme.colors.primary
|
||||
shadowOpacity: 0.35
|
||||
shadowBlur: 0.4
|
||||
shadowHorizontalOffset: 0
|
||||
shadowVerticalOffset: 0
|
||||
onVisibleChanged: {
|
||||
if (visible) focusInput();
|
||||
}
|
||||
|
||||
TextInput {
|
||||
id: searchInput
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.geometry.padding
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: 18
|
||||
color: Theme.colors.text
|
||||
clip: true
|
||||
|
||||
Text {
|
||||
text: "Search apps..."
|
||||
color: Theme.colors.textMuted
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: 18
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: searchInput.text.length === 0
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) forceActiveFocus();
|
||||
}
|
||||
|
||||
onTextChanged: {
|
||||
searchTimer.restart();
|
||||
}
|
||||
|
||||
Keys.onEscapePressed: (event) => {
|
||||
rootState.commandPaletteOpen = false;
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
Keys.onUpPressed: (event) => {
|
||||
if (appList.currentIndex > 0) {
|
||||
appList.currentIndex--;
|
||||
appList.positionViewAtIndex(appList.currentIndex, ListView.Contain);
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
Keys.onDownPressed: (event) => {
|
||||
if (appList.currentIndex < appList.count - 1) {
|
||||
appList.currentIndex++;
|
||||
appList.positionViewAtIndex(appList.currentIndex, ListView.Contain);
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
Keys.onReturnPressed: (event) => {
|
||||
if (appList.count > 0 && appList.currentIndex >= 0 && appList.currentIndex < appModel.count) {
|
||||
paletteWindow.launchApp(appList.currentIndex);
|
||||
} else {
|
||||
paletteWindow.enterQueued = true;
|
||||
}
|
||||
event.accepted = true;
|
||||
onTextChanged: {
|
||||
if (paletteWindow.appsLoaded) {
|
||||
paletteWindow.applyFilter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: searchTimer
|
||||
interval: 200
|
||||
onTriggered: searchProcess.restart()
|
||||
onEscapePressed: {
|
||||
rootState.commandPaletteOpen = false;
|
||||
}
|
||||
|
||||
onUpPressed: {
|
||||
if (appList.currentIndex > 0) {
|
||||
appList.currentIndex--;
|
||||
appList.positionViewAtIndex(appList.currentIndex, ListView.Contain);
|
||||
}
|
||||
}
|
||||
|
||||
onDownPressed: {
|
||||
if (appList.currentIndex < appList.count - 1) {
|
||||
appList.currentIndex++;
|
||||
appList.positionViewAtIndex(appList.currentIndex, ListView.Contain);
|
||||
}
|
||||
}
|
||||
|
||||
onReturnPressed: {
|
||||
if (appList.count > 0 && appList.currentIndex >= 0 && appList.currentIndex < appModel.count) {
|
||||
paletteWindow.launchApp(appList.currentIndex);
|
||||
} else {
|
||||
paletteWindow.enterQueued = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
@@ -191,21 +181,22 @@ PanelWindow {
|
||||
}
|
||||
paletteWindow.usageCounts = counts;
|
||||
paletteWindow.lastUsedApp = lastUsed;
|
||||
|
||||
// Now that history is loaded, run the search
|
||||
searchProcess.restart();
|
||||
|
||||
// Now that history is loaded, list every desktop entry once.
|
||||
// Filtering as the user types happens entirely in JS below
|
||||
// (applyFilter), so the expensive disk/symlink walk here
|
||||
// only ever runs a single time per palette open.
|
||||
listProcess.restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: searchProcess
|
||||
id: listProcess
|
||||
command: [
|
||||
"bash",
|
||||
"-c",
|
||||
"fd -L -t f -e desktop -0 . /usr/share/applications ~/.local/share/applications /var/lib/flatpak/exports/share/applications /run/current-system/sw/share/applications ~/.nix-profile/share/applications 2>/dev/null | xargs -0 -r awk -F= 'BEGIN { OFS=\"|\" } FNR==1 { if(file!=\"\" && name!=\"\") print icon, name, file; name=\"\"; icon=\"\"; file=FILENAME } /^Name=/ && name==\"\" { name=substr($0, 6) } /^Icon=/ && icon==\"\" { icon=substr($0, 6) } END { if(file!=\"\" && name!=\"\") print icon, name, file }' | { [ -z \"$1\" ] && cat || rg -i \"$1\"; } | head -n 20",
|
||||
"_",
|
||||
searchInput.text
|
||||
"bash",
|
||||
"-c",
|
||||
"fd -L -t f -e desktop -0 . /usr/share/applications ~/.local/share/applications /var/lib/flatpak/exports/share/applications /run/current-system/sw/share/applications ~/.nix-profile/share/applications 2>/dev/null | xargs -0 -r awk -F= 'BEGIN { OFS=\"|\" } FNR==1 { if(file!=\"\" && name!=\"\") print icon, name, file; name=\"\"; icon=\"\"; file=FILENAME } /^Name=/ && name==\"\" { name=substr($0, 6) } /^Icon=/ && icon==\"\" { icon=substr($0, 6) } END { if(file!=\"\" && name!=\"\") print icon, name, file }'"
|
||||
]
|
||||
running: false
|
||||
function restart() {
|
||||
@@ -215,117 +206,113 @@ PanelWindow {
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
let lines = this.text.split('\n').filter(l => l.trim() !== "");
|
||||
let results = [];
|
||||
|
||||
let apps = [];
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
let parts = lines[i].split('|');
|
||||
if (parts.length >= 3) {
|
||||
let desktopName = parts[2].split('/').pop();
|
||||
|
||||
// Calculate frecency score
|
||||
let count = paletteWindow.usageCounts[desktopName] || 0;
|
||||
let isLast = (desktopName === paletteWindow.lastUsedApp);
|
||||
// Give a massive boost to the absolute last used app, then weight by total usage
|
||||
let score = count * 10 + (isLast ? 10000 : 0);
|
||||
|
||||
results.push({
|
||||
"iconName": parts[0],
|
||||
"appName": parts[1],
|
||||
|
||||
apps.push({
|
||||
"iconName": parts[0],
|
||||
"appName": parts[1],
|
||||
"appPath": parts[2],
|
||||
"desktopName": desktopName,
|
||||
"score": score
|
||||
"isLastUsed": isLast,
|
||||
"score": paletteWindow.scoreOf(desktopName)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Sort by score (descending), then alphabetically
|
||||
results.sort((a, b) => {
|
||||
if (b.score !== a.score) return b.score - a.score;
|
||||
return a.appName.localeCompare(b.appName);
|
||||
});
|
||||
|
||||
appModel.clear();
|
||||
for (let i = 0; i < results.length; i++) {
|
||||
appModel.append(results[i]);
|
||||
}
|
||||
|
||||
appList.currentIndex = 0;
|
||||
|
||||
if (paletteWindow.enterQueued && appModel.count > 0) {
|
||||
paletteWindow.enterQueued = false;
|
||||
paletteWindow.launchApp(0);
|
||||
}
|
||||
|
||||
paletteWindow.allApps = apps;
|
||||
paletteWindow.appsLoaded = true;
|
||||
paletteWindow.applyFilter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
height: paletteWindow.emptyStateHeight
|
||||
visible: appModel.count === 0
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: searchInput.text.length > 0 ? "No apps found for “" + searchInput.text + "”" : "No apps found"
|
||||
color: Theme.colors.textMuted
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: Theme.type.body
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: appList
|
||||
width: parent.width
|
||||
height: parent.height - (searchInput.text.length > 0 ? 50 + Theme.geometry.spacing : 0)
|
||||
height: parent.height - paletteWindow.headerHeight - paletteWindow.footerHeight - Theme.geometry.spacing * 2
|
||||
visible: appModel.count > 0
|
||||
clip: true
|
||||
spacing: Theme.geometry.spacing
|
||||
|
||||
model: ListModel { id: appModel }
|
||||
|
||||
delegate: Rectangle {
|
||||
width: appList.width
|
||||
height: 36
|
||||
color: ListView.isCurrentItem ? Theme.colors.surfaceHover : "transparent"
|
||||
radius: Theme.geometry.radiusTiny
|
||||
spacing: Theme.geometry.spacing / 2
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: Theme.geometry.padding
|
||||
anchors.rightMargin: Theme.geometry.padding
|
||||
|
||||
Image {
|
||||
id: appIcon
|
||||
width: 24
|
||||
height: 24
|
||||
source: model.iconName ? Quickshell.iconPath(model.iconName) : ""
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
fillMode: Image.PreserveAspectFit
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: Theme.colors.primary
|
||||
radius: 12
|
||||
visible: parent.status === Image.Error || parent.status === Image.Null || model.iconName === ""
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: model.appName.charAt(0).toUpperCase()
|
||||
color: Theme.colors.background
|
||||
font.bold: true
|
||||
font.pixelSize: 12
|
||||
}
|
||||
model: ListModel { id: appModel }
|
||||
|
||||
delegate: ListRow {
|
||||
width: appList.width
|
||||
selected: ListView.isCurrentItem
|
||||
accent: model.isLastUsed ? Theme.colors.secondary : Theme.colors.primary
|
||||
|
||||
onEntered: appList.currentIndex = index
|
||||
onClicked: {
|
||||
appList.currentIndex = index;
|
||||
paletteWindow.launchApp(index);
|
||||
}
|
||||
|
||||
Image {
|
||||
id: appIcon
|
||||
width: 24
|
||||
height: 24
|
||||
source: model.iconName ? Quickshell.iconPath(model.iconName) : ""
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
fillMode: Image.PreserveAspectFit
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: Theme.colors.primary
|
||||
radius: 12
|
||||
visible: parent.status === Image.Error || parent.status === Image.Null || model.iconName === ""
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: model.appName.charAt(0).toUpperCase()
|
||||
color: Theme.colors.textOnAccent
|
||||
font.bold: true
|
||||
font.pixelSize: 12
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: model.appName
|
||||
color: Theme.colors.text
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: 14
|
||||
anchors.left: appIcon.right
|
||||
anchors.leftMargin: Theme.geometry.spacing
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onEntered: appList.currentIndex = index
|
||||
onClicked: {
|
||||
appList.currentIndex = index;
|
||||
paletteWindow.launchApp(index);
|
||||
}
|
||||
|
||||
Text {
|
||||
text: model.appName
|
||||
color: Theme.colors.text
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: Theme.type.label
|
||||
anchors.left: appIcon.right
|
||||
anchors.leftMargin: Theme.geometry.spacing
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HintBar {
|
||||
width: parent.width
|
||||
height: paletteWindow.footerHeight
|
||||
hints: [
|
||||
{ key: "↑↓", label: "Navigate" },
|
||||
{ key: "↵", label: "Launch" },
|
||||
{ key: "Esc", label: "Close" }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
@@ -336,7 +323,7 @@ PanelWindow {
|
||||
running = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Process {
|
||||
id: logHistoryProcess
|
||||
running: false
|
||||
@@ -352,9 +339,10 @@ PanelWindow {
|
||||
container.scale = 1.0;
|
||||
searchInput.text = "";
|
||||
paletteWindow.enterQueued = false;
|
||||
paletteWindow.appsLoaded = false;
|
||||
appModel.clear(); // Clear so it re-populates clean
|
||||
|
||||
// Read history first, then search
|
||||
|
||||
// Read history first, then list every desktop entry once
|
||||
historyProcess.restart();
|
||||
} else {
|
||||
container.scale = 0.95;
|
||||
|
||||
Reference in new issue
Block a user