initial commit

This commit is contained in:
Henry Hiles 2026-11-17 16:51:34 -05:00
commit b7ea790891
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
17 changed files with 941 additions and 0 deletions

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
result
result-*
# Written by quickshell with paths from this machine, for qmlls
.qmlls.ini

61
README.md Normal file
View file

@ -0,0 +1,61 @@
# quadshell
A phone shell for [niri](https://github.com/YaLTeR/niri), built with
[Quickshell](https://quickshell.org). It's a status bar with a quick settings sheet that you pull
down from it.
<img src="docs/screenshot.png" alt="The quick settings sheet pulled down over the app grid" width="300">
The bar shows the time, cellular, Wi-Fi, Bluetooth and battery. The sheet has:
- Wi-Fi, Bluetooth, cellular and mobile data toggles. The arrow on Wi-Fi opens `nmgui`, and on
Bluetooth it opens `adw-bluetooth`.
- A flashlight
- Rotation, with a choice of orientations
- Screenshot and power (suspend, restart, power off) buttons
Drag the bar down to open the sheet, and swipe up anywhere or tap below it to close it. You can
also toggle it with `qs ipc call sheet toggle`.
## Using it
The flake has a `quadshell` package, and an overlay that adds it to nixpkgs:
```nix
nixpkgs.overlays = [ quadshell.overlays.default ];
```
Then start it with niri, in your niri config:
```kdl
spawn-at-startup "quadshell"
```
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 Papirus-Dark icon theme and the Inter font
## Developing
```sh
nix run .#phone [host]
```
This copies `src` to the phone over SSH (`host` defaults to `phone`) and runs it there, showing
its logs until you press Ctrl+C. It stops any other running Quickshell first, so when you quit
there's no bar until you run it again. The phone needs Quickshell from this flake's nixpkgs
already in its store, as it doesn't download anything.
### Editor support
For completion and lints in VS Code, install the Qt Qml extension and point it at `qmlls` from
`qt6.qtdeclarative`. Then create an empty `src/.qmlls.ini` and run Quickshell on this machine once:
```sh
nix run --inputs-from . nixpkgs#quickshell -- --path src
```
Quickshell fills in `.qmlls.ini` with its import paths. That file links into `/run`, so do this
again after a reboot.

BIN
docs/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 KiB

27
flake.lock generated Normal file
View file

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1794537146,
"narHash": "sha256-Wpz/7x/YWnDIBu7yj6ixe8j6fIMsidd9Y+o1PqPF3iM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d5cc6833999746cffdfe0598f7bc801a57b887a9",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

62
flake.nix Normal file
View file

@ -0,0 +1,62 @@
{
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
outputs =
{ self, nixpkgs, ... }:
let
forAllSystems = nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
];
in
{
overlays.default = final: prev: {
quadshell = final.callPackage ./package.nix { };
};
packages = forAllSystems (system: {
default = (nixpkgs.legacyPackages.${system}.extend self.overlays.default).quadshell;
});
apps = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
# Just the path, the phone should already have it, so this machine doesn't need it
quickshell = builtins.unsafeDiscardStringContext (
nixpkgs.lib.getExe nixpkgs.legacyPackages.aarch64-linux.quickshell
);
in
{
# nix run .#phone [host]: runs the shell on the phone until Ctrl+C.
phone = {
type = "app";
program = nixpkgs.lib.getExe (
pkgs.writeShellApplication {
name = "quadshell-phone";
runtimeInputs = [
pkgs.openssh
pkgs.gnutar
];
text = ''
host=''${1:-phone}
dest=.cache/quadshell-dev
# The store's files are read-only, which would stop the next run replacing them
# shellcheck disable=SC2029
tar -C ${self}/src --mode=u+w -c . | ssh "$host" "rm -rf $dest; mkdir -p $dest; tar -C $dest -x"
# shellcheck disable=SC2029
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
"
'';
}
);
};
}
);
};
}

35
package.nix Normal file
View file

