diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2025-12-08 11:53:23 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2025-12-08 11:53:23 +0530 |
| commit | e6cf56ead8382d6bcd4d9f8d7a28490887bae92a (patch) | |
| tree | 95160419d00e5f278a0cefbf1916c4f9a852742d /quickshell | |
| parent | 6cdd44c09685f15b66bf247801a7d5fbc0f2d0f3 (diff) | |
miraged from waybar to quickshell
Diffstat (limited to 'quickshell')
| -rwxr-xr-x | quickshell/battery.sh | 2 | ||||
| -rwxr-xr-x | quickshell/brightness.sh | 4 | ||||
| -rwxr-xr-x | quickshell/network.sh | 2 | ||||
| -rw-r--r-- | quickshell/shell.qml | 360 | ||||
| -rwxr-xr-x | quickshell/volume.sh | 2 |
5 files changed, 370 insertions, 0 deletions
diff --git a/quickshell/battery.sh b/quickshell/battery.sh new file mode 100755 index 0000000..c7d4302 --- /dev/null +++ b/quickshell/battery.sh @@ -0,0 +1,2 @@ +battery=$(cat /sys/class/power_supply/BAT1/capacity) +echo "$battery" diff --git a/quickshell/brightness.sh b/quickshell/brightness.sh new file mode 100755 index 0000000..ccb2bc2 --- /dev/null +++ b/quickshell/brightness.sh @@ -0,0 +1,4 @@ +brightness=$(brightnessctl | grep 'Current brightness' | grep -o '[0-9]\+' | head -n 1) +temp=$(hyprctl hyprsunset temperature 2>/dev/null | grep -o '[0-9]\+') +if [ -z "$temp" ]; then temp=6000; fi +echo "$brightness $temp" diff --git a/quickshell/network.sh b/quickshell/network.sh new file mode 100755 index 0000000..f50707e --- /dev/null +++ b/quickshell/network.sh @@ -0,0 +1,2 @@ +connections=$(nmcli connection show --active | sed -n '2 p') +echo "$connections" diff --git a/quickshell/shell.qml b/quickshell/shell.qml new file mode 100644 index 0000000..bc1290e --- /dev/null +++ b/quickshell/shell.qml @@ -0,0 +1,360 @@ +import Quickshell +import Quickshell.Wayland +import Quickshell.Hyprland +import Quickshell.Io +import QtQuick +import QtQuick.Layouts + +PanelWindow { + id: root + + property int redBatteryPoint: 15 + property int orangeBatteryPoint: 30 + + property color black: "#000000" + property color white: "#ffffff" + property color green: "#28CD41" + property color red: "#FF4040" + property color orange: "#FFA500" + property color purple: "#BF00FF" + property color blue: "#00FFFF" + property string fontFamily: "JetBrainsMono Nerd Font" + property int fontSize: 18 + + property int cpuUsage: 0 + property int lastCpuTotal: 0 + property int lastCpuIdle: 0 + + Process { + id: cpuProc + command: ["sh", "-c", "head -1 /proc/stat"] + + stdout: SplitParser { + onRead: data => { + var p = data.trim().split(/\s+/) + var idle = parseInt(p[4]) + parseInt(p[5]) + var total = p.slice(1, 8).reduce((a, b) => a + parseInt(b), 0) + if (lastCpuTotal > 0) { + cpuUsage = Math.round(100 * (1 - (idle - lastCpuIdle) / (total - lastCpuTotal))) + } + lastCpuTotal = total + lastCpuIdle = idle + } + } + Component.onCompleted: running = true + } + + property int memUsage: 0 + Process { + id: memProc + command: ["sh", "-c", "free | grep Mem"] + stdout: SplitParser { + onRead: data => { + var parts = data.trim().split(/\s+/) + var total = parseInt(parts[1]) || 1 + var used = parseInt(parts[2]) || 0 + memUsage = Math.round(100 * used / total) + } + } + Component.onCompleted: running = true + } + + property int brightness: 100 + property int temperature: 6000 + Process { + id: brightnessProc + command: ["sh", "-c", "~/.config/quickshell/brightness.sh"] + stdout: SplitParser { + onRead: data => { + var parts = data.trim().split(/\s+/) + brightness = parseInt(parts[0]) || 100 + temperature = parseInt(parts[1]) || 6000 + } + } + Component.onCompleted: running = true + } + + property int volume: 12 + Process { + id: volumeProc + command: ["sh", "-c", "~/.config/quickshell/volume.sh"] + stdout: SplitParser { + onRead: data => { + volume = parseInt(data.trim()) || 13; + } + } + Component.onCompleted: running = true + } + + property int battery: 12 + Process { + id: batteryProc + command: ["sh", "-c", "~/.config/quickshell/battery.sh"] + stdout: SplitParser { + onRead: data => { + battery = parseInt(data.trim()) || 13; + } + } + Component.onCompleted: running = true + } + + property string wifiName: "Offline" + Process { + id: networkProc + command: ["sh", "-c", "~/.config/quickshell/network.sh"] + stdout: SplitParser { + onRead: data => { + var parts = data.trim().split(/\s+/) + wifiName = parts[0]; + } + } + Component.onCompleted: running = true + } + + Timer { + interval: 2000 + running: true + repeat: true + onTriggered: { + cpuProc.running = true + memProc.running = true + brightnessProc.running = true + volumeProc.running = true + batteryProc.running = true + networkProc.running = true + } + } + Process { + id: networkManagerProc + command: ["foot", "-e", "nmtui"] + Component.onCompleted: running = false + } + + anchors.top: true + anchors.left: true + anchors.right: true + implicitHeight: 32 + color: root.black + + RowLayout { + anchors.fill: parent + anchors.margins: 0 + + Repeater { + model: 5 + + Text { + property bool isActive: Hyprland.focusedWorkspace?.id === (index + 1) + + text: index + 1 + color: isActive ? root.green : root.white + font { + pixelSize: root.fontSize; + bold: true; + } + + MouseArea { + anchors.fill: parent + onClicked: Hyprland.dispatch("workspace " + (index + 1)) + } + } + } + Item { Layout.fillWidth: true } + RowLayout { + spacing: 0 + Text { + text: " Radio:" + color: root.white + font { + family: root.fontFamily + pixelSize: root.fontSize + } + } + Text { + text: wifiName + color: wifiName == "Offline" ? root.red : root.green + font { + family: root.fontFamily + pixelSize: root.fontSize + bold: true + } + + MouseArea { + anchors.fill: parent + onClicked: networkManagerProc.running = true + } + } + } + RowLayout { + spacing: 0 + Text { + text: " Electrons:" + color: root.white + font { + family: root.fontFamily + pixelSize: root.fontSize + } + } + Text { + text: battery + color: (battery <= redBatteryPoint) ? root.red : ((battery <= orangeBatteryPoint) ? root.orange : root.green) + font { + family: root.fontFamily + pixelSize: root.fontSize + bold: true + } + } + } + RowLayout { + spacing: 0 + Text { + text: " Waves:" + color: root.white + font { + family: root.fontFamily + pixelSize: root.fontSize + } + } + Text { + text: volume + color: root.green + font { + family: root.fontFamily + pixelSize: root.fontSize + bold: true + } + } + } + RowLayout { + spacing: 0 + Text { + text: " Photons:" + color: root.white + font { + family: root.fontFamily + pixelSize: root.fontSize + } + } + Text { + text: brightness + color: root.orange + font { + family: root.fontFamily + pixelSize: root.fontSize + bold: true + } + } + Text { + text: "(" + temperature + "K)" + color: root.red + font { + family: root.fontFamily + pixelSize: root.fontSize + bold: true + } + } + } + RowLayout { + spacing: 0 + Text { + text: " Radiation:" + color: root.white + font { + family: root.fontFamily + pixelSize: root.fontSize + } + } + Text { + text: cpuUsage + "K" + color: root.orange + font { + family: root.fontFamily + pixelSize: root.fontSize + bold: true + } + } + } + RowLayout { + spacing: 0 + Text { + text: " Data Bus:" + color: root.white + font { + family: root.fontFamily + pixelSize: root.fontSize + } + } + Text { + text: cpuUsage + color: root.orange + font { + family: root.fontFamily + pixelSize: root.fontSize + bold: true + } + } + } + RowLayout { + spacing: 0 + Text { + text: " Latch:" + color: root.white + font { + family: root.fontFamily + pixelSize: root.fontSize + } + } + Text { + text: memUsage + color: root.orange + font { + family: root.fontFamily + pixelSize: root.fontSize + bold: true + } + } + } + RowLayout { + spacing: 0 + Text { + text: " Spin:" + color: root.white + font { + family: root.fontFamily + pixelSize: root.fontSize + } + } + Text { + property var formatMode: "HH:mm:ss" + + id: clock + text: Qt.formatDateTime(new Date(), clock.formatMode) + color: root.purple + font { + family: root.fontFamily + pixelSize: root.fontSize + bold: true + } + + Timer { + interval: 1000 + running: true + repeat: true + onTriggered: clock.text = Qt.formatDateTime(new Date(), clock.formatMode) + } + + MouseArea { + anchors.fill: parent + onClicked: { + if (clock.formatMode === "HH:mm:ss") { + clock.formatMode = "yyyy/MM/dd, dddd" + } else { + clock.formatMode = "HH:mm:ss" + } + clock.text = Qt.formatDateTime(new Date(), clock.formatMode) + } + } + } + } + } +} diff --git a/quickshell/volume.sh b/quickshell/volume.sh new file mode 100755 index 0000000..3059255 --- /dev/null +++ b/quickshell/volume.sh @@ -0,0 +1,2 @@ +volume=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -Po '\d+(?=%)' | head -n 1) +echo "$volume" |
