diff --git a/home/bin/desktop/executable_quickshell-start.sh b/home/bin/desktop/executable_quickshell-start.sh index 9876e21..e32ba41 100644 --- a/home/bin/desktop/executable_quickshell-start.sh +++ b/home/bin/desktop/executable_quickshell-start.sh @@ -1,5 +1,23 @@ #!/bin/bash -# Start the systemd-managed Quickshell bar on the current Wayland session. +# Start the systemd-managed Quickshell bar in the current graphical session. -systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP HYPRLAND_INSTANCE_SIGNATURE +if ! command -v qs &> /dev/null; then + if [ "${XDG_SESSION_TYPE}" = "x11" ]; then + ~/bin/desktop/polybar-start.sh + fi + exit 0 +fi + +if [ "${XDG_SESSION_TYPE}" = "x11" ]; then + systemctl --user unset-environment WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE + systemctl --user set-environment QT_QPA_PLATFORM=xcb +else + systemctl --user set-environment QT_QPA_PLATFORM=wayland +fi +systemctl --user import-environment DISPLAY XAUTHORITY WAYLAND_DISPLAY XDG_SESSION_TYPE XDG_CURRENT_DESKTOP HYPRLAND_INSTANCE_SIGNATURE I3SOCK +if [ "$(hostname)" = "desktop" ]; then + systemctl --user set-environment QUICKSHELL_BAR_SCREEN=DP-2 +else + systemctl --user unset-environment QUICKSHELL_BAR_SCREEN +fi systemctl --user restart quickshell-bar.service diff --git a/home/bin/system/executable_system-start.sh b/home/bin/system/executable_system-start.sh index 7e71026..aca2018 100644 --- a/home/bin/system/executable_system-start.sh +++ b/home/bin/system/executable_system-start.sh @@ -5,11 +5,7 @@ pass git pull # Desktop ~/bin/connect-nas.sh -if [ "${XDG_SESSION_TYPE}" = "wayland" ]; then - ~/bin/desktop/quickshell-start.sh -else - systemctl --user start polybar -fi +~/bin/desktop/quickshell-start.sh systemctl --user restart streamdeck /usr/libexec/polkit-gnome-authentication-agent-1 & diff --git a/home/dot_config/quickshell/bar/Bar.qml b/home/dot_config/quickshell/bar/Bar.qml index a94c02f..f0f28a0 100644 --- a/home/dot_config/quickshell/bar/Bar.qml +++ b/home/dot_config/quickshell/bar/Bar.qml @@ -1,6 +1,5 @@ import QtQuick import Quickshell -import Quickshell.Hyprland import Quickshell.Services.Pipewire import Quickshell.Services.UPower @@ -11,6 +10,7 @@ PanelWindow { property var source: Pipewire.defaultAudioSource property var battery: UPower.displayDevice property var hardware + property bool isWayland: Quickshell.env("XDG_SESSION_TYPE") === "wayland" anchors { top: true @@ -42,34 +42,29 @@ PanelWindow { id: leftModules anchors { left: parent.left - top: parent.top - bottom: parent.bottom + verticalCenter: parent.verticalCenter } + height: Theme.blockHeight spacing: Theme.moduleSpacing - Workspaces { + Loader { height: parent.height + source: bar.isWayland ? "Workspaces.qml" : "I3Workspaces.qml" } } - Text { + Loader { anchors.centerIn: parent width: Math.max(0, Math.min(implicitWidth, parent.width - leftModules.width - rightModules.width - Theme.blockHeight)) - elide: Text.ElideRight - horizontalAlignment: Text.AlignHCenter - text: Hyprland.activeToplevel ? Hyprland.activeToplevel.title : "" - color: Theme.foreground - font.family: Theme.fontFamily - font.pixelSize: Theme.fontSize + source: bar.isWayland ? "HyprlandTitle.qml" : "I3Title.qml" } Row { id: rightModules anchors { right: parent.right - top: parent.top - bottom: parent.bottom + verticalCenter: parent.verticalCenter rightMargin: Theme.moduleSpacing / 2 } spacing: Theme.moduleSpacing diff --git a/home/dot_config/quickshell/bar/BatteryBlock.qml b/home/dot_config/quickshell/bar/BatteryBlock.qml index 9a525cb..989cae9 100644 --- a/home/dot_config/quickshell/bar/BatteryBlock.qml +++ b/home/dot_config/quickshell/bar/BatteryBlock.qml @@ -4,10 +4,10 @@ Block { id: root required property var battery - property int percentage: Math.round(battery.percentage * 100) + property int percentage: battery ? Math.round(battery.percentage * 100) : 0 signal detailsRequested(var anchorItem) - visible: battery.ready && battery.isLaptopBattery + visible: battery && battery.ready && battery.isLaptopBattery interactive: true blockColor: percentage <= 15 && UPower.onBattery ? Theme.urgent : UPower.onBattery ? Theme.foreground : Theme.secondary diff --git a/home/dot_config/quickshell/bar/HyprlandTitle.qml b/home/dot_config/quickshell/bar/HyprlandTitle.qml new file mode 100644 index 0000000..88f14c2 --- /dev/null +++ b/home/dot_config/quickshell/bar/HyprlandTitle.qml @@ -0,0 +1,11 @@ +import QtQuick +import Quickshell.Hyprland + +Text { + elide: Text.ElideRight + horizontalAlignment: Text.AlignHCenter + text: Hyprland.activeToplevel ? Hyprland.activeToplevel.title : "" + color: Theme.foreground + font.family: Theme.fontFamily + font.pixelSize: Theme.fontSize +} diff --git a/home/dot_config/quickshell/bar/I3Title.qml b/home/dot_config/quickshell/bar/I3Title.qml new file mode 100644 index 0000000..5e44fb5 --- /dev/null +++ b/home/dot_config/quickshell/bar/I3Title.qml @@ -0,0 +1,40 @@ +import QtQuick +import Quickshell.I3 +import Quickshell.Io + +Text { + id: root + + function focusedTitle(node) { + for (const child of (node.nodes || []).concat(node.floating_nodes || [])) { + const title = focusedTitle(child); + if (title) + return title; + } + return node.focused && node.type === "con" ? node.name || "" : ""; + } + + elide: Text.ElideRight + horizontalAlignment: Text.AlignHCenter + color: Theme.foreground + font.family: Theme.fontFamily + font.pixelSize: Theme.fontSize + + Connections { + target: I3 + function onRawEvent(event) { + if ((event.type === "window" || event.type === "workspace") && !treeQuery.running) + treeQuery.running = true; + } + } + + Process { + id: treeQuery + command: ["i3-msg", "-t", "get_tree"] + running: true + + stdout: StdioCollector { + onStreamFinished: root.text = root.focusedTitle(JSON.parse(text)) + } + } +} diff --git a/home/dot_config/quickshell/bar/I3Workspaces.qml b/home/dot_config/quickshell/bar/I3Workspaces.qml new file mode 100644 index 0000000..d20eed4 --- /dev/null +++ b/home/dot_config/quickshell/bar/I3Workspaces.qml @@ -0,0 +1,48 @@ +import QtQuick +import Quickshell.I3 + +Row { + spacing: 0 + + Repeater { + model: I3.workspaces + + Rectangle { + id: workspaceButton + + required property var modelData + property bool active: modelData.active + + visible: modelData.number > 0 + width: visible ? Theme.blockHeight + 2 : 0 + height: parent.height + color: modelData.urgent ? Theme.urgent + : active ? Theme.primary : "transparent" + + Rectangle { + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + height: Theme.activeLineWidth + color: workspaceButton.active ? Theme.accent : "transparent" + } + + Text { + anchors.centerIn: parent + text: modelData.number === 2 ? "\uf120" + : modelData.number === 13 ? "\uf001" : modelData.name + color: Theme.foreground + font.family: Theme.iconFontFamily + font.pixelSize: Theme.fontSize + } + + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onClicked: workspaceButton.modelData.activate() + } + } + } +} diff --git a/home/dot_config/quickshell/bar/Theme.qml b/home/dot_config/quickshell/bar/Theme.qml index 87ad37e..0da855c 100644 --- a/home/dot_config/quickshell/bar/Theme.qml +++ b/home/dot_config/quickshell/bar/Theme.qml @@ -18,7 +18,7 @@ Singleton { readonly property string fontFamily: "SF Pro Display, Helvetica, Arial, sans-serif" readonly property string iconFontFamily: "SF Pro Display, Font Awesome 6 Free" - readonly property int barHeight: 38 + readonly property int barHeight: 32 readonly property int blockHeight: 32 readonly property int fontSize: 18 readonly property int fontTiny: 11 diff --git a/home/dot_config/quickshell/bar/shell.qml b/home/dot_config/quickshell/bar/shell.qml index 3f3a580..a49b637 100644 --- a/home/dot_config/quickshell/bar/shell.qml +++ b/home/dot_config/quickshell/bar/shell.qml @@ -11,6 +11,8 @@ ShellRoot { Bar { required property var modelData screen: modelData + visible: !Quickshell.env("QUICKSHELL_BAR_SCREEN") + || modelData.name === Quickshell.env("QUICKSHELL_BAR_SCREEN") hardware: hardwareService } } diff --git a/home/dot_config/systemd/user/quickshell-bar.service b/home/dot_config/systemd/user/quickshell-bar.service index 93303c5..861a767 100644 --- a/home/dot_config/systemd/user/quickshell-bar.service +++ b/home/dot_config/systemd/user/quickshell-bar.service @@ -3,7 +3,6 @@ Description=Quickshell desktop bar Documentation=https://quickshell.org/ After=graphical-session.target PartOf=graphical-session.target -ConditionEnvironment=WAYLAND_DISPLAY [Service] Type=simple