my over complex system configurations dotfiles.isabelroses.com/
nixos nix flake dotfiles linux
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

isabel/quickshell: osd should only show on the active screen

isabel af3e73a5 2c921d5f

+199 -206
+199 -206
home/isabel/gui/quickshell/modules/Osd.qml
··· 9 9 import "root:/services" 10 10 11 11 Scope { 12 - id: root 12 + id: root 13 13 14 - // OSD State 15 - property string osdType: "" 16 - property real progress: 0 17 - property string iconSource: "" 18 - property string osdText: "" 19 - property bool osdVisible: false 14 + // OSD State 15 + property string osdType: "" 16 + property real progress: 0 17 + property string iconSource: "" 18 + property string osdText: "" 19 + property bool osdVisible: false 20 20 21 - // Notification State 22 - property var currentNotification: null 23 - property bool notificationVisible: false 21 + // Notification State 22 + property var currentNotification: null 23 + property bool notificationVisible: false 24 24 25 - // Connect to Pipewire service for volume changes 26 - Connections { 27 - target: Pipewire 28 - function onSinkVolumeChanged() { showVolumeOsd(); } 29 - function onSinkMutedChanged() { showVolumeOsd(); } 30 - } 25 + // Connect to Pipewire service for volume changes 26 + Connections { 27 + target: Pipewire 28 + function onSinkVolumeChanged() { showVolumeOsd(); } 29 + function onSinkMutedChanged() { showVolumeOsd(); } 30 + } 31 31 32 - function showVolumeOsd(): void { 33 - root.osdType = "volume"; 34 - root.progress = Pipewire.sinkVolume; 35 - root.iconSource = Pipewire.sinkIcon; 36 - root.osdText = Pipewire.sinkVolumeText; 37 - root.osdVisible = true; 38 - osdHideTimer.restart(); 39 - } 32 + function showVolumeOsd(): void { 33 + root.osdType = "volume"; 34 + root.progress = Pipewire.sinkVolume; 35 + root.iconSource = Pipewire.sinkIcon; 36 + root.osdText = Pipewire.sinkVolumeText; 37 + root.osdVisible = true; 38 + osdHideTimer.restart(); 39 + } 40 40 41 - function showNotification(notification: QsNotifications.Notification): void { 42 - root.currentNotification = notification; 43 - root.notificationVisible = true; 44 - notificationHideTimer.restart(); 45 - } 41 + function showNotification(notification: QsNotifications.Notification): void { 42 + root.currentNotification = notification; 43 + root.notificationVisible = true; 44 + notificationHideTimer.restart(); 45 + } 46 46 47 - Timer { 48 - id: osdHideTimer 49 - interval: 1500 50 - onTriggered: root.osdVisible = false 51 - } 47 + Timer { 48 + id: osdHideTimer 49 + interval: 1500 50 + onTriggered: root.osdVisible = false 51 + } 52 52 53 - Timer { 54 - id: notificationHideTimer 55 - interval: 4000 56 - onTriggered: root.notificationVisible = false 57 - } 53 + Timer { 54 + id: notificationHideTimer 55 + interval: 4000 56 + onTriggered: root.notificationVisible = false 57 + } 58 58 59 - // Connect to the shared notification service 60 - Connections { 61 - target: Notifications 62 - function onNewNotification(notification) { 63 - root.showNotification(notification); 64 - } 59 + // Connect to the shared notification service 60 + Connections { 61 + target: Notifications 62 + function onNewNotification(notification) { 63 + root.showNotification(notification); 65 64 } 65 + } 66 66 67 - Variants { 68 - model: Quickshell.screens 69 67 70 - PanelWindow { 71 - id: osdWindow 72 - property var modelData 73 - screen: modelData 68 + PanelWindow { 69 + id: osdWindow 70 + property var modelData 71 + screen: modelData 74 72 75 - visible: root.osdVisible 76 - color: "transparent" 73 + visible: root.osdVisible 74 + color: "transparent" 77 75 78 - WlrLayershell.namespace: "osd" 79 - WlrLayershell.layer: WlrLayer.Overlay 80 - exclusionMode: ExclusionMode.Ignore 76 + WlrLayershell.namespace: "osd" 77 + WlrLayershell.layer: WlrLayer.Overlay 78 + exclusionMode: ExclusionMode.Ignore 81 79 82 - anchors { 83 - bottom: true 84 - } 80 + anchors { 81 + bottom: true 82 + } 85 83 86 - implicitWidth: 320 87 - implicitHeight: 80 84 + implicitWidth: 320 85 + implicitHeight: 80 88 86 89 - margins { 90 - bottom: 80 91 - } 87 + margins { 88 + bottom: 80 89 + } 92 90 93 - Rectangle { 94 - id: osdContainer 95 - anchors.centerIn: parent 96 - width: 300 97 - height: 56 98 - radius: 14 99 - color: Settings.colors.background 91 + Rectangle { 92 + id: osdContainer 93 + anchors.centerIn: parent 94 + width: 300 95 + height: 56 96 + radius: 14 97 + color: Settings.colors.background 100 98 101 - RowLayout { 102 - anchors { 103 - fill: parent 104 - leftMargin: 18 105 - rightMargin: 18 106 - } 107 - spacing: 14 99 + RowLayout { 100 + anchors { 101 + fill: parent 102 + leftMargin: 18 103 + rightMargin: 18 104 + } 105 + spacing: 14 108 106 109 - MyIcon { 110 - icon: root.iconSource 111 - size: 22 112 - Layout.alignment: Qt.AlignVCenter 113 - } 107 + MyIcon { 108 + icon: root.iconSource 109 + size: 22 110 + Layout.alignment: Qt.AlignVCenter 111 + } 114 112 115 - Rectangle { 116 - Layout.fillWidth: true 117 - Layout.preferredHeight: 6 118 - Layout.alignment: Qt.AlignVCenter 119 - radius: 3 120 - color: Settings.colors.backgroundLighter 113 + Rectangle { 114 + Layout.fillWidth: true 115 + Layout.preferredHeight: 6 116 + Layout.alignment: Qt.AlignVCenter 117 + radius: 3 118 + color: Settings.colors.backgroundLighter 121 119 122 - Rectangle { 123 - width: parent.width * Math.min(root.progress, 1.0) 124 - height: parent.height 125 - radius: 3 126 - color: root.muted ? Settings.colors.error : Settings.colors.accent 120 + Rectangle { 121 + width: parent.width * Math.min(root.progress, 1.0) 122 + height: parent.height 123 + radius: 3 124 + color: root.muted ? Settings.colors.error : Settings.colors.accent 127 125 128 - Behavior on width { 129 - SmoothedAnimation { velocity: 600 } 130 - } 131 - } 132 - } 126 + Behavior on width { 127 + SmoothedAnimation { velocity: 600 } 128 + } 129 + } 130 + } 133 131 134 - Text { 135 - text: root.osdText 136 - color: Settings.colors.foreground 137 - font { 138 - pixelSize: 13 139 - weight: Font.Medium 140 - } 141 - Layout.preferredWidth: 40 142 - Layout.alignment: Qt.AlignVCenter 143 - horizontalAlignment: Text.AlignRight 144 - } 145 - } 146 - } 132 + Text { 133 + text: root.osdText 134 + color: Settings.colors.foreground 135 + font { 136 + pixelSize: 13 137 + weight: Font.Medium 138 + } 139 + Layout.preferredWidth: 40 140 + Layout.alignment: Qt.AlignVCenter 141 + horizontalAlignment: Text.AlignRight 147 142 } 143 + } 148 144 } 145 + } 149 146 150 - // Notification Popup 151 - Variants { 152 - model: Quickshell.screens 147 + // Notification Popup 148 + PanelWindow { 149 + id: notificationWindow 150 + property var modelData 151 + screen: modelData 153 152 154 - PanelWindow { 155 - id: notificationWindow 156 - property var modelData 157 - screen: modelData 153 + visible: root.notificationVisible && root.currentNotification !== null 154 + color: "transparent" 158 155 159 - visible: root.notificationVisible && root.currentNotification !== null 160 - color: "transparent" 156 + WlrLayershell.namespace: "notification" 157 + WlrLayershell.layer: WlrLayer.Overlay 158 + exclusionMode: ExclusionMode.Ignore 161 159 162 - WlrLayershell.namespace: "notification" 163 - WlrLayershell.layer: WlrLayer.Overlay 164 - exclusionMode: ExclusionMode.Ignore 160 + anchors { 161 + top: true 162 + } 165 163 166 - anchors { 167 - top: true 168 - } 164 + implicitWidth: 420 165 + implicitHeight: 100 169 166 170 - implicitWidth: 420 171 - implicitHeight: 100 167 + margins { 168 + top: 16 169 + } 172 170 173 - margins { 174 - top: 16 175 - } 176 - 177 - Rectangle { 178 - id: notificationContainer 179 - anchors { 180 - fill: parent 181 - margins: 8 182 - } 183 - radius: 12 184 - color: Settings.colors.background 185 - 186 - RowLayout { 187 - anchors { 188 - fill: parent 189 - margins: 14 190 - } 191 - spacing: 12 171 + Rectangle { 172 + id: notificationContainer 173 + anchors { 174 + fill: parent 175 + margins: 8 176 + } 177 + radius: 12 178 + color: Settings.colors.background 192 179 193 - IconImage { 194 - source: Quickshell.iconPath(root.currentNotification?.appIcon ? Utils.getIcon(root.currentNotification.appIcon) : "application-x-executable") 195 - implicitSize: 40 196 - Layout.alignment: Qt.AlignTop 197 - } 180 + RowLayout { 181 + anchors { 182 + fill: parent 183 + margins: 14 184 + } 185 + spacing: 12 198 186 199 - ColumnLayout { 200 - Layout.fillWidth: true 201 - Layout.fillHeight: true 202 - spacing: 4 187 + IconImage { 188 + source: Quickshell.iconPath(root.currentNotification?.appIcon ? Utils.getIcon(root.currentNotification.appIcon) : "application-x-executable") 189 + implicitSize: 40 190 + Layout.alignment: Qt.AlignTop 191 + } 203 192 204 - Text { 205 - text: root.currentNotification?.appName ?? "" 206 - color: Settings.colors.foreground 207 - font { 208 - pixelSize: 13 209 - weight: Font.Bold 210 - } 211 - elide: Text.ElideRight 212 - Layout.fillWidth: true 213 - } 193 + ColumnLayout { 194 + Layout.fillWidth: true 195 + Layout.fillHeight: true 196 + spacing: 4 214 197 215 - Text { 216 - text: root.currentNotification?.summary ?? "" 217 - color: Settings.colors.foreground 218 - font { 219 - pixelSize: 12 220 - weight: Font.Medium 221 - } 222 - elide: Text.ElideRight 223 - Layout.fillWidth: true 224 - visible: text !== "" 225 - } 198 + Text { 199 + text: root.currentNotification?.appName ?? "" 200 + color: Settings.colors.foreground 201 + font { 202 + pixelSize: 13 203 + weight: Font.Bold 204 + } 205 + elide: Text.ElideRight 206 + Layout.fillWidth: true 207 + } 226 208 227 - Text { 228 - text: root.currentNotification?.body ?? "" 229 - color: Settings.colors.foreground 230 - opacity: 0.8 231 - font.pixelSize: 11 232 - elide: Text.ElideRight 233 - wrapMode: Text.WordWrap 234 - maximumLineCount: 2 235 - Layout.fillWidth: true 236 - } 237 - } 209 + Text { 210 + text: root.currentNotification?.summary ?? "" 211 + color: Settings.colors.foreground 212 + font { 213 + pixelSize: 12 214 + weight: Font.Medium 215 + } 216 + elide: Text.ElideRight 217 + Layout.fillWidth: true 218 + visible: text !== "" 219 + } 238 220 239 - IconButton { 240 - icon: "window-close-symbolic" 241 - size: 14 242 - Layout.alignment: Qt.AlignTop 243 - onClicked: { 244 - root.currentNotification?.dismiss(); 245 - root.notificationVisible = false; 246 - } 247 - } 248 - } 221 + Text { 222 + text: root.currentNotification?.body ?? "" 223 + color: Settings.colors.foreground 224 + opacity: 0.8 225 + font.pixelSize: 11 226 + elide: Text.ElideRight 227 + wrapMode: Text.WordWrap 228 + maximumLineCount: 2 229 + Layout.fillWidth: true 230 + } 231 + } 249 232 250 - // Click to dismiss 251 - MouseArea { 252 - anchors.fill: parent 253 - z: -1 254 - onClicked: root.notificationVisible = false 255 - } 256 - } 233 + IconButton { 234 + icon: "window-close-symbolic" 235 + size: 14 236 + Layout.alignment: Qt.AlignTop 237 + onClicked: { 238 + root.currentNotification?.dismiss(); 239 + root.notificationVisible = false; 240 + } 257 241 } 242 + } 243 + 244 + // Click to dismiss 245 + MouseArea { 246 + anchors.fill: parent 247 + z: -1 248 + onClicked: root.notificationVisible = false 249 + } 258 250 } 251 + } 259 252 }