add lockscreen support
This commit is contained in:
parent
c5050f9f5f
commit
79d36e01be
11 changed files with 752 additions and 389 deletions
10
README.md
10
README.md
|
|
@ -22,6 +22,10 @@ It's also the notification server. New notifications pop up under the bar for a
|
|||
until you dismiss them if they're urgent. Swipe one up to put it away early. Swipe a notification
|
||||
sideways to dismiss it, in the sheet or as a popup, and tap it to open it.
|
||||
|
||||
And it's the lockscreen. It locks as soon as it starts, when logind asks it to (before
|
||||
suspending, or with `loginctl lock-session`), and with `qs ipc call lock lock`. The lockscreen
|
||||
has the clock, a password field and your notifications.
|
||||
|
||||
## Using it
|
||||
|
||||
The flake has a `quadshell` package, and an overlay that adds it to nixpkgs:
|
||||
|
|
@ -36,11 +40,17 @@ Then start it with niri, in your niri config:
|
|||
spawn-at-startup "quadshell"
|
||||
```
|
||||
|
||||
To have your wallpaper blurred behind the lockscreen, use
|
||||
`pkgs.quadshell.override { wallpaper = ./background.jpg; }`. It sets `QUADSHELL_WALLPAPER`,
|
||||
which you can also set yourself, or before `nix run .#phone` to a path on the phone.
|
||||
|
||||
It brings `nmcli`, `mmcli`, `nmgui` and `adw-bluetooth` with it. The system needs:
|
||||
|
||||
- niri, NetworkManager and ModemManager running
|
||||
- systemd-logind, which the flashlight uses to set the LED without root
|
||||
- The `login` PAM service, which checks the lockscreen's password
|
||||
- The Papirus-Dark icon theme and the Inter font
|
||||
- An on-screen keyboard that uses text-input-v3, like Stevia, to type the password
|
||||
- No other notification daemon, like swaync or mako, as only one can run at a time
|
||||
|
||||
## Developing
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@
|
|||
exec ssh -t "$host" "
|
||||
nix-store --realise ${builtins.dirOf (builtins.dirOf quickshell)} >/dev/null;
|
||||
pkill -f '^/nix/store/[^ ]*/bin/quickshell ';
|
||||
exec systemd-run --user --pty --quiet --collect ${quickshell} --path ~/$dest
|
||||
exec systemd-run --user --pty --quiet --collect \
|
||||
''${QUADSHELL_WALLPAPER:+--setenv=QUADSHELL_WALLPAPER=$QUADSHELL_WALLPAPER} \
|
||||
${quickshell} --path ~/$dest
|
||||
"
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
lib,
|
||||
quickshell,
|
||||
writeShellApplication,
|
||||
glib,
|
||||
networkmanager,
|
||||
modemmanager,
|
||||
nmgui,
|
||||
|
|
@ -9,6 +10,8 @@
|
|||
coreutils,
|
||||
gawk,
|
||||
gnugrep,
|
||||
# Blurred behind the lockscreen
|
||||
wallpaper ? null,
|
||||
}:
|
||||
let
|
||||
config = lib.fileset.toSource {
|
||||
|
|
@ -27,9 +30,11 @@ writeShellApplication {
|
|||
coreutils
|
||||
gawk
|
||||
gnugrep
|
||||
glib # gdbus, for logind's lock signal
|
||||
];
|
||||
|
||||
text = ''
|
||||
${lib.optionalString (wallpaper != null) "export QUADSHELL_WALLPAPER=${wallpaper}"}
|
||||
exec ${lib.getExe quickshell} --path ${config} "$@"
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
104
src/Lock.qml
Normal file
104
src/Lock.qml
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Services.Pam
|
||||
|
||||
Scope {
|
||||
id: root
|
||||
|
||||
readonly property bool checking: pam.active
|
||||
property string error: ""
|
||||
property string password
|
||||
property string sessionPath
|
||||
|
||||
signal failed
|
||||
|
||||
function lock() {
|
||||
session.locked = true;
|
||||
}
|
||||
|
||||
function unlock(password) {
|
||||
if (pam.active || password === "") return;
|
||||
root.password = password;
|
||||
error = "";
|
||||
pam.start();
|
||||
}
|
||||
|
||||
function setLockedHint() {
|
||||
if (sessionPath === "") return;
|
||||
Quickshell.execDetached(["busctl", "call", "org.freedesktop.login1", sessionPath,
|
||||
"org.freedesktop.login1.Session", "SetLockedHint", "b", session.locked ? "true" : "false"]);
|
||||
}
|
||||
|
||||
onSessionPathChanged: setLockedHint()
|
||||
|
||||
WlSessionLock {
|
||||
id: session
|
||||
locked: true
|
||||
onLockedChanged: root.setLockedHint()
|
||||
|
||||
LockSurface {
|
||||
lock: root
|
||||
}
|
||||
}
|
||||
|
||||
PamContext {
|
||||
id: pam
|
||||
config: "login"
|
||||
|
||||
onPamMessage: {
|
||||
if (responseRequired) respond(root.password);
|
||||
}
|
||||
|
||||
onCompleted: result => {
|
||||
root.password = "";
|
||||
if (result === PamResult.Success) {
|
||||
session.locked = false;
|
||||
} else {
|
||||
root.error = result === PamResult.MaxTries ? "Too many tries, wait a moment" : "Wrong password";
|
||||
root.failed();
|
||||
}
|
||||
}
|
||||
|
||||
onError: () => {
|
||||
root.password = "";
|
||||
root.error = "Couldn't check the password";
|
||||
root.failed();
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: logind
|
||||
running: true
|
||||
command: ["sh", "-c", `
|
||||
id=$(loginctl show-user "$USER" -p Display --value)
|
||||
path=$(busctl call org.freedesktop.login1 /org/freedesktop/login1 \
|
||||
org.freedesktop.login1.Manager GetSession s "$id" | cut -d '"' -f 2)
|
||||
echo "path=$path"
|
||||
exec gdbus monitor --system --dest org.freedesktop.login1 --object-path "$path"
|
||||
`]
|
||||
stdout: SplitParser {
|
||||
onRead: line => {
|
||||
if (line.startsWith("path=")) root.sessionPath = line.slice(5);
|
||||
else if (line.includes("org.freedesktop.login1.Session.Lock (")) root.lock();
|
||||
}
|
||||
}
|
||||
onRunningChanged: if (!running) restartLogind.start()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: restartLogind
|
||||
interval: 2000
|
||||
onTriggered: logind.running = true
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "lock"
|
||||
|
||||
function lock(): void {
|
||||
root.lock();
|
||||
}
|
||||
}
|
||||
}
|
||||
213
src/LockSurface.qml
Normal file
213
src/LockSurface.qml
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
import QtQuick
|
||||
import QtQuick.Effects
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
|
||||
WlSessionLockSurface {
|
||||
id: surface
|
||||
|
||||
required property Lock lock
|
||||
|
||||
color: Theme.base
|
||||
|
||||
Item {
|
||||
id: content
|
||||
anchors.fill: parent
|
||||
|
||||
Image {
|
||||
id: wallpaper
|
||||
anchors.fill: parent
|
||||
anchors.margins: -blur.blurMax
|
||||
visible: false
|
||||
source: Theme.wallpaper === "" ? "" : `file://${Theme.wallpaper}`
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
sourceSize.width: surface.width / 2
|
||||
asynchronous: true
|
||||
}
|
||||
|
||||
MultiEffect {
|
||||
id: blur
|
||||
anchors.fill: wallpaper
|
||||
autoPaddingEnabled: false
|
||||
source: wallpaper
|
||||
visible: wallpaper.status === Image.Ready
|
||||
blurEnabled: true
|
||||
blur: 1
|
||||
blurMax: 32
|
||||
brightness: -0.05
|
||||
}
|
||||
|
||||
SystemClock {
|
||||
id: clock
|
||||
precision: SystemClock.Minutes
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: surface.lock
|
||||
|
||||
function onFailed() {
|
||||
input.text = "";
|
||||
input.forceActiveFocus();
|
||||
shake.restart();
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: info
|
||||
enabled: !shade.sheetShown
|
||||
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
topMargin: Theme.barHeight + 48
|
||||
leftMargin: 16
|
||||
rightMargin: 16
|
||||
}
|
||||
spacing: 0
|
||||
|
||||
Text {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: Qt.formatTime(clock.date, "HH:mm")
|
||||
color: Theme.text
|
||||
font.family: Theme.font
|
||||
font.pixelSize: 88
|
||||
font.weight: Font.Light
|
||||
}
|
||||
|
||||
Text {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: Qt.formatDate(clock.date, "dddd, MMMM d")
|
||||
color: Theme.subtext
|
||||
font.family: Theme.font
|
||||
font.pixelSize: 18
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: field
|
||||
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Layout.topMargin: 32
|
||||
Layout.preferredWidth: Math.min(320, info.width)
|
||||
implicitHeight: 50
|
||||
radius: height / 2
|
||||
color: Theme.surface
|
||||
opacity: surface.lock.checking ? 0.6 : 1
|
||||
|
||||
transform: Translate {
|
||||
id: offset
|
||||
}
|
||||
|
||||
SequentialAnimation {
|
||||
id: shake
|
||||
loops: 2
|
||||
NumberAnimation { target: offset; property: "x"; to: 10; duration: 50 }
|
||||
NumberAnimation { target: offset; property: "x"; to: -10; duration: 100 }
|
||||
NumberAnimation { target: offset; property: "x"; to: 0; duration: 50 }
|
||||
}
|
||||
|
||||
TextInput {
|
||||
id: input
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: submit.left
|
||||
verticalCenter: parent.verticalCenter
|
||||
leftMargin: 20
|
||||
rightMargin: 8
|
||||
}
|
||||
readOnly: surface.lock.checking
|
||||
echoMode: TextInput.Password
|
||||
passwordCharacter: "•"
|
||||
inputMethodHints: Qt.ImhSensitiveData | Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
|
||||
color: Theme.text
|
||||
font.family: Theme.font
|
||||
font.pixelSize: 16
|
||||
clip: true
|
||||
onAccepted: surface.lock.unlock(text)
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: input.text === ""
|
||||
text: "Password"
|
||||
color: Theme.subtext
|
||||
opacity: 0.6
|
||||
font: input.font
|
||||
}
|
||||
}
|
||||
|
||||
RoundButton {
|
||||
id: submit
|
||||
|
||||
anchors {
|
||||
right: parent.right
|
||||
verticalCenter: parent.verticalCenter
|
||||
rightMargin: 5
|
||||
}
|
||||
implicitWidth: 40
|
||||
implicitHeight: 40
|
||||
icon: "go-next-symbolic"
|
||||
active: input.text !== ""
|
||||
onClicked: surface.lock.unlock(input.text)
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Layout.topMargin: 10
|
||||
visible: text !== ""
|
||||
text: surface.lock.error
|
||||
color: "#bf616a"
|
||||
font.family: Theme.font
|
||||
font.pixelSize: 14
|
||||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
enabled: !shade.sheetShown
|
||||
anchors {
|
||||
top: info.bottom
|
||||
bottom: parent.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
margins: 8
|
||||
topMargin: 24
|
||||
}
|
||||
clip: true
|
||||
spacing: 8
|
||||
model: ScriptModel {
|
||||
values: Notifications.list
|
||||
}
|
||||
|
||||
delegate: NotificationCard {
|
||||
required property var modelData
|
||||
notification: modelData
|
||||
locked: true
|
||||
width: ListView.view.width
|
||||
}
|
||||
|
||||
remove: Transition {
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
to: 0
|
||||
duration: 150
|
||||
}
|
||||
}
|
||||
displaced: Transition {
|
||||
NumberAnimation {
|
||||
property: "y"
|
||||
duration: 180
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Shade {
|
||||
id: shade
|
||||
anchors.fill: parent
|
||||
locked: true
|
||||
showPopups: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,8 @@ Item {
|
|||
|
||||
required property Notification notification
|
||||
property bool popup: false
|
||||
// Can still be dismissed, but not opened
|
||||
property bool locked: false
|
||||
|
||||
signal activated
|
||||
|
||||
|
|
@ -88,6 +90,7 @@ Item {
|
|||
}
|
||||
|
||||
TapHandler {
|
||||
enabled: !card.locked
|
||||
onTapped: eventPoint => {
|
||||
const p = actionRow.mapFromItem(body, eventPoint.position);
|
||||
if (actionRow.visible && actionRow.contains(p)) return;
|
||||
|
|
@ -172,7 +175,7 @@ Item {
|
|||
id: actionRow
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 6
|
||||
visible: card.actions.length > 0
|
||||
visible: card.actions.length > 0 && !card.locked
|
||||
color: Theme.surface
|
||||
model: card.actions.map(a => ({
|
||||
name: a.text,
|
||||
|
|
|
|||
395
src/Panel.qml
395
src/Panel.qml
|
|
@ -1,10 +1,7 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Networking
|
||||
|
||||
PanelWindow { // qmllint disable uncreatable-type
|
||||
id: root
|
||||
|
|
@ -25,408 +22,32 @@ PanelWindow { // qmllint disable uncreatable-type
|
|||
WlrLayershell.layer: WlrLayer.Top
|
||||
WlrLayershell.namespace: "quad-shell"
|
||||
|
||||
// 0 is closed, 1 is open
|
||||
property real progress: 0
|
||||
readonly property bool sheetShown: progress > 0
|
||||
// Which row of options is dropped down: "", "rotate" or "power"
|
||||
property string expanded: ""
|
||||
|
||||
mask: Region {
|
||||
item: root.sheetShown ? scrim : bar
|
||||
item: shade.sheetShown ? shade.scrimItem : shade.barItem
|
||||
|
||||
Region {
|
||||
item: popups
|
||||
item: shade.popupsItem
|
||||
}
|
||||
}
|
||||
|
||||
function open() {
|
||||
settle.to = 1;
|
||||
settle.restart();
|
||||
}
|
||||
|
||||
function close() {
|
||||
settle.to = 0;
|
||||
settle.restart();
|
||||
}
|
||||
|
||||
// Snap open or closed depending on how far and fast it was dragged
|
||||
function release(velocity) {
|
||||
if (velocity > 400) open();
|
||||
else if (velocity < -400) close();
|
||||
else if (progress > 0.5) open();
|
||||
else close();
|
||||
}
|
||||
|
||||
function launch(command) {
|
||||
Quickshell.execDetached(command);
|
||||
close();
|
||||
}
|
||||
|
||||
onSheetShownChanged: {
|
||||
if (sheetShown) Status.refresh();
|
||||
else expanded = "";
|
||||
Shade {
|
||||
id: shade
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "sheet"
|
||||
|
||||
function open(): void {
|
||||
root.open();
|
||||
shade.open();
|
||||
}
|
||||
|
||||
function close(): void {
|
||||
root.close();
|
||||
shade.close();
|
||||
}
|
||||
|
||||
function toggle(): void {
|
||||
root.sheetShown ? root.close() : root.open();
|
||||
shade.sheetShown ? shade.close() : shade.open();
|
||||
}
|
||||
}
|
||||
|
||||
component SheetDrag: DragHandler {
|
||||
target: null
|
||||
xAxis.enabled: false
|
||||
|
||||
property real startProgress
|
||||
|
||||
onActiveChanged: {
|
||||
if (active) {
|
||||
settle.stop();
|
||||
startProgress = root.progress;
|
||||
} else {
|
||||
root.release(centroid.velocity.y);
|
||||
}
|
||||
}
|
||||
onActiveTranslationChanged: {
|
||||
if (active) root.progress = Math.max(0, Math.min(1, startProgress + activeTranslation.y / sheet.height));
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: screenshot
|
||||
interval: 400
|
||||
onTriggered: Quickshell.execDetached(["niri", "msg", "action", "screenshot-screen"])
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
id: settle
|
||||
target: root
|
||||
property: "progress"
|
||||
duration: 220
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: scrim
|
||||
anchors.fill: parent
|
||||
color: "black"
|
||||
opacity: 0.5 * root.progress
|
||||
|
||||
TapHandler {
|
||||
enabled: root.sheetShown
|
||||
onTapped: eventPoint => {
|
||||
const p = eventPoint.position;
|
||||
if (p.y > sheet.y + sheet.height && !drawer.contains(drawer.mapFromItem(scrim, p))) root.close();
|
||||
}
|
||||
}
|
||||
|
||||
SheetDrag {
|
||||
enabled: root.sheetShown
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: sheet
|
||||
|
||||
width: parent.width
|
||||
height: content.implicitHeight + Theme.barHeight + 28
|
||||
y: (root.progress - 1) * height
|
||||
visible: root.sheetShown
|
||||
color: Theme.background
|
||||
bottomLeftRadius: 24
|
||||
bottomRightRadius: 24
|
||||
|
||||
TapHandler {}
|
||||
|
||||
ColumnLayout {
|
||||
id: content
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
top: parent.top
|
||||
topMargin: Theme.barHeight + 8
|
||||
leftMargin: 12
|
||||
rightMargin: 12
|
||||
}
|
||||
spacing: 10
|
||||
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 8
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
RoundButton {
|
||||
icon: "camera-photo-symbolic"
|
||||
onClicked: {
|
||||
root.close();
|
||||
screenshot.restart();
|
||||
}
|
||||
}
|
||||
|
||||
RoundButton {
|
||||
icon: "system-shutdown-symbolic"
|
||||
active: root.expanded === "power"
|
||||
onClicked: root.expanded = root.expanded === "power" ? "" : "power"
|
||||
}
|
||||
}
|
||||
|
||||
Options {
|
||||
visible: root.expanded === "power"
|
||||
Layout.fillWidth: true
|
||||
model: [
|
||||
{ name: "Suspend", action: () => root.launch(["systemctl", "suspend"]) },
|
||||
{ name: "Restart", action: () => root.launch(["systemctl", "reboot"]) },
|
||||
{ name: "Power off", action: () => root.launch(["systemctl", "poweroff"]) },
|
||||
]
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
Layout.fillWidth: true
|
||||
columns: 2
|
||||
columnSpacing: 10
|
||||
rowSpacing: 10
|
||||
|
||||
Tile {
|
||||
Layout.fillWidth: true
|
||||
icon: Status.wifiIcon
|
||||
label: "Wi-Fi"
|
||||
detail: !Networking.wifiEnabled ? "Off" : Status.wifiNetwork?.name ?? "Not connected"
|
||||
active: Networking.wifiEnabled
|
||||
hasMore: true
|
||||
onToggled: Status.setWifi(!Networking.wifiEnabled)
|
||||
onMore: root.launch(["nmgui"])
|
||||
}
|
||||
|
||||
Tile {
|
||||
Layout.fillWidth: true
|
||||
icon: Status.bluetoothEnabled ? "bluetooth-active-symbolic" : "bluetooth-disabled-symbolic"
|
||||
label: "Bluetooth"
|
||||
detail: !Status.bluetoothEnabled ? "Off"
|
||||
: Status.bluetoothConnected.length === 1 ? Status.bluetoothConnected[0].name
|
||||
: Status.bluetoothConnected.length > 1 ? `${Status.bluetoothConnected.length} devices`
|
||||
: "On"
|
||||
active: Status.bluetoothEnabled
|
||||
hasMore: true
|
||||
onToggled: Status.setBluetooth(!Status.bluetoothEnabled)
|
||||
onMore: root.launch(["adw-bluetooth"])
|
||||
}
|
||||
|
||||
Tile {
|
||||
Layout.fillWidth: true
|
||||
icon: Status.cellularIcon
|
||||
label: "Cellular"
|
||||
detail: Status.cellularEnabled ? "On" : "Off"
|
||||
active: Status.cellularEnabled
|
||||
onToggled: Status.setCellular(!Status.cellularEnabled)
|
||||
}
|
||||
|
||||
Tile {
|
||||
Layout.fillWidth: true
|
||||
icon: "network-transmit-receive-symbolic"
|
||||
label: "Mobile data"
|
||||
detail: !Status.cellularEnabled || !Status.dataEnabled ? "Off"
|
||||
: Status.dataActive ? "Connected" : "Connecting"
|
||||
// Keeps its setting, it just can't do anything without the modem
|
||||
available: Status.cellularEnabled
|
||||
active: Status.cellularEnabled && Status.dataEnabled
|
||||
onToggled: Status.setData(!Status.dataEnabled)
|
||||
}
|
||||
|
||||
Tile {
|
||||
Layout.fillWidth: true
|
||||
icon: "flashlight.svg"
|
||||
label: "Flashlight"
|
||||
detail: Status.flashlight ? "On" : "Off"
|
||||
active: Status.flashlight
|
||||
onToggled: Status.setFlashlight(!Status.flashlight)
|
||||
}
|
||||
|
||||
Tile {
|
||||
Layout.fillWidth: true
|
||||
icon: "object-rotate-right-symbolic"
|
||||
label: "Rotate"
|
||||
detail: root.rotations.find(r => r.transform === Status.transform)?.name ?? Status.transform
|
||||
active: Status.transform !== "normal"
|
||||
hasMore: true
|
||||
moreIcon: root.expanded === "rotate" ? "go-up-symbolic" : "go-down-symbolic"
|
||||
onToggled: Status.setTransform(Status.transform === "normal" ? root.rotations[1].transform : "normal")
|
||||
onMore: root.expanded = root.expanded === "rotate" ? "" : "rotate"
|
||||
}
|
||||
}
|
||||
|
||||
Options {
|
||||
visible: root.expanded === "rotate"
|
||||
Layout.fillWidth: true
|
||||
model: root.rotations.slice(1).map(r => ({
|
||||
name: r.name,
|
||||
active: Status.transform === r.transform,
|
||||
action: () => Status.setTransform(Status.transform === r.transform ? "normal" : r.transform),
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: drawer
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
margins: 8
|
||||
}
|
||||
y: sheet.y + sheet.height + 8
|
||||
visible: root.sheetShown && Notifications.list.length > 0
|
||||
opacity: root.progress
|
||||
spacing: 8
|
||||
|
||||
ListView {
|
||||
Layout.fillWidth: true
|
||||
// Scrolls rather than going off the bottom of the screen
|
||||
Layout.preferredHeight: Math.min(contentHeight, root.height - sheet.height - clearAll.implicitHeight - 40)
|
||||
interactive: contentHeight > height
|
||||
clip: true
|
||||
spacing: 8
|
||||
model: ScriptModel {
|
||||
values: Notifications.list
|
||||
}
|
||||
|
||||
delegate: NotificationCard {
|
||||
required property var modelData
|
||||
notification: modelData
|
||||
width: ListView.view.width
|
||||
onActivated: root.close()
|
||||
}
|
||||
|
||||
remove: Transition {
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
to: 0
|
||||
duration: 150
|
||||
}
|
||||
}
|
||||
displaced: Transition {
|
||||
NumberAnimation {
|
||||
property: "y"
|
||||
duration: 180
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: clearAll
|
||||
|
||||
Layout.alignment: Qt.AlignRight
|
||||
implicitWidth: clearText.implicitWidth + 32
|
||||
implicitHeight: 36
|
||||
radius: height / 2
|
||||
color: Theme.background
|
||||
|
||||
Text {
|
||||
id: clearText
|
||||
anchors.centerIn: parent
|
||||
text: "Clear all"
|
||||
color: Theme.text
|
||||
font.family: Theme.font
|
||||
font.pixelSize: 13
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
onTapped: Notifications.clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: popups
|
||||
|
||||
anchors {
|
||||
top: bar.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
margins: 8
|
||||
}
|
||||
height: contentHeight
|
||||
visible: !root.sheetShown
|
||||
interactive: false
|
||||
spacing: 8
|
||||
model: ScriptModel {
|
||||
values: Notifications.popups.slice(0, 3)
|
||||
}
|
||||
|
||||
delegate: NotificationCard {
|
||||
required property var modelData
|
||||
notification: modelData
|
||||
width: ListView.view.width
|
||||
popup: true
|
||||
}
|
||||
|
||||
add: Transition {
|
||||
NumberAnimation {
|
||||
property: "y"
|
||||
from: -80
|
||||
duration: 220
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
from: 0
|
||||
to: 1
|
||||
duration: 220
|
||||
}
|
||||
}
|
||||
remove: Transition {
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
to: 0
|
||||
duration: 150
|
||||
}
|
||||
}
|
||||
displaced: Transition {
|
||||
NumberAnimation {
|
||||
property: "y"
|
||||
duration: 220
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly property var rotations: [
|
||||
{ name: "Portrait", transform: "normal" },
|
||||
{ name: "Landscape", transform: "270" },
|
||||
{ name: "Landscape flipped", transform: "90" },
|
||||
{ name: "Portrait flipped", transform: "180" },
|
||||
]
|
||||
|
||||
Bar {
|
||||
id: bar
|
||||
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
height: Theme.barHeight
|
||||
|
||||
TapHandler {
|
||||
onTapped: root.sheetShown ? root.close() : root.open()
|
||||
}
|
||||
|
||||
SheetDrag {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
397
src/Shade.qml
Normal file
397
src/Shade.qml
Normal file
|
|
@ -0,0 +1,397 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Networking
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property bool locked: false
|
||||
property bool showPopups: true
|
||||
|
||||
readonly property Item barItem: bar
|
||||
readonly property Item scrimItem: scrim
|
||||
readonly property Item popupsItem: popups
|
||||
|
||||
// 0 is closed, 1 is open
|
||||
property real progress: 0
|
||||
readonly property bool sheetShown: progress > 0
|
||||
// Which row of options is dropped down: "", "rotate" or "power"
|
||||
property string expanded: ""
|
||||
|
||||
function open() {
|
||||
settle.to = 1;
|
||||
settle.restart();
|
||||
}
|
||||
|
||||
function close() {
|
||||
settle.to = 0;
|
||||
settle.restart();
|
||||
}
|
||||
|
||||
function release(velocity) {
|
||||
if (velocity > 400) open();
|
||||
else if (velocity < -400) close();
|
||||
else if (progress > 0.5) open();
|
||||
else close();
|
||||
}
|
||||
|
||||
function launch(command) {
|
||||
Quickshell.execDetached(command);
|
||||
close();
|
||||
}
|
||||
|
||||
onSheetShownChanged: {
|
||||
if (sheetShown) Status.refresh();
|
||||
else expanded = "";
|
||||
}
|
||||
|
||||
component SheetDrag: DragHandler {
|
||||
target: null
|
||||
xAxis.enabled: false
|
||||
|
||||
property real startProgress
|
||||
|
||||
onActiveChanged: {
|
||||
if (active) {
|
||||
settle.stop();
|
||||
startProgress = root.progress;
|
||||
} else {
|
||||
root.release(centroid.velocity.y);
|
||||
}
|
||||
}
|
||||
onActiveTranslationChanged: {
|
||||
if (active) root.progress = Math.max(0, Math.min(1, startProgress + activeTranslation.y / sheet.height));
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: screenshot
|
||||
interval: 400
|
||||
onTriggered: Quickshell.execDetached(["niri", "msg", "action", "screenshot-screen"])
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
id: settle
|
||||
target: root
|
||||
property: "progress"
|
||||
duration: 220
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: scrim
|
||||
anchors.fill: parent
|
||||
color: "black"
|
||||
opacity: 0.5 * root.progress
|
||||
|
||||
TapHandler {
|
||||
enabled: root.sheetShown
|
||||
onTapped: eventPoint => {
|
||||
const p = eventPoint.position;
|
||||
if (p.y > sheet.y + sheet.height && !drawer.contains(drawer.mapFromItem(scrim, p))) root.close();
|
||||
}
|
||||
}
|
||||
|
||||
SheetDrag {
|
||||
enabled: root.sheetShown
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: sheet
|
||||
|
||||
width: parent.width
|
||||
height: content.implicitHeight + Theme.barHeight + 28
|
||||
y: (root.progress - 1) * height
|
||||
visible: root.sheetShown
|
||||
color: Theme.background
|
||||
bottomLeftRadius: 24
|
||||
bottomRightRadius: 24
|
||||
|
||||
TapHandler {}
|
||||
|
||||
ColumnLayout {
|
||||
id: content
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
top: parent.top
|
||||
topMargin: Theme.barHeight + 8
|
||||
leftMargin: 12
|
||||
rightMargin: 12
|
||||
}
|
||||
spacing: 10
|
||||
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 8
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
RoundButton {
|
||||
icon: "camera-photo-symbolic"
|
||||
onClicked: {
|
||||
root.close();
|
||||
screenshot.restart();
|
||||
}
|
||||
}
|
||||
|
||||
RoundButton {
|
||||
icon: "system-shutdown-symbolic"
|
||||
active: root.expanded === "power"
|
||||
onClicked: root.expanded = root.expanded === "power" ? "" : "power"
|
||||
}
|
||||
}
|
||||
|
||||
Options {
|
||||
visible: root.expanded === "power"
|
||||
Layout.fillWidth: true
|
||||
model: [
|
||||
{ name: "Suspend", action: () => root.launch(["systemctl", "suspend"]) },
|
||||
{ name: "Restart", action: () => root.launch(["systemctl", "reboot"]) },
|
||||
{ name: "Power off", action: () => root.launch(["systemctl", "poweroff"]) },
|
||||
]
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
Layout.fillWidth: true
|
||||
columns: 2
|
||||
columnSpacing: 10
|
||||
rowSpacing: 10
|
||||
|
||||
Tile {
|
||||
Layout.fillWidth: true
|
||||
icon: Status.wifiIcon
|
||||
label: "Wi-Fi"
|
||||
detail: !Networking.wifiEnabled ? "Off" : Status.wifiNetwork?.name ?? "Not connected"
|
||||
active: Networking.wifiEnabled
|
||||
hasMore: !root.locked
|
||||
onToggled: Status.setWifi(!Networking.wifiEnabled)
|
||||
onMore: root.launch(["nmgui"])
|
||||
}
|
||||
|
||||
Tile {
|
||||
Layout.fillWidth: true
|
||||
icon: Status.bluetoothEnabled ? "bluetooth-active-symbolic" : "bluetooth-disabled-symbolic"
|
||||
label: "Bluetooth"
|
||||
detail: !Status.bluetoothEnabled ? "Off"
|
||||
: Status.bluetoothConnected.length === 1 ? Status.bluetoothConnected[0].name
|
||||
: Status.bluetoothConnected.length > 1 ? `${Status.bluetoothConnected.length} devices`
|
||||
: "On"
|
||||
active: Status.bluetoothEnabled
|
||||
hasMore: !root.locked
|
||||
onToggled: Status.setBluetooth(!Status.bluetoothEnabled)
|
||||
onMore: root.launch(["adw-bluetooth"])
|
||||
}
|
||||
|
||||
Tile {
|
||||
Layout.fillWidth: true
|
||||
icon: Status.cellularIcon
|
||||
label: "Cellular"
|
||||
detail: Status.cellularEnabled ? "On" : "Off"
|
||||
active: Status.cellularEnabled
|
||||
onToggled: Status.setCellular(!Status.cellularEnabled)
|
||||
}
|
||||
|
||||
Tile {
|
||||
Layout.fillWidth: true
|
||||
icon: "network-transmit-receive-symbolic"
|
||||
label: "Mobile data"
|
||||
detail: !Status.cellularEnabled || !Status.dataEnabled ? "Off"
|
||||
: Status.dataActive ? "Connected" : "Connecting"
|
||||
// Keeps its setting, it just can't do anything without the modem
|
||||
available: Status.cellularEnabled
|
||||
active: Status.cellularEnabled && Status.dataEnabled
|
||||
onToggled: Status.setData(!Status.dataEnabled)
|
||||
}
|
||||
|
||||
Tile {
|
||||
Layout.fillWidth: true
|
||||
icon: "flashlight.svg"
|
||||
label: "Flashlight"
|
||||
detail: Status.flashlight ? "On" : "Off"
|
||||
active: Status.flashlight
|
||||
onToggled: Status.setFlashlight(!Status.flashlight)
|
||||
}
|
||||
|
||||
Tile {
|
||||
Layout.fillWidth: true
|
||||
icon: "object-rotate-right-symbolic"
|
||||
label: "Rotate"
|
||||
detail: root.rotations.find(r => r.transform === Status.transform)?.name ?? Status.transform
|
||||
active: Status.transform !== "normal"
|
||||
hasMore: true
|
||||
moreIcon: root.expanded === "rotate" ? "go-up-symbolic" : "go-down-symbolic"
|
||||
onToggled: Status.setTransform(Status.transform === "normal" ? root.rotations[1].transform : "normal")
|
||||
onMore: root.expanded = root.expanded === "rotate" ? "" : "rotate"
|
||||
}
|
||||
}
|
||||
|
||||
Options {
|
||||
visible: root.expanded === "rotate"
|
||||
Layout.fillWidth: true
|
||||
model: root.rotations.slice(1).map(r => ({
|
||||
name: r.name,
|
||||
active: Status.transform === r.transform,
|
||||
action: () => Status.setTransform(Status.transform === r.transform ? "normal" : r.transform),
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: drawer
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
margins: 8
|
||||
}
|
||||
y: sheet.y + sheet.height + 8
|
||||
visible: root.sheetShown && Notifications.list.length > 0
|
||||
opacity: root.progress
|
||||
spacing: 8
|
||||
|
||||
ListView {
|
||||
Layout.fillWidth: true
|
||||
// Scrolls rather than going off the bottom of the screen
|
||||
Layout.preferredHeight: Math.min(contentHeight, root.height - sheet.height - clearAll.implicitHeight - 40)
|
||||
interactive: contentHeight > height
|
||||
clip: true
|
||||
spacing: 8
|
||||
model: ScriptModel {
|
||||
values: Notifications.list
|
||||
}
|
||||
|
||||
delegate: NotificationCard {
|
||||
required property var modelData
|
||||
notification: modelData
|
||||
locked: root.locked
|
||||
width: ListView.view.width
|
||||
onActivated: root.close()
|
||||
}
|
||||
|
||||
remove: Transition {
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
to: 0
|
||||
duration: 150
|
||||
}
|
||||
}
|
||||
displaced: Transition {
|
||||
NumberAnimation {
|
||||
property: "y"
|
||||
duration: 180
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: clearAll
|
||||
|
||||
Layout.alignment: Qt.AlignRight
|
||||
implicitWidth: clearText.implicitWidth + 32
|
||||
implicitHeight: 36
|
||||
radius: height / 2
|
||||
color: Theme.background
|
||||
|
||||
Text {
|
||||
id: clearText
|
||||
anchors.centerIn: parent
|
||||
text: "Clear all"
|
||||
color: Theme.text
|
||||
font.family: Theme.font
|
||||
font.pixelSize: 13
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
onTapped: Notifications.clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: popups
|
||||
|
||||
anchors {
|
||||
top: bar.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
margins: 8
|
||||
}
|
||||
height: contentHeight
|
||||
visible: !root.sheetShown && root.showPopups
|
||||
interactive: false
|
||||
spacing: 8
|
||||
model: ScriptModel {
|
||||
values: Notifications.popups.slice(0, 3)
|
||||
}
|
||||
|
||||
delegate: NotificationCard {
|
||||
required property var modelData
|
||||
notification: modelData
|
||||
width: ListView.view.width
|
||||
popup: true
|
||||
}
|
||||
|
||||
add: Transition {
|
||||
NumberAnimation {
|
||||
property: "y"
|
||||
from: -80
|
||||
duration: 220
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
from: 0
|
||||
to: 1
|
||||
duration: 220
|
||||
}
|
||||
}
|
||||
remove: Transition {
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
to: 0
|
||||
duration: 150
|
||||
}
|
||||
}
|
||||
displaced: Transition {
|
||||
NumberAnimation {
|
||||
property: "y"
|
||||
duration: 220
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly property var rotations: [
|
||||
{ name: "Portrait", transform: "normal" },
|
||||
{ name: "Landscape", transform: "270" },
|
||||
{ name: "Landscape flipped", transform: "90" },
|
||||
{ name: "Portrait flipped", transform: "180" },
|
||||
]
|
||||
|
||||
Bar {
|
||||
id: bar
|
||||
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
height: Theme.barHeight
|
||||
|
||||
TapHandler {
|
||||
onTapped: root.sheetShown ? root.close() : root.open()
|
||||
}
|
||||
|
||||
SheetDrag {}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import Quickshell
|
|||
Singleton {
|
||||
readonly property int barHeight: 27
|
||||
|
||||
readonly property color base: "#242933"
|
||||
readonly property color background: "#2e3440"
|
||||
readonly property color surface: "#3b4252"
|
||||
readonly property color surfaceHigh: "#434c5e"
|
||||
|
|
@ -13,4 +14,6 @@ Singleton {
|
|||
readonly property color subtext: "#d8dee9"
|
||||
|
||||
readonly property string font: "Inter"
|
||||
|
||||
readonly property string wallpaper: Quickshell.env("QUADSHELL_WALLPAPER") ?? ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,12 @@ singleton Notifications Notifications.qml
|
|||
singleton Status Status.qml
|
||||
singleton Theme Theme.qml
|
||||
Bar Bar.qml
|
||||
Lock Lock.qml
|
||||
LockSurface LockSurface.qml
|
||||
NotificationCard NotificationCard.qml
|
||||
Options Options.qml
|
||||
Panel Panel.qml
|
||||
RoundButton RoundButton.qml
|
||||
Shade Shade.qml
|
||||
ShellIcon ShellIcon.qml
|
||||
Tile Tile.qml
|
||||
|
|
|
|||
|
|
@ -8,4 +8,6 @@ ShellRoot {
|
|||
|
||||
Panel {}
|
||||
}
|
||||
|
||||
Lock {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue