diff --git a/.config/quickshell/modules/bar/ActiveWindow.qml b/.config/quickshell/modules/bar/ActiveWindow.qml index d51381580..3a23182ac 100644 --- a/.config/quickshell/modules/bar/ActiveWindow.qml +++ b/.config/quickshell/modules/bar/ActiveWindow.qml @@ -9,6 +9,7 @@ Rectangle { required property var bar readonly property HyprlandMonitor monitor: Hyprland.monitorFor(bar.screen) readonly property Toplevel activeWindow: ToplevelManager.activeToplevel + property int preferredWidth: 400 height: parent.height width: colLayout.width @@ -25,13 +26,17 @@ Rectangle { StyledText { font.pointSize: Appearance.font.pointSize.smaller color: Appearance.colors.colSubtext - text: activeWindow.activated ? activeWindow?.appId : "Desktop" + Layout.preferredWidth: preferredWidth + elide: Text.ElideRight + text: activeWindow?.activated ? activeWindow?.appId : "Desktop" } StyledText { font.pointSize: Appearance.font.pointSize.small color: Appearance.colors.colOnLayer0 - text: activeWindow.activated ? activeWindow?.title : `Workspace ${monitor.activeWorkspace?.id}` + Layout.preferredWidth: preferredWidth + elide: Text.ElideRight + text: activeWindow?.activated ? activeWindow?.title : `Workspace ${monitor.activeWorkspace?.id}` } } diff --git a/.config/quickshell/modules/bar/Bar.qml b/.config/quickshell/modules/bar/Bar.qml index 5289f42c8..3cb2ce7c8 100644 --- a/.config/quickshell/modules/bar/Bar.qml +++ b/.config/quickshell/modules/bar/Bar.qml @@ -30,6 +30,17 @@ Scope { ActiveWindow { bar: barRoot } + // Scroll to switch workspaces + + WheelHandler { + onWheel: (event) => { + if (event.angleDelta.y < 0) + Brightness.value = -1; + else if (event.angleDelta.y > 0) + Brightness.value = 1; + } + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad + } } diff --git a/.config/quickshell/modules/common/Brightness.qml b/.config/quickshell/modules/common/Brightness.qml new file mode 100644 index 000000000..57ad389d3 --- /dev/null +++ b/.config/quickshell/modules/common/Brightness.qml @@ -0,0 +1,63 @@ +import Quickshell +import Quickshell.Io +pragma Singleton + +Singleton { + id: root + + property string brightness + property int value: 0 + + function refresh() { + getBrightness.running = true; + } + + onValueChanged: () => { + if (value > 0) { + increaseBrightness.running = true; + root.value = 0; + } else if (value < 0) { + decreaseBrightness.running = true; + root.value = 0; + } + getBrightness.running = true; + } + + Process { + id: getBrightness + + command: ["sh", "-c", "brightnessctl -m i | cut -d, -f4"] + running: true + onExited: { + running = false; + } + + stdout: SplitParser { + onRead: (data) => { + root.brightness = data; + } + } + + } + + Process { + id: decreaseBrightness + + command: ["brightnessctl", "set", "5%-"] + running: false + onExited: { + running = false; + } + } + + Process { + id: increaseBrightness + + command: ["brightnessctl", "set", "5%+"] + running: false + onExited: { + running = false; + } + } + +}