| 1 | import QtQuick |
| 2 | import QtQuick.Layouts |
| 3 | import Quickshell |
| 4 | import Quickshell.Bluetooth |
| 5 | import Quickshell.Services.Pipewire |
| 6 | |
| 7 | ColumnLayout { |
| 8 | id: page |
| 9 | spacing: 10 |
| 10 | signal closeRequested() |
| 11 | signal overlayRequested(string name) |
| 12 | |
| 13 | property string armed: "" |
| 14 | Timer { id: disarm; interval: 3000; onTriggered: page.armed = "" } |
| 15 | |
| 16 | function act(name, fn, confirm) { |
| 17 | if (confirm && armed !== name) { armed = name; disarm.restart(); return } |
| 18 | armed = "" |
| 19 | fn() |
| 20 | closeRequested() |
| 21 | } |
| 22 | |
| 23 | Timer { |
| 24 | interval: 3000 |
| 25 | running: page.visible |
| 26 | repeat: true |
| 27 | onTriggered: Bright.refresh() |
| 28 | } |
| 29 | |
| 30 | MediaCard { Layout.fillWidth: true } |
| 31 | |
| 32 | SectionLabel { text: "levels" } |
| 33 | |
| 34 | SliderRow { |
| 35 | Layout.fillWidth: true |
| 36 | readonly property var audio: Pipewire.defaultAudioSink ? Pipewire.defaultAudioSink.audio : null |
| 37 | icon: Theme.volIcon(audio ? audio.volume : 0, audio ? audio.muted : true) |
| 38 | value: audio ? audio.volume : 0 |
| 39 | muted: audio ? audio.muted : false |
| 40 | onMoved: v => { if (audio) audio.volume = v } |
| 41 | onIconClicked: if (audio) audio.muted = !audio.muted |
| 42 | } |
| 43 | SliderRow { |
| 44 | Layout.fillWidth: true |
| 45 | readonly property var audio: Pipewire.defaultAudioSource ? Pipewire.defaultAudioSource.audio : null |
| 46 | icon: audio && !audio.muted ? Theme.iMic : Theme.iMicOff |
| 47 | value: audio ? audio.volume : 0 |
| 48 | muted: audio ? audio.muted : false |
| 49 | onMoved: v => { if (audio) audio.volume = v } |
| 50 | onIconClicked: if (audio) audio.muted = !audio.muted |
| 51 | } |
| 52 | SliderRow { |
| 53 | Layout.fillWidth: true |
| 54 | visible: Bright.available |
| 55 | icon: Theme.iBright |
| 56 | value: Bright.percent / 100 |
| 57 | valueText: Bright.percent + "%" |
| 58 | onMoved: v => Bright.setPercent(Math.max(0.01, v) * 100) |
| 59 | } |
| 60 | |
| 61 | SectionLabel { text: "quick toggles" } |
| 62 | |
| 63 | RowLayout { |
| 64 | Layout.fillWidth: true |
| 65 | spacing: 6 |
| 66 | IconBtn { |
| 67 | Layout.fillWidth: true |
| 68 | icon: Net.wifiEnabled ? Theme.iWifi : Theme.iWifiOff |
| 69 | label: "wifi" |
| 70 | active: Net.wifiEnabled |
| 71 | onClicked: Net.setWifi(!Net.wifiEnabled) |
| 72 | } |
| 73 | IconBtn { |
| 74 | Layout.fillWidth: true |
| 75 | readonly property var ad: Bluetooth.defaultAdapter |
| 76 | visible: ad !== null |
| 77 | icon: ad && ad.enabled ? Theme.iBt : Theme.iBtOff |
| 78 | label: "bt" |
| 79 | active: ad ? ad.enabled : false |
| 80 | onClicked: if (ad) ad.enabled = !ad.enabled |
| 81 | } |
| 82 | IconBtn { |
| 83 | Layout.fillWidth: true |
| 84 | icon: Notifs.dnd ? Theme.iBellOff : Theme.iBell |
| 85 | label: "dnd" |
| 86 | active: Notifs.dnd |
| 87 | onClicked: Notifs.dnd = !Notifs.dnd |
| 88 | } |
| 89 | IconBtn { |
| 90 | Layout.fillWidth: true |
| 91 | readonly property var audio: Pipewire.defaultAudioSource ? Pipewire.defaultAudioSource.audio : null |
| 92 | icon: audio && audio.muted ? Theme.iMicOff : Theme.iMic |
| 93 | label: "mic" |
| 94 | active: audio ? !audio.muted : false |
| 95 | onClicked: if (audio) audio.muted = !audio.muted |
| 96 | } |
| 97 | } |
| 98 | RowLayout { |
| 99 | Layout.fillWidth: true |
| 100 | spacing: 6 |
| 101 | IconBtn { |
| 102 | Layout.fillWidth: true |
| 103 | icon: Theme.iCoffee |
| 104 | label: "caffeine" |
| 105 | active: Toggles.caffeine |
| 106 | onClicked: Toggles.caffeine = !Toggles.caffeine |
| 107 | } |
| 108 | IconBtn { |
| 109 | Layout.fillWidth: true |
| 110 | icon: Theme.iPlane |
| 111 | label: "airplane" |
| 112 | active: Toggles.airplane |
| 113 | onClicked: Toggles.setAirplane(!Toggles.airplane) |
| 114 | } |
| 115 | IconBtn { |
| 116 | Layout.fillWidth: true |
| 117 | visible: Toggles.hasPicker |
| 118 | icon: Theme.iPicker |
| 119 | label: "colour" |
| 120 | onClicked: { page.closeRequested(); Toggles.pickColour() } |
| 121 | } |
| 122 | IconBtn { // click: record the focused monitor; while recording: stop |
| 123 | Layout.fillWidth: true |
| 124 | visible: Rec.available |
| 125 | icon: Rec.busy ? Theme.iStop : Theme.iRec |
| 126 | label: Rec.running ? Theme.fmtClock(Rec.elapsed) : "rec" |
| 127 | active: Rec.busy |
| 128 | onClicked: { if (!Rec.busy) page.closeRequested(); Rec.toggle("screen") } |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | SectionLabel { text: "desktop" } |
| 133 | |
| 134 | RowLayout { |
| 135 | Layout.fillWidth: true |
| 136 | spacing: 6 |
| 137 | IconBtn { |
| 138 | Layout.fillWidth: true |
| 139 | icon: Theme.iImage |
| 140 | label: "wallpaper" |
| 141 | onClicked: page.overlayRequested("wall") |
| 142 | } |
| 143 | IconBtn { |
| 144 | Layout.fillWidth: true |
| 145 | icon: Theme.iShuffle |
| 146 | label: "random" |
| 147 | onClicked: Wall.random() |
| 148 | } |
| 149 | IconBtn { |
| 150 | Layout.fillWidth: true |
| 151 | icon: Theme.iWindow |
| 152 | label: "overview" |
| 153 | onClicked: page.overlayRequested("overview") |
| 154 | } |
| 155 | IconBtn { |
| 156 | Layout.fillWidth: true |
| 157 | visible: Clip.available |
| 158 | icon: Theme.iClipboard |
| 159 | label: "clipboard" |
| 160 | onClicked: page.overlayRequested("clip") |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | SectionLabel { text: "capture" } |
| 165 | |
| 166 | RowLayout { |
| 167 | Layout.fillWidth: true |
| 168 | spacing: 6 |
| 169 | IconBtn { // where the shot goes: clipboard or ~/pix/ss |
| 170 | Layout.fillWidth: true |
| 171 | icon: Shot.save ? Theme.iSave : Theme.iClipboard |
| 172 | label: Shot.save ? "save" : "copy" |
| 173 | active: true |
| 174 | onClicked: Shot.save = !Shot.save |
| 175 | } |
| 176 | IconBtn { |
| 177 | Layout.fillWidth: true |
| 178 | icon: Theme.iCrop |
| 179 | label: "area" |
| 180 | onClicked: { page.closeRequested(); Shot.take("region") } |
| 181 | } |
| 182 | IconBtn { |
| 183 | Layout.fillWidth: true |
| 184 | icon: Theme.iWindow |
| 185 | label: "window" |
| 186 | onClicked: { page.closeRequested(); Shot.take("window") } |
| 187 | } |
| 188 | IconBtn { |
| 189 | Layout.fillWidth: true |
| 190 | icon: Theme.iMonitor |
| 191 | label: "screen" |
| 192 | onClicked: { page.closeRequested(); Shot.take("output") } |
| 193 | } |
| 194 | IconBtn { |
| 195 | Layout.fillWidth: true |
| 196 | icon: Theme.iSearch |
| 197 | label: "ocr" |
| 198 | onClicked: { page.closeRequested(); Shot.take("ocr") } |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | Item { Layout.fillHeight: true } |
| 203 | |
| 204 | SectionLabel { text: "session" } |
| 205 | |
| 206 | RowLayout { |
| 207 | Layout.fillWidth: true |
| 208 | spacing: 6 |
| 209 | IconBtn { |
| 210 | Layout.fillWidth: true |
| 211 | icon: Theme.iLock |
| 212 | onClicked: page.act("lock", function () { Quickshell.execDetached(["loginctl", "lock-session"]) }, false) |
| 213 | } |
| 214 | IconBtn { |
| 215 | Layout.fillWidth: true |
| 216 | icon: Theme.iSleep |
| 217 | onClicked: page.act("sleep", function () { Quickshell.execDetached(["systemctl", "suspend"]) }, false) |
| 218 | } |
| 219 | IconBtn { |
| 220 | Layout.fillWidth: true |
| 221 | icon: Theme.iLogout |
| 222 | label: page.armed === "logout" ? "sure?" : "" |
| 223 | active: page.armed === "logout" |
| 224 | onClicked: page.act("logout", function () { Hypr.logout() }, true) |
| 225 | } |
| 226 | IconBtn { |
| 227 | Layout.fillWidth: true |
| 228 | icon: Theme.iReboot |
| 229 | label: page.armed === "reboot" ? "sure?" : "" |
| 230 | active: page.armed === "reboot" |
| 231 | onClicked: page.act("reboot", function () { Quickshell.execDetached(["systemctl", "reboot"]) }, true) |
| 232 | } |
| 233 | IconBtn { |
| 234 | Layout.fillWidth: true |
| 235 | icon: Theme.iPower |
| 236 | label: page.armed === "off" ? "sure?" : "" |
| 237 | active: page.armed === "off" |
| 238 | onClicked: page.act("off", function () { Quickshell.execDetached(["systemctl", "poweroff"]) }, true) |
| 239 | } |
| 240 | } |
| 241 | } |