quickshell: init config

This commit is contained in:
Bloxx12 2025-06-26 20:46:50 +02:00
commit 5e9c4e8e4c
Signed by: faukah
SSH key fingerprint: SHA256:Uj2AXqvtdCA4hn5Hq0ZonhIAyUqI1q4w2sMG3Z1TH7E
20 changed files with 1650 additions and 0 deletions

View file

@ -0,0 +1,50 @@
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
import Quickshell
import "../../config"
import "components"
Item {
id: root
required property ShellScreen screen
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
}
implicitWidth: Config.bar.width
Item {
id: child
anchors {
top: parent.top
bottom: parent.bottom
horizontalCenter: parent.horizontalCenter
}
implicitWidth: Math.max(clock.implicitWidth, workspaces.implicitWidth)
ColumnLayout {
spacing: 2
anchors {
top: parent.top
left: parent.left
right: parent.right
margins: 0
}
Clock {
id: clock
}
Workspaces {
id: workspaces
screen: root.screen
}
}
}
}

View file

@ -0,0 +1,34 @@
import QtQuick
import Quickshell
import "../../../config"
Rectangle {
id: root
width: text.width + 5
height: text.height + 5
implicitWidth: width
border.color: Config.catppuccin.rosewater
border.width: 0
radius: 5
color: "transparent"
Text {
id: text
anchors.centerIn: parent
property var date: Date()
text: Qt.formatDateTime(clock.date, "hh mm")
font.family: "JetBrainsMono NF Mono"
font.pointSize: 15
color: Config.catppuccin.text
}
SystemClock {
id: clock
precision: SystemClock.Seconds
}
}

View file

@ -0,0 +1,109 @@
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Io
import QtQuick.Layouts
import "../../../services/niri"
import "../../../config"
Rectangle {
id: root
required property ShellScreen screen
property var workspaces: Niri.workspaces
property var wsCount: Niri.workspaces.length
property var activeWorkspace: Niri.activeWorkspace
property var activeWorkspaceIndex: Niri.activeWorkspaceIndex
property int wsItemHeight: 15
signal workspaceAdded(workspace: var)
function onWorkspaceAdded(workspace: var) {
root.workspaces.push(workspace);
}
// property bool _: log()
// function log() {
// console.log(workspaces.values);
// return true;
// }
// Works
height: 300
// Gives warning
// height: workspaces.length * root.wsItemHeight
implicitWidth: list.implicitWidth
color: "transparent"
border.color: Config.catppuccin.rosewater
border.width: 0
radius: 7
Layout.fillWidth: true
ListView {
id: list
model: root.workspaces
implicitHeight: contentHeight
implicitWidth: contentItem.childrenRect.width
anchors.horizontalCenter: parent.horizontalCenter
// anchors.fill: parent
delegate: Item {
id: wsItem
// Name of the workspace
property string name: "VOID"
// ID of the workspace
required property string id
required property string output
property bool isActive: (id - 1 == root.activeWorkspaceIndex)
property real animActive: isActive ? 1 : 0.65
Behavior on animActive {
NumberAnimation {
duration: 150
}
}
// property bool isCorrectScreen: log()
// function log() {
// console.log("Screen name: " + root.screen.name);
// console.log(wsItem.output);
// console.log(wsItem.id);
// let isCorrect = root.screen.name == wsItem.output;
// console.log("isCorrect: ", isCorrect);
// return root.screen.name == wsItem.output;
// }
implicitHeight: root.wsItemHeight
implicitWidth: 50
anchors {
right: parent.right
left: parent.left
}
Rectangle {
anchors.centerIn: parent
height: wsItem.height - 5
width: parent.width * wsItem.animActive
radius: height / 2
border.color: Config.catppuccin.mantle
border.width: 0
color: Config.catppuccin.blue
}
}
}
Component.onCompleted: {
Niri.workspaces.forEach(workspace => {
root.workspaceAdded(workspace);
});
}
}

View file

@ -0,0 +1,9 @@
import Quickshell
import QtQuick
import QtQuick.Shapes
import "../notifications" as Notifications
Rectangle {
required property Item bar
}

View file

@ -0,0 +1,54 @@
import Quickshell
import QtQuick
import QtQuick.Effects
import "../../config"
Item {
id: root
required property Item bar
anchors.fill: parent
Rectangle {
id: rect
anchors.fill: parent
color: Config.border.color
visible: false
Behavior on color {
ColorAnimation {
duration: 150
easing.type: Easing.BezierSpline
}
}
}
Item {
id: mask
anchors.fill: parent
layer.enabled: true
visible: false
Rectangle {
anchors.fill: parent
anchors.margins: Config.border.thickness
anchors.leftMargin: root.bar.implicitWidth
radius: Config.border.rounding
}
}
MultiEffect {
anchors.fill: parent
maskEnabled: true
maskInverted: true
maskSource: mask
source: rect
maskThresholdMin: 0.5
maskSpreadAtMin: 1
}
}

