This commit is contained in:
Damocles 2026-04-12 15:58:13 +02:00
parent 4df704844e
commit 9e1716aa39
14 changed files with 154 additions and 102 deletions

View file

@ -9,7 +9,8 @@ M.BarSection {
tooltip: "Brightness: " + root.percent + "%" tooltip: "Brightness: " + root.percent + "%"
property int percent: 0 property int percent: 0
onPercentChanged: if (percent > 0) M.OsdState.show(percent / 100, "\uF185") onPercentChanged: if (percent > 0)
M.OsdState.show(percent / 100, "\uF185")
Process { Process {
id: adjProc id: adjProc

View file

@ -39,8 +39,12 @@ PanelWindow {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
spacing: M.Theme.barSpacing spacing: M.Theme.barSpacing
M.Clock { visible: M.Modules.clock } M.Clock {
M.Notifications { visible: M.Modules.notifications } visible: M.Modules.clock
}
M.Notifications {
visible: M.Modules.notifications
}
} }
// ---- left ---- // ---- left ----
@ -50,7 +54,10 @@ PanelWindow {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
spacing: M.Theme.barSpacing spacing: M.Theme.barSpacing
M.Workspaces { bar: bar; visible: M.Modules.workspaces } M.Workspaces {
bar: bar
visible: M.Modules.workspaces
}
M.Tray { M.Tray {
bar: bar bar: bar
visible: M.Modules.tray visible: M.Modules.tray
@ -59,7 +66,9 @@ PanelWindow {
Layout.maximumWidth: 400 Layout.maximumWidth: 400
visible: M.Modules.windowTitle visible: M.Modules.windowTitle
} }
Item { Layout.fillWidth: true } Item {
Layout.fillWidth: true
}
} }
// ---- right ---- // ---- right ----
@ -76,38 +85,59 @@ PanelWindow {
// Media // Media
M.BarGroup { M.BarGroup {
M.Mpris {} M.Mpris {}
M.Volume { visible: M.Modules.volume } M.Volume {
visible: M.Modules.volume
}
} }
// Connectivity // Connectivity
M.BarGroup { M.BarGroup {
M.Network { visible: M.Modules.network } M.Network {
visible: M.Modules.network
}
M.Bluetooth {} M.Bluetooth {}
} }
// Controls // Controls
M.BarGroup { M.BarGroup {
M.Backlight {} M.Backlight {}
M.PowerProfile { visible: M.Modules.powerProfile } M.PowerProfile {
M.IdleInhibitor { visible: M.Modules.idleInhibitor } visible: M.Modules.powerProfile
}
M.IdleInhibitor {
visible: M.Modules.idleInhibitor
}
} }
// System // System
M.BarGroup { M.BarGroup {
M.Cpu { visible: M.Modules.cpu } M.Cpu {
M.Memory { visible: M.Modules.memory } visible: M.Modules.cpu
M.Temperature { visible: M.Modules.temperature } }
M.Memory {
visible: M.Modules.memory
}
M.Temperature {
visible: M.Modules.temperature
}
} }
// Status // Status
M.BarGroup { M.BarGroup {
M.Weather { visible: M.Modules.weather } M.Weather {
M.Disk { visible: M.Modules.disk } visible: M.Modules.weather
}
M.Disk {
visible: M.Modules.disk
}
M.Battery {} M.Battery {}
} }
// Power // Power
M.Power { bar: bar; visible: M.Modules.power } M.Power {
bar: bar
visible: M.Modules.power
}
} }
} }
} }

View file

