feat: complete quickshell redesign
This commit is contained in:
1 parent
5245f4aaf2
commit
8be610fbdd
25 files changed
+1410
-401
No files matched your search
@@ -0,0 +1,589 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Io
|
||||
import Quickshell.Services.Pipewire
|
||||
import Quickshell.Services.Mpris
|
||||
import Quickshell.Networking
|
||||
import Quickshell.Bluetooth
|
||||
import "../Shared"
|
||||
|
||||
PanelWindow {
|
||||
id: qsWindow
|
||||
property QtObject rootState
|
||||
|
||||
readonly property int panelWidth: 380
|
||||
|
||||
visible: rootState.quickSettingsOpen
|
||||
|
||||
// Spans the whole screen (like the other overlays) purely so the
|
||||
// click-outside-to-close MouseArea below has somewhere to catch clicks -
|
||||
// the visible chrome is just the anchored `panel` Surface in the corner.
|
||||
anchors { top: true; bottom: true; left: true; right: true }
|
||||
exclusiveZone: 0
|
||||
color: "transparent"
|
||||
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.namespace: "quickshell-quicksettings"
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
|
||||
|
||||
// --- Host / uptime ---
|
||||
property string hostLabel: "localhost"
|
||||
property string uptimeLabel: ""
|
||||
|
||||
Process {
|
||||
id: hostnameProcess
|
||||
command: ["hostname"]
|
||||
running: qsWindow.visible
|
||||
stdout: StdioCollector { onStreamFinished: qsWindow.hostLabel = this.text.trim() }
|
||||
}
|
||||
|
||||
Process {
|
||||
id: uptimeProcess
|
||||
command: ["bash", "-c", "uptime -p | sed 's/^up //'"]
|
||||
running: qsWindow.visible
|
||||
stdout: StdioCollector { onStreamFinished: qsWindow.uptimeLabel = this.text.trim() }
|
||||
}
|
||||
|
||||
// --- Brightness (polled only while the panel is open) ---
|
||||
property real brightnessLevel: 0.5
|
||||
|
||||
Timer {
|
||||
interval: 1000
|
||||
running: qsWindow.visible
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: brightnessProcess.restart()
|
||||
}
|
||||
|
||||
Process {
|
||||
id: brightnessProcess
|
||||
command: ["bash", "-c", "brightnessctl -m 2>/dev/null | awk -F, '{print $4}' | tr -d '%'"]
|
||||
running: false
|
||||
function restart() { running = false; running = true; }
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
let val = parseInt(this.text);
|
||||
if (!isNaN(val)) qsWindow.brightnessLevel = val / 100.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: setBrightnessProcess
|
||||
running: false
|
||||
function set(pct) { command = ["brightnessctl", "set", pct + "%"]; running = false; running = true; }
|
||||
}
|
||||
|
||||
// --- Volume (live Pipewire binding) ---
|
||||
property QtObject sink: Pipewire.defaultAudioSink
|
||||
property bool sinkReady: sink !== null && sink.ready && sink.audio !== null
|
||||
property real volumeLevel: sinkReady ? sink.audio.volume : 0.0
|
||||
|
||||
// --- Audio sinks (all real hardware/software sinks, for the routing list) ---
|
||||
readonly property var sinkNodes: Pipewire.nodes.values.filter(n => n.isSink && !n.isStream)
|
||||
|
||||
PwObjectTracker {
|
||||
objects: qsWindow.sinkNodes
|
||||
}
|
||||
|
||||
// --- Wi-Fi / Bluetooth status ---
|
||||
function wifiNetworkName() {
|
||||
let devices = Networking.devices ? Networking.devices.values : [];
|
||||
for (const d of devices) {
|
||||
if (d.type === DeviceType.Wifi && d.networks) {
|
||||
for (const n of d.networks.values) if (n.connected) return n.name;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function bluetoothDeviceName() {
|
||||
let adapter = Bluetooth.defaultAdapter;
|
||||
if (!adapter || !adapter.devices) return "";
|
||||
for (const d of adapter.devices.values) if (d.connected) return d.name || d.deviceName;
|
||||
return "";
|
||||
}
|
||||
|
||||
// --- Night light: only wire the toggle to a binary that's actually installed ---
|
||||
property string nightLightBinary: ""
|
||||
property bool nightLightOn: false
|
||||
|
||||
Process {
|
||||
id: nightLightDetect
|
||||
command: ["bash", "-c", "command -v gammastep || command -v wlsunset || true"]
|
||||
running: true
|
||||
stdout: StdioCollector { onStreamFinished: qsWindow.nightLightBinary = this.text.trim() }
|
||||
}
|
||||
|
||||
Process {
|
||||
id: nightLightProcess
|
||||
running: false
|
||||
function toggle() {
|
||||
if (qsWindow.nightLightBinary.length === 0) return;
|
||||
if (qsWindow.nightLightOn) {
|
||||
command = ["pkill", "-f", qsWindow.nightLightBinary];
|
||||
} else {
|
||||
command = [qsWindow.nightLightBinary];
|
||||
}
|
||||
running = false;
|
||||
running = true;
|
||||
qsWindow.nightLightOn = !qsWindow.nightLightOn;
|
||||
}
|
||||
}
|
||||
|
||||
// --- Media player (first available MPRIS source) ---
|
||||
readonly property var player: Mpris.players.values.length > 0 ? Mpris.players.values[0] : null
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: rootState.quickSettingsOpen = false
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
focus: qsWindow.visible
|
||||
Keys.onEscapePressed: (event) => { rootState.quickSettingsOpen = false; event.accepted = true; }
|
||||
}
|
||||
|
||||
Surface {
|
||||
id: panel
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.topMargin: 12
|
||||
anchors.rightMargin: 12
|
||||
width: qsWindow.panelWidth
|
||||
height: content.implicitHeight + Theme.geometry.padding * 2
|
||||
tint: Theme.colors.primary
|
||||
glow: true
|
||||
|
||||
MouseArea { anchors.fill: parent } // absorb clicks so they don't fall through to the backdrop
|
||||
|
||||
Column {
|
||||
id: content
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.margins: Theme.geometry.padding
|
||||
spacing: Theme.geometry.spacing * 1.5
|
||||
|
||||
// --- Header ---
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 44
|
||||
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.geometry.spacing
|
||||
|
||||
Rectangle {
|
||||
width: 44
|
||||
height: 44
|
||||
color: Theme.colors.surfaceHover
|
||||
border.width: Theme.geometry.borderWidth
|
||||
border.color: Theme.colors.crust
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: Quickshell.env("USER").charAt(0).toUpperCase()
|
||||
font.family: Theme.font.headlineFamily
|
||||
font.bold: true
|
||||
font.pixelSize: 20
|
||||
color: Theme.colors.primary
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 2
|
||||
Text {
|
||||
text: Quickshell.env("USER") + "@" + qsWindow.hostLabel
|
||||
color: Theme.colors.text
|
||||
font.family: Theme.font.family
|
||||
font.bold: true
|
||||
font.pixelSize: Theme.type.label
|
||||
}
|
||||
Text {
|
||||
text: "UP " + qsWindow.uptimeLabel
|
||||
color: Theme.colors.textMuted
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: Theme.type.caption
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 28
|
||||
height: 28
|
||||
color: "transparent"
|
||||
border.width: Theme.geometry.borderWidth
|
||||
border.color: Theme.colors.alert
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "PWR"
|
||||
color: Theme.colors.alert
|
||||
font.family: Theme.font.family
|
||||
font.bold: true
|
||||
font.pixelSize: 9
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
rootState.quickSettingsOpen = false;
|
||||
rootState.logoutMenuOpen = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- 2x2 toggle grid ---
|
||||
Grid {
|
||||
width: parent.width
|
||||
columns: 2
|
||||
rowSpacing: Theme.geometry.spacing
|
||||
columnSpacing: Theme.geometry.spacing
|
||||
|
||||
ToggleTile {
|
||||
label: "Wi-Fi"
|
||||
sub: on ? (qsWindow.wifiNetworkName() || "Connected") : "Disabled"
|
||||
on: Networking.wifiEnabled
|
||||
accent: Theme.colors.primary
|
||||
onToggledSwitch: Networking.wifiEnabled = !Networking.wifiEnabled
|
||||
}
|
||||
|
||||
ToggleTile {
|
||||
label: "Bluetooth"
|
||||
sub: on ? (qsWindow.bluetoothDeviceName() || "On") : "Disabled"
|
||||
on: Bluetooth.defaultAdapter ? Bluetooth.defaultAdapter.enabled : false
|
||||
accent: Theme.colors.secondary
|
||||
onToggledSwitch: {
|
||||
if (Bluetooth.defaultAdapter) Bluetooth.defaultAdapter.enabled = !Bluetooth.defaultAdapter.enabled;
|
||||
}
|
||||
}
|
||||
|
||||
ToggleTile {
|
||||
label: "Do Not Disturb"
|
||||
sub: on ? "Notifications Off" : "Notifications On"
|
||||
on: rootState.dndEnabled
|
||||
accent: Theme.colors.warning
|
||||
onToggledSwitch: rootState.dndEnabled = !rootState.dndEnabled
|
||||
}
|
||||
|
||||
ToggleTile {
|
||||
label: "Night Light"
|
||||
sub: qsWindow.nightLightBinary.length === 0 ? "Unavailable" : (on ? "Enabled" : "Disabled")
|
||||
on: qsWindow.nightLightOn
|
||||
enabled: qsWindow.nightLightBinary.length > 0
|
||||
accent: Theme.colors.tertiary
|
||||
onToggledSwitch: nightLightProcess.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
// --- Sliders ---
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.geometry.spacing
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.geometry.spacing / 2
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 16
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
text: "OUTPUT LEVEL"
|
||||
color: Theme.colors.textMuted
|
||||
font.family: Theme.font.family
|
||||
font.bold: true
|
||||
font.pixelSize: Theme.type.caption
|
||||
}
|
||||
Text {
|
||||
anchors.right: parent.right
|
||||
text: Math.round(qsWindow.volumeLevel * 100) + "%"
|
||||
color: Theme.colors.text
|
||||
font.family: Theme.font.family
|
||||
font.bold: true
|
||||
font.pixelSize: Theme.type.caption
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
width: parent.width
|
||||
height: 16
|
||||
function apply(mx) {
|
||||
if (!qsWindow.sinkReady) return;
|
||||
qsWindow.sink.audio.volume = Math.max(0, Math.min(1, mx / width));
|
||||
}
|
||||
onPressed: (mouse) => apply(mouse.x)
|
||||
onPositionChanged: (mouse) => { if (pressed) apply(mouse.x); }
|
||||
|
||||
ProgressBar {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: parent.width
|
||||
value: qsWindow.volumeLevel
|
||||
fillColor: Theme.colors.secondary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.geometry.spacing / 2
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 16
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
text: "BRIGHTNESS"
|
||||
color: Theme.colors.textMuted
|
||||
font.family: Theme.font.family
|
||||
font.bold: true
|
||||
font.pixelSize: Theme.type.caption
|
||||
}
|
||||
Text {
|
||||
anchors.right: parent.right
|
||||
text: Math.round(qsWindow.brightnessLevel * 100) + "%"
|
||||
color: Theme.colors.text
|
||||
font.family: Theme.font.family
|
||||
font.bold: true
|
||||
font.pixelSize: Theme.type.caption
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
width: parent.width
|
||||
height: 16
|
||||
function apply(mx) {
|
||||
let pct = Math.round(Math.max(0, Math.min(1, mx / width)) * 100);
|
||||
qsWindow.brightnessLevel = pct / 100.0;
|
||||
setBrightnessProcess.set(pct);
|
||||
}
|
||||
onPressed: (mouse) => apply(mouse.x)
|
||||
onPositionChanged: (mouse) => { if (pressed) apply(mouse.x); }
|
||||
|
||||
ProgressBar {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: parent.width
|
||||
value: qsWindow.brightnessLevel
|
||||
fillColor: Theme.colors.primary
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Audio sink routing ---
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.geometry.spacing / 2
|
||||
visible: qsWindow.sinkNodes.length > 0
|
||||
|
||||
Repeater {
|
||||
model: qsWindow.sinkNodes
|
||||
|
||||
delegate: ListRow {
|
||||
width: parent.width
|
||||
accent: Theme.colors.primary
|
||||
selected: qsWindow.sink !== null && modelData.id === qsWindow.sink.id
|
||||
onClicked: Pipewire.preferredDefaultAudioSink = modelData
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: statusChip.left
|
||||
anchors.rightMargin: Theme.geometry.spacing
|
||||
text: modelData.description || modelData.name
|
||||
color: (qsWindow.sink !== null && modelData.id === qsWindow.sink.id) ? Theme.colors.textOnAccent : Theme.colors.text
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: Theme.type.caption
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
Text {
|
||||
id: statusChip
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: (qsWindow.sink !== null && modelData.id === qsWindow.sink.id) ? "DEFAULT" : ""
|
||||
color: Theme.colors.textOnAccent
|
||||
font.family: Theme.font.family
|
||||
font.bold: true
|
||||
font.pixelSize: Theme.type.caption
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Media player ---
|
||||
Surface {
|
||||
width: parent.width
|
||||
height: 96
|
||||
visible: qsWindow.player !== null
|
||||
color: Theme.colors.surface
|
||||
tint: Theme.colors.tertiary
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.geometry.spacing
|
||||
spacing: Theme.geometry.spacing / 2
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
spacing: Theme.geometry.spacing
|
||||
|
||||
Text {
|
||||
text: "♪"
|
||||
color: Theme.colors.tertiary
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: 18
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
Text {
|
||||
text: qsWindow.player ? qsWindow.player.trackTitle : ""
|
||||
color: Theme.colors.text
|
||||
font.family: Theme.font.family
|
||||
font.bold: true
|
||||
font.pixelSize: Theme.type.caption
|
||||
elide: Text.ElideRight
|
||||
width: 260
|
||||
}
|
||||
Text {
|
||||
text: qsWindow.player ? qsWindow.player.trackArtist : ""
|
||||
color: Theme.colors.textMuted
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: Theme.type.caption
|
||||
elide: Text.ElideRight
|
||||
width: 260
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
width: parent.width
|
||||
value: (qsWindow.player && qsWindow.player.length > 0) ? qsWindow.player.position / qsWindow.player.length : 0
|
||||
fillColor: Theme.colors.tertiary
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: Theme.geometry.spacing * 1.5
|
||||
|
||||
Text {
|
||||
text: "◀"
|
||||
color: Theme.colors.text
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: 14
|
||||
MouseArea { anchors.fill: parent; anchors.margins: -6; cursorShape: Qt.PointingHandCursor; onClicked: qsWindow.player && qsWindow.player.previous() }
|
||||
}
|
||||
|
||||
Text {
|
||||
text: (qsWindow.player && qsWindow.player.isPlaying) ? "II" : "▶"
|
||||
color: Theme.colors.tertiary
|
||||
font.family: Theme.font.family
|
||||
font.bold: true
|
||||
font.pixelSize: 14
|
||||
MouseArea { anchors.fill: parent; anchors.margins: -6; cursorShape: Qt.PointingHandCursor; onClicked: qsWindow.player && qsWindow.player.togglePlaying() }
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "▶"
|
||||
color: Theme.colors.text
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: 14
|
||||
MouseArea { anchors.fill: parent; anchors.margins: -6; cursorShape: Qt.PointingHandCursor; onClicked: qsWindow.player && qsWindow.player.next() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Footer ---
|
||||
Row {
|
||||
width: parent.width
|
||||
spacing: Theme.geometry.spacing / 2
|
||||
|
||||
Rectangle {
|
||||
width: 8
|
||||
height: 8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: Theme.colors.success
|
||||
border.width: Theme.geometry.borderWidth
|
||||
border.color: Theme.colors.crust
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "STATUS: OK"
|
||||
color: Theme.colors.textMuted
|
||||
font.family: Theme.font.family
|
||||
font.bold: true
|
||||
font.pixelSize: Theme.type.caption
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inline component for a 2x2 toggle tile.
|
||||
component ToggleTile: Surface {
|
||||
id: tile
|
||||
property string label: ""
|
||||
property string sub: ""
|
||||
property bool on: false
|
||||
property color accent: Theme.colors.primary
|
||||
signal toggledSwitch()
|
||||
|
||||
width: (qsWindow.panelWidth - Theme.geometry.padding * 2 - Theme.geometry.spacing) / 2
|
||||
height: 68
|
||||
color: Theme.colors.surface
|
||||
tint: on ? accent : Theme.colors.border
|
||||
glow: on
|
||||
opacity: enabled ? 1.0 : 0.5
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.geometry.spacing
|
||||
|
||||
Column {
|
||||
anchors.left: parent.left
|
||||
anchors.right: toggleSwitch.left
|
||||
anchors.rightMargin: Theme.geometry.spacing / 2
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 2
|
||||
|
||||
Text {
|
||||
text: tile.label
|
||||
color: Theme.colors.text
|
||||
font.family: Theme.font.headlineFamily
|
||||
font.bold: true
|
||||
font.pixelSize: Theme.type.body
|
||||
}
|
||||
Text {
|
||||
text: tile.sub
|
||||
color: Theme.colors.textMuted
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: Theme.type.caption
|
||||
elide: Text.ElideRight
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
||||
ToggleSwitch {
|
||||
id: toggleSwitch
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
checked: tile.on
|
||||
onColor: tile.accent
|
||||
|
||||
onToggled: tile.toggledSwitch()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user