View file

@ -0,0 +1,105 @@
pragma ComponentBehavior: Bound
import Quickshell
import Quickshell.Wayland
import Quickshell.Services.Notifications
import QtQuick
import QtQuick.Effects
import "../bar"
import "../volume"
import "../notifications"
import "../../services"
import "../../config"
Variants {
model: Quickshell.screens
Scope {
id: scope
required property ShellScreen modelData
Exclusions {
screen: scope.modelData
bar: bar
}
PanelWindow {
id: win
screen: scope.modelData
color: "transparent"
WlrLayershell.exclusionMode: ExclusionMode.Ignore
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
// Clickthrough mask.
// Clickable areas of the window are determined by the provided region.
mask: Region {
// Start at the bottom left; right of the bar and on top of the border
x: bar.implicitWidth
y: Config.border.thickness
// Width is the window width - the bar's width - the border thickness
width: win.width - bar.implicitWidth - Config.border.thickness
// Height is window width - the border thickness x2 top border and bottom border.
height: win.height - Config.border.thickness * 2
// Setting the intersection mode to Xor will invert the mask and make everything in the mask region not clickable and pass through clicks inside it through the window.
intersection: Intersection.Xor
Region {
item: volume
intersection: Intersection.Subtract
}
}
anchors {
top: true
bottom: true
left: true
right: true
}
Item {
id: background
anchors.fill: parent
visible: false
Border {
bar: bar
}
Backgrounds {
bar: bar
}
}
MultiEffect {
anchors.fill: source
source: background
shadowEnabled: true
blurMax: 15
}
Bar {
id: bar
screen: scope.modelData
}
VolumeSlider {
id: volume
isInRightPanel: hover.isInRightPanel
screen: scope.modelData
}
Hover {
id: hover
screen: scope.modelData
bar: bar
}
}
}
}

View file

@ -0,0 +1,38 @@
pragma ComponentBehavior: Bound
import Quickshell
import QtQuick
import "../../config"
Scope {
id: root
required property ShellScreen screen
required property Item bar
ExclusionZone {
anchors.left: true
exclusiveZone: root.bar.implicitWidth
}
ExclusionZone {
anchors.top: true
}
ExclusionZone {
anchors.right: true
}
ExclusionZone {
anchors.bottom: true
}
component ExclusionZone: PanelWindow {
screen: root.screen
color: "transparent"
exclusiveZone: Config.border.thickness
implicitHeight: Config.border.thickness
implicitWidth: Config.border.thickness
mask: Region {}
}
}

View file

@ -0,0 +1,319 @@
pragma Singleton
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Io
import Quickshell.Wayland
import Quickshell.Widgets
Singleton {
id: launcher
property bool launcherOpen: false
IpcHandler {
target: "launcher"
function open(): void {
launcher.launcherOpen = true;
}
function close(): void {
launcher.launcherOpen = false;
}
function toggle(): void {
launcher.launcherOpen = !launcher.launcherOpen;
}
}
LazyLoader {
id: loader
activeAsync: launcher.launcherOpen
PanelWindow {
width: 450
height: 7 + searchContainer.implicitHeight + list.topMargin * 2 + list.delegateHeight * 10
color: "transparent"
anchors {
bottom: parent.bottom
}
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
WlrLayershell.namespace: "shell:launcher"
Rectangle {
height: 7 + searchContainer.implicitHeight + list.topMargin + list.bottomMargin + Math.min(list.contentHeight, list.delegateHeight * 10)
Behavior on height {
NumberAnimation {
duration: 200
easing.type: Easing.OutCubic
}
}
width: 450
color: "#30c0afaf"
radius: 5
border.color: "black"
border.width: 2
ColumnLayout {
anchors.fill: parent
anchors.margins: 7
anchors.bottomMargin: 0
spacing: 0
Rectangle {
id: searchContainer
Layout.fillWidth: true
implicitHeight: searchbox.implicitHeight + 10
color: "#30c0ffff"
radius: 3
border.color: "#50ffffff"
RowLayout {
id: searchbox
anchors.fill: parent
anchors.margins: 5
IconImage {
implicitSize: parent.height
source: "root:icons/magnifying-glass.svg"
}
TextInput {
id: search
Layout.fillWidth: true
color: "black"
focus: true
Keys.forwardTo: [list]
Keys.onEscapePressed: launcher.launcherOpen = false
Keys.onPressed: event => {
if (event.modifiers & Qt.ControlModifier) {
if (event.key == Qt.Key_J) {
list.currentIndex = list.currentIndex == list.count - 1 ? 0 : list.currentIndex + 1;
event.accepted = true;
} else if (event.key == Qt.Key_K) {
list.currentIndex = list.currentIndex == 0 ? list.count - 1 : list.currentIndex - 1;
event.accepted = true;
}
}
}
onAccepted: {
if (list.currentItem) {
list.currentItem.clicked(null);
}
}
onTextChanged: {
list.currentIndex = 0;
}
}
}
}
ListView {
id: list
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
cacheBuffer: 0 // works around QTBUG-131106
//reuseItems: true
model: ScriptModel {
values: DesktopEntries.applications.values.map(object => {
const stxt = search.text.toLowerCase();
const ntxt = object.name.toLowerCase();
let si = 0;
let ni = 0;
let matches = [];
let startMatch = -1;
for (let si = 0; si != stxt.length; ++si) {
const sc = stxt[si];
while (true) {
// Drop any entries with letters that don't exist in order
if (ni == ntxt.length)
return null;
const nc = ntxt[ni++];
if (nc == sc) {
if (startMatch == -1)
startMatch = ni;
break;
} else {
if (startMatch != -1) {
matches.push({
index: startMatch,
length: ni - startMatch
});
startMatch = -1;
}
}
}
}
if (startMatch != -1) {
matches.push({
index: startMatch,
length: ni - startMatch + 1
});
}
return {
object: object,
matches: matches
};
}).filter(entry => entry !== null).sort((a, b) => {
let ai = 0;
let bi = 0;
let s = 0;
while (ai != a.matches.length && bi != b.matches.length) {
const am = a.matches[ai];
const bm = b.matches[bi];
s = bm.length - am.length;
if (s != 0)
return s;
s = am.index - bm.index;
if (s != 0)
return s;
++ai;
++bi;
}
s = a.matches.length - b.matches.length;
if (s != 0)
return s;
s = a.object.name.length - b.object.name.length;
if (s != 0)
return s;
return a.object.name.localeCompare(b.object.name);
}).map(entry => entry.object)
onValuesChanged: list.currentIndex = 0
}
topMargin: 7
bottomMargin: list.count == 0 ? 0 : 7
add: Transition {
NumberAnimation {
property: "opacity"
from: 0
to: 1
duration: 100
}
}
displaced: Transition {
NumberAnimation {
property: "y"
duration: 200
easing.type: Easing.OutCubic
}
NumberAnimation {
property: "opacity"
to: 1
duration: 100
}
}
move: Transition {
NumberAnimation {
property: "y"
duration: 200
easing.type: Easing.OutCubic
}
NumberAnimation {
property: "opacity"
to: 1
duration: 100
}
}
remove: Transition {
NumberAnimation {
property: "y"
duration: 200
easing.type: Easing.OutCubic
}
NumberAnimation {
property: "opacity"
to: 0
duration: 100
}
}
highlight: Rectangle {
radius: 5
color: "#20e0ffff"
border.color: "#30ffffff"
border.width: 1
}
keyNavigationEnabled: true
keyNavigationWraps: true
highlightMoveVelocity: -1
highlightMoveDuration: 50
preferredHighlightBegin: list.topMargin
preferredHighlightEnd: list.height - list.bottomMargin
highlightRangeMode: ListView.ApplyRange
snapMode: ListView.SnapToItem
readonly property real delegateHeight: 44
delegate: MouseArea {
required property DesktopEntry modelData
implicitHeight: list.delegateHeight
implicitWidth: ListView.view.width
onClicked: {
modelData.execute();
launcher.launcherOpen = false;
}
RowLayout {
id: delegateLayout
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 5
}
IconImage {
Layout.alignment: Qt.AlignVCenter
asynchronous: true
implicitSize: 30
source: Quickshell.iconPath(modelData.icon)
}
Text {
text: modelData.name
color: "black"
font.family: "ComicShannsMono Nerd Font Mono"
Layout.alignment: Qt.AlignVCenter
}
}
}
}
}
}
}
}
function init() {
}
}

View file

@ -0,0 +1,18 @@
import Quickshell
import Quickshell.Widgets
import Quickshell.Services.Notifications
import QtQuick
import QtQuick.Layouts
import "../../config"
import "../../services"
Rectangle {
id: root
color: "transparent"
required property Notification.Notif modelData
Text {
text: root.modelData.summary
}
}

View file

@ -0,0 +1,41 @@
pragma ComponentBehavior: Bound
import Quickshell
import Quickshell.Wayland
import Quickshell.Services.Notifications
import QtQuick
import QtQuick.Effects
Rectangle {
id: root
required property bool isInRightPanel
required property ShellScreen screen
property bool isVisible
color: "transparent"
property bool _: log()
function log() {
console.log(hover.hovered);
return true
}
anchors {
right: parent.right
verticalCenter: parent.verticalCenter
}
implicitWidth: 60
implicitHeight: screen.height / 3
HoverHandler {
id: hover
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
}
Rectangle {
anchors.right: parent.right
color: "green"
implicitWidth: hover.hovered | root.isInRightPanel ? 60 : 10
implicitHeight: root.screen.height / 3
}
}