@ -17,10 +17,7 @@ M.BarSection {
readonly property var dev: UPower.displayDevice readonly property var dev: UPower.displayDevice
readonly property real pct: (dev?.percentage ?? 0) * 100 readonly property real pct: (dev?.percentage ?? 0) * 100
readonly property bool charging: dev?.state === UPowerDeviceState.Charging readonly property bool charging: dev?.state === UPowerDeviceState.Charging
readonly property color _stateColor: charging ? M.Theme.base0B readonly property color _stateColor: charging ? M.Theme.base0B : pct < 15 ? M.Theme.base08 : pct < 30 ? M.Theme.base09 : M.Theme.base0B
: pct < 15 ? M.Theme.base08
: pct < 30 ? M.Theme.base09
: M.Theme.base0B
M.BarIcon { M.BarIcon {
icon: { icon: {

View file

@ -7,8 +7,10 @@ M.BarSection {
spacing: M.Theme.moduleSpacing spacing: M.Theme.moduleSpacing
visible: M.Modules.bluetooth && root.state !== "unavailable" visible: M.Modules.bluetooth && root.state !== "unavailable"
tooltip: { tooltip: {
if (root.state === "off") return "Bluetooth: off"; if (root.state === "off")
if (root.state === "connected") return "Bluetooth: " + root.device; return "Bluetooth: off";
if (root.state === "connected")
return "Bluetooth: " + root.device;
return "Bluetooth: on"; return "Bluetooth: on";
} }
@ -18,20 +20,14 @@ M.BarSection {
function _parse(text) { function _parse(text) {
const t = text.trim(); const t = text.trim();
const sep = t.indexOf(":"); const sep = t.indexOf(":");
root.state = sep === -1 ? t : t.slice(0, sep); root.state = sep === -1 ? t : t.slice(0, sep);
root.device = sep === -1 ? "" : t.slice(sep + 1); root.device = sep === -1 ? "" : t.slice(sep + 1);
} }
Process { Process {
id: proc id: proc
running: true running: true
command: ["sh", "-c", command: ["sh", "-c", "s=$(bluetoothctl show 2>/dev/null); " + "[ -z \"$s\" ] && echo unavailable && exit; " + "echo \"$s\" | grep -q 'Powered: yes' || { echo off:; exit; }; " + "d=$(bluetoothctl info 2>/dev/null | awk -F': ' '/\\tName:/{n=$2}/Connected: yes/{c=1}END{if(c)print n}'); " + "[ -n \"$d\" ] && echo \"connected:$d\" || echo on:"]
"s=$(bluetoothctl show 2>/dev/null); " +
"[ -z \"$s\" ] && echo unavailable && exit; " +
"echo \"$s\" | grep -q 'Powered: yes' || { echo off:; exit; }; " +
"d=$(bluetoothctl info 2>/dev/null | awk -F': ' '/\\tName:/{n=$2}/Connected: yes/{c=1}END{if(c)print n}'); " +
"[ -n \"$d\" ] && echo \"connected:$d\" || echo on:"
]
stdout: StdioCollector { stdout: StdioCollector {
onStreamFinished: root._parse(text) onStreamFinished: root._parse(text)
} }
@ -47,14 +43,13 @@ M.BarSection {
id: toggle id: toggle
property string cmd: "" property string cmd: ""
command: ["bluetoothctl", "power", cmd] command: ["bluetoothctl", "power", cmd]
onRunningChanged: if (!running && cmd !== "") proc.running = true onRunningChanged: if (!running && cmd !== "")
proc.running = true
} }
M.BarIcon { M.BarIcon {
icon: "\uF294" icon: "\uF294"
color: root.state === "connected" ? M.Theme.base0D color: root.state === "connected" ? M.Theme.base0D : root.state === "off" ? M.Theme.base04 : M.Theme.base0D
: root.state === "off" ? M.Theme.base04
: M.Theme.base0D
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
M.BarLabel { M.BarLabel {

View file

@ -20,10 +20,7 @@ PanelWindow {
// Flush below bar, centered on hovered item // Flush below bar, centered on hovered item
margins.top: 0 margins.top: 0
margins.left: Math.max(0, Math.min( margins.left: Math.max(0, Math.min(Math.round(M.FlyoutState.itemX - implicitWidth / 2), screen.width - implicitWidth))
Math.round(M.FlyoutState.itemX - implicitWidth / 2),
screen.width - implicitWidth
))
implicitWidth: label.implicitWidth + M.Theme.barPadding * 2 implicitWidth: label.implicitWidth + M.Theme.barPadding * 2
implicitHeight: label.implicitHeight + M.Theme.barPadding * 2 implicitHeight: label.implicitHeight + M.Theme.barPadding * 2

View file

@ -10,7 +10,7 @@ PanelWindow {
required property var screen required property var screen
required property real anchorX required property real anchorX
signal menuClosed() signal menuClosed
signal runCommand(var cmd) signal runCommand(var cmd)
readonly property bool _isNiri: Quickshell.env("NIRI_SOCKET") !== "" readonly property bool _isNiri: Quickshell.env("NIRI_SOCKET") !== ""
@ -40,10 +40,7 @@ PanelWindow {
Item { Item {
id: panel id: panel
x: Math.max(0, Math.min( x: Math.max(0, Math.min(Math.round(menuWindow.anchorX - menuCol.width / 2), menuWindow.width - menuCol.width))
Math.round(menuWindow.anchorX - menuCol.width / 2),
menuWindow.width - menuCol.width
))
y: 0 y: 0
width: menuCol.width width: menuCol.width
@ -73,11 +70,36 @@ PanelWindow {
Repeater { Repeater {
model: [ model: [
{ label: "Lock", icon: "\uF023", cmd: ["loginctl", "lock-session"], color: M.Theme.base0D }, {
{ label: "Suspend", icon: "\uF186", cmd: ["systemctl", "suspend"], color: M.Theme.base0E }, label: "Lock",
{ label: "Logout", icon: "\uF2F5", cmd: menuWindow._isNiri ? ["niri", "msg", "action", "quit"] : ["loginctl", "terminate-user", ""], color: M.Theme.base0A }, icon: "\uF023",
{ label: "Reboot", icon: "\uF021", cmd: ["systemctl", "reboot"], color: M.Theme.base09 }, cmd: ["loginctl", "lock-session"],
{ label: "Shutdown", icon: "\uF011", cmd: ["systemctl", "poweroff"], color: M.Theme.base08 } color: M.Theme.base0D
},
{
label: "Suspend",
icon: "\uF186",
cmd: ["systemctl", "suspend"],
color: M.Theme.base0E
},
{
label: "Logout",
icon: "\uF2F5",
cmd: menuWindow._isNiri ? ["niri", "msg", "action", "quit"] : ["loginctl", "terminate-user", ""],
color: M.Theme.base0A
},
{
label: "Reboot",
icon: "\uF021",
cmd: ["systemctl", "reboot"],
color: M.Theme.base09
},
{
label: "Shutdown",
icon: "\uF011",
cmd: ["systemctl", "poweroff"],
color: M.Theme.base08
}
] ]
delegate: Item { delegate: Item {

View file

@ -8,9 +8,7 @@ M.BarIcon {
property string profile: "" property string profile: ""
color: root.profile === "performance" ? M.Theme.base09 color: root.profile === "performance" ? M.Theme.base09 : root.profile === "power-saver" ? M.Theme.base0B : M.Theme.base05
: root.profile === "power-saver" ? M.Theme.base0B
: M.Theme.base05
icon: { icon: {
if (root.profile === "performance") if (root.profile === "performance")

View file

@ -70,8 +70,24 @@ Item {
} }
} }
Corner { corner: 0; anchors.top: true; anchors.left: true } Corner {
Corner { corner: 1; anchors.top: true; anchors.right: true } corner: 0
Corner { corner: 2; anchors.bottom: true; anchors.left: true } anchors.top: true
Corner { corner: 3; anchors.bottom: true; anchors.right: true } anchors.left: true
}
Corner {
corner: 1
anchors.top: true
anchors.right: true
}
Corner {
corner: 2
anchors.bottom: true
anchors.left: true
}
Corner {
corner: 3
anchors.bottom: true
anchors.right: true
}
} }

View file

@ -8,9 +8,7 @@ M.BarSection {
tooltip: "Temperature: " + root.celsius + "\u00B0C" tooltip: "Temperature: " + root.celsius + "\u00B0C"
property int celsius: 0 property int celsius: 0
readonly property color _stateColor: celsius > 80 ? M.Theme.base08 readonly property color _stateColor: celsius > 80 ? M.Theme.base08 : celsius > 60 ? M.Theme.base09 : M.Theme.base0C
: celsius > 60 ? M.Theme.base09
: M.Theme.base0C
FileView { FileView {
id: thermal id: thermal

View file

@ -30,8 +30,7 @@ RowLayout {
HoverHandler { HoverHandler {
onHoveredChanged: { onHoveredChanged: {
const tip = [iconItem.modelData.tooltipTitle, iconItem.modelData.tooltipDescription] const tip = [iconItem.modelData.tooltipTitle, iconItem.modelData.tooltipDescription].filter(s => s).join("\n") || iconItem.modelData.title;
.filter(s => s).join("\n") || iconItem.modelData.title;
if (hovered && tip) { if (hovered && tip) {
M.FlyoutState.text = tip; M.FlyoutState.text = tip;
M.FlyoutState.itemX = iconItem.mapToGlobal(iconItem.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0); M.FlyoutState.itemX = iconItem.mapToGlobal(iconItem.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0);

View file

@ -13,7 +13,7 @@ PanelWindow {
required property var screen required property var screen
required property real anchorX required property real anchorX
signal menuClosed() signal menuClosed
// Current menu level swapped when entering/leaving submenus // Current menu level swapped when entering/leaving submenus
property var _currentHandle: handle property var _currentHandle: handle
@ -41,10 +41,7 @@ PanelWindow {
Item { Item {
id: panel id: panel
x: Math.max(0, Math.min( x: Math.max(0, Math.min(Math.round(menuWindow.anchorX - menuCol.width / 2), menuWindow.width - menuCol.width))
Math.round(menuWindow.anchorX - menuCol.width / 2),
menuWindow.width - menuCol.width
))
y: 0 y: 0
width: menuCol.width width: menuCol.width
@ -143,8 +140,7 @@ PanelWindow {
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: 4 anchors.leftMargin: 4
anchors.rightMargin: 4 anchors.rightMargin: 4
color: rowArea.containsMouse && entryItem.modelData.enabled color: rowArea.containsMouse && entryItem.modelData.enabled ? M.Theme.base02 : "transparent"
? M.Theme.base02 : "transparent"
radius: M.Theme.radius radius: M.Theme.radius
} }

View file

@ -14,7 +14,8 @@ M.BarSection {
property string _title: "" property string _title: ""
property string _appId: "" property string _appId: ""
readonly property string _iconSource: { readonly property string _iconSource: {
if (!root._appId) return ""; if (!root._appId)
return "";
const entry = DesktopEntries.heuristicLookup(root._appId); const entry = DesktopEntries.heuristicLookup(root._appId);
return entry ? Quickshell.iconPath(entry.icon) : ""; return entry ? Quickshell.iconPath(entry.icon) : "";
} }

View file

@ -44,8 +44,7 @@ Row {
try { try {
const ev = JSON.parse(line); const ev = JSON.parse(line);
if (ev.WorkspacesChanged !== undefined) { if (ev.WorkspacesChanged !== undefined) {
root._allWorkspaces = ev.WorkspacesChanged.workspaces root._allWorkspaces = ev.WorkspacesChanged.workspaces.sort((a, b) => a.idx - b.idx);
.sort((a, b) => a.idx - b.idx);
} else if (ev.WorkspaceActivated !== undefined) { } else if (ev.WorkspaceActivated !== undefined) {
if (ev.WorkspaceActivated.focused) if (ev.WorkspaceActivated.focused)
root._activeId = ev.WorkspaceActivated.id; root._activeId = ev.WorkspaceActivated.id;

View file

@ -56,33 +56,37 @@ in
description = "Enable or disable individual bar modules."; description = "Enable or disable individual bar modules.";
default = { }; default = { };
type = lib.types.submodule { type = lib.types.submodule {
options = lib.genAttrs options =
[ lib.genAttrs
"workspaces" [
"tray" "workspaces"
"windowTitle" "tray"
"clock" "windowTitle"
"notifications" "clock"
"mpris" "notifications"
"volume" "mpris"
"bluetooth" "volume"
"backlight" "bluetooth"
"network" "backlight"
"powerProfile" "network"
"idleInhibitor" "powerProfile"
"weather" "idleInhibitor"
"temperature" "weather"
"cpu" "temperature"
"memory" "cpu"
"disk" "memory"
"battery" "disk"
"power" "battery"
] "power"
(name: lib.mkOption { ]
type = lib.types.bool; (
default = true; name:
description = "Enable the ${name} module."; lib.mkOption {
}); type = lib.types.bool;
default = true;
description = "Enable the ${name} module.";
}
);
}; };
}; };
@ -123,12 +127,11 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = home.packages = [
[ self.packages.${pkgs.stdenv.hostPlatform.system}.nova-shell-cli
self.packages.${pkgs.stdenv.hostPlatform.system}.nova-shell-cli pkgs.nerd-fonts.symbols-only
pkgs.nerd-fonts.symbols-only ]
] ++ lib.optional cfg.modules.weather pkgs.wttrbar;
++ lib.optional cfg.modules.weather pkgs.wttrbar;
xdg.configFile."nova-shell/modules.json".source = xdg.configFile."nova-shell/modules.json".source =
(pkgs.formats.json { }).generate "nova-shell-modules.json" (pkgs.formats.json { }).generate "nova-shell-modules.json"