@ -0,0 +1,35 @@
{
lib,
quickshell,
writeShellApplication,
networkmanager,
modemmanager,
nmgui,
adw-bluetooth,
coreutils,
gawk,
gnugrep,
}:
let
config = lib.fileset.toSource {
root = ./src;
fileset = ./src;
};
in
writeShellApplication {
name = "quadshell";
runtimeInputs = [
networkmanager
modemmanager
nmgui
adw-bluetooth
coreutils
gawk
gnugrep
];
text = ''
exec ${lib.getExe quickshell} --path ${config} "$@"
'';
}

63
src/Bar.qml Normal file
View file

@ -0,0 +1,63 @@
import QtQuick
import QtQuick.Layouts
import Quickshell
Rectangle {
color: "black"
SystemClock {
id: clock
precision: SystemClock.Minutes
}
Text {
anchors {
left: parent.left
leftMargin: 16
verticalCenter: parent.verticalCenter
}
text: Qt.formatDateTime(clock.date, "HH:mm")
color: Theme.text
font.family: Theme.font
font.pixelSize: 13
font.weight: Font.DemiBold
}
RowLayout {
anchors {
right: parent.right
rightMargin: 14
verticalCenter: parent.verticalCenter
}
spacing: 6
ShellIcon {
visible: Status.cellularEnabled
name: Status.cellularIcon
implicitSize: 14
}
ShellIcon {
name: Status.wifiIcon
implicitSize: 14
}
ShellIcon {
visible: Status.bluetoothConnected.length > 0
name: "bluetooth-active-symbolic"
implicitSize: 14
}
ShellIcon {
name: Status.batteryIcon
implicitSize: 14
}
Text {
text: `${Math.round(Status.batteryLevel * 100)}%`
color: Theme.text
font.family: Theme.font
font.pixelSize: 12
}
}
}

43
src/Options.qml Normal file
View file

@ -0,0 +1,43 @@
import QtQuick
import QtQuick.Layouts
RowLayout {
id: options
property var model: []
spacing: 8
Repeater {
model: options.model
Rectangle {
id: pill
required property var modelData
Layout.fillWidth: true
implicitHeight: 40
radius: 20
color: modelData.active ? Theme.accent : Theme.surface
Text {
anchors.centerIn: parent
width: parent.width - 24
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
maximumLineCount: 2
elide: Text.ElideRight
lineHeight: 0.9
text: pill.modelData.name
color: Theme.text
font.family: Theme.font
font.pixelSize: 12
}
TapHandler {
onTapped: pill.modelData.action()
}
}
}
}

298
src/Panel.qml Normal file
View file

@ -0,0 +1,298 @@
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
required property var modelData
screen: modelData
anchors {
top: true
left: true
right: true
}
implicitHeight: modelData.height
exclusionMode: ExclusionMode.Normal
exclusiveZone: Theme.barHeight
color: "transparent"
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
}
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 = "";
}
IpcHandler {
target: "sheet"
function open(): void {
root.open();
}
function close(): void {
root.close();
}
function toggle(): void {
root.sheetShown ? root.close() : root.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 {
onTapped: eventPoint => {
if (eventPoint.position.y > sheet.y + sheet.height) root.close();
}
}
SheetDrag {}
}
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),
}))
}
}
}
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 {}
}
}

25
src/RoundButton.qml Normal file
View file

@ -0,0 +1,25 @@
import QtQuick
Rectangle {
id: button
property string icon
property bool active
signal clicked
implicitWidth: 40
implicitHeight: 40
radius: height / 2
color: active ? Theme.accent : Theme.surface
ShellIcon {
anchors.centerIn: parent
name: button.icon
implicitSize: 18
}
TapHandler {
onTapped: button.clicked()
}
}

15
src/ShellIcon.qml Normal file
View file

@ -0,0 +1,15 @@
import QtQuick
import QtQuick.Effects
import Quickshell
import Quickshell.Widgets
IconImage {
property string name
source: name.endsWith(".svg") ? Qt.resolvedUrl(name) : Quickshell.iconPath(name)
layer.enabled: true
layer.effect: MultiEffect {
brightness: 1
}
}

168
src/Status.qml Normal file
View file

@ -0,0 +1,168 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
import Quickshell.Networking
import Quickshell.Bluetooth
import Quickshell.Services.UPower
Singleton {
id: root
readonly property var wifiDevice: Networking.devices.values.find(d => d.type === DeviceType.Wifi) ?? null // qmllint disable missing-property
readonly property var wifiNetwork: wifiDevice?.networks.values.find(n => n.connected) ?? null
readonly property string wifiIcon: !Networking.wifiEnabled ? "network-wireless-disabled-symbolic"
: !wifiNetwork ? "network-wireless-offline-symbolic"
: `network-wireless-signal-${signalLevel(wifiNetwork.signalStrength)}-symbolic`
readonly property var bluetooth: Bluetooth.defaultAdapter // qmllint disable unresolved-type
readonly property bool bluetoothEnabled: bluetooth?.enabled ?? false
readonly property var bluetoothConnected: Bluetooth.devices.values.filter(d => d.connected) // qmllint disable missing-property
readonly property var battery: UPower.displayDevice
readonly property real batteryLevel: battery?.percentage ?? 0
readonly property bool charging: battery?.state === UPowerDeviceState.Charging
|| battery?.state === UPowerDeviceState.FullyCharged
readonly property int batteryStep: Math.round(batteryLevel * 10) * 10
readonly property string batteryIcon: `battery-level-${batteryStep}${!charging ? "" : batteryStep === 100 ? "-charged" : "-charging"}-symbolic`
property bool cellularEnabled
property string dataConnection
property bool dataEnabled
property bool dataActive
property real cellularSignal
property bool flashlight
property string output
property string transform: "normal"
readonly property string cellularIcon: !cellularEnabled ? "network-cellular-disabled-symbolic"
: `network-cellular-signal-${signalLevel(cellularSignal)}-symbolic`
readonly property string flashlightLed: "white:flash"
function signalLevel(strength) {
if (strength > 0.8) return "excellent";
if (strength > 0.6) return "good";
if (strength > 0.4) return "ok";
if (strength > 0.2) return "weak";
return "none";
}
function setWifi(on) {
Networking.wifiEnabled = on;
}
function setBluetooth(on) {
if (bluetooth) bluetooth.enabled = on;
}
function setCellular(on) {
cellularEnabled = on;
run(["nmcli", "radio", "wwan", on ? "on" : "off"]);
}
function setData(on) {
if (!dataConnection) return;
dataEnabled = on;
run(["sh", "-c", 'nmcli connection modify "$1" connection.autoconnect "$2" && nmcli connection "$3" "$1"',
"sh", dataConnection, on ? "yes" : "no", on ? "up" : "down"]);
}
function setFlashlight(on) {
flashlight = on;
run(["sh", "-c", `busctl call org.freedesktop.login1 \
"/org/freedesktop/login1/session/$(loginctl show-user "$USER" -p Display --value)" \
org.freedesktop.login1.Session SetBrightness ssu leds "$1" "$2"`,
"sh", flashlightLed, on ? "255" : "0"]);
}
function setTransform(t) {
if (!output) return;
transform = t;
run(["niri", "msg", "output", output, "transform", t]);
}
function run(command) {
Quickshell.execDetached(command);
refreshSoon.restart();
}
function refresh() {
if (poll.running) pollAgain = true;
else poll.running = true;
}
property bool pollAgain
function parse(text) {
const values = {};
for (const line of text.split("\n")) {
const split = line.indexOf("=");
if (split > 0) values[line.slice(0, split)] = line.slice(split + 1);
}
cellularEnabled = values.wwan === "enabled";
dataConnection = values.gsm ?? "";
dataEnabled = values.autoconnect === "yes";
dataActive = values.active === "yes";
cellularSignal = (parseInt(values.signal) || 0) / 100;
flashlight = (parseInt(values.flashlight) || 0) > 0;
try {
const outputs = Object.values(JSON.parse(values.outputs));
const first = outputs.find(o => o.logical) ?? outputs[0];
output = first?.name ?? "";
// niri calls these Normal, _90, Flipped90 and so on, `niri msg output` wants 90
transform = (first?.logical?.transform ?? "normal").replace(/^_/, "").toLowerCase();
} catch (e) {
console.warn("Couldn't read niri outputs:", e);
}
}
Process {
id: poll
command: ["sh", "-c", `
echo "wwan=$(nmcli radio wwan)"
gsm=$(nmcli -t -f NAME,TYPE connection show | awk -F: '$2 == "gsm" { print $1; exit }')
echo "gsm=$gsm"
if [ -n "$gsm" ]; then
echo "autoconnect=$(nmcli -g connection.autoconnect connection show "$gsm")"
nmcli -t -f NAME connection show --active | grep -qxF "$gsm" && echo "active=yes"
fi
echo "signal=$(mmcli -m any -K 2>/dev/null | awk -F': *' '/signal-quality.value/ { print $2 }')"
echo "flashlight=$(cat /sys/class/leds/${root.flashlightLed}/brightness)"
echo "outputs=$(niri msg -j outputs)"
`]
stdout: StdioCollector {
onStreamFinished: root.parse(text)
}
onExited: {
if (root.pollAgain) {
root.pollAgain = false;
running = true;
}
}
}
Timer {
id: refreshSoon
interval: 400
onTriggered: root.refresh()
}
Process {
running: true
command: ["nmcli", "monitor"]
stdout: SplitParser {
onRead: refreshSoon.restart()
}
}
Timer {
running: true
repeat: true
interval: 30000
triggeredOnStart: true
onTriggered: root.refresh()
}
}

16
src/Theme.qml Normal file
View file

@ -0,0 +1,16 @@
pragma Singleton
import QtQuick
import Quickshell
Singleton {
readonly property int barHeight: 27
readonly property color background: "#2e3440"
readonly property color surface: "#3b4252"
readonly property color surfaceHigh: "#434c5e"
readonly property color accent: "#5e81ac"
readonly property color text: "#eceff4"
readonly property color subtext: "#d8dee9"
readonly property string font: "Inter"
}

103
src/Tile.qml Normal file
View file

@ -0,0 +1,103 @@
import QtQuick
import QtQuick.Layouts
Rectangle {
id: tile
property string icon
property string label
property string detail
property bool active
property string moreIcon: "go-next-symbolic"
property bool hasMore: false
property bool available: true
signal toggled
signal more
implicitHeight: 60
radius: 20
opacity: available ? 1 : 0.4
color: active ? Theme.accent : Theme.surface
Behavior on color {
ColorAnimation {
duration: 150
}
}
RowLayout {
anchors.fill: parent
spacing: 0
Item {
Layout.fillWidth: true
Layout.fillHeight: true
RowLayout {
anchors.fill: parent
anchors.leftMargin: 14
anchors.rightMargin: tile.hasMore ? 4 : 14
spacing: 10
ShellIcon {
name: tile.icon
implicitSize: 20
}
ColumnLayout {
Layout.fillWidth: true
spacing: 0
Text {
Layout.fillWidth: true
text: tile.label
color: Theme.text
font.family: Theme.font
font.pixelSize: 14
font.weight: Font.DemiBold
elide: Text.ElideRight
}
Text {
Layout.fillWidth: true
visible: text !== ""
text: tile.detail
color: Theme.subtext
font.family: Theme.font
font.pixelSize: 12
elide: Text.ElideRight
}
}
}
TapHandler {
enabled: tile.available
onTapped: tile.toggled()
}
}
Rectangle {
visible: tile.hasMore
Layout.preferredWidth: 1
Layout.preferredHeight: 28
color: Theme.text
opacity: 0.2
}
Item {
visible: tile.hasMore
Layout.preferredWidth: 44
Layout.fillHeight: true
ShellIcon {
anchors.centerIn: parent
name: tile.moreIcon
implicitSize: 16
}
TapHandler {
onTapped: tile.more()
}
}
}
}

1
src/flashlight.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#ffffff" d="M6 2h12v3H6zm0 5v1l2 3v11h8V11l2-3V7H6zm6 8.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"/></svg>

After

Width:  |  Height:  |  Size: 210 B

8
src/qmldir Normal file
View file

@ -0,0 +1,8 @@
singleton Status Status.qml
singleton Theme Theme.qml
Bar Bar.qml
Options Options.qml
Panel Panel.qml
RoundButton RoundButton.qml
ShellIcon ShellIcon.qml
Tile Tile.qml

11
src/shell.qml Normal file
View file

@ -0,0 +1,11 @@
//@ pragma IconTheme Papirus-Dark
import QtQuick
import Quickshell
ShellRoot {
Variants {
model: Quickshell.screens
Panel {}
}
}