Actually updated swayshell now (I updated the one of my friend and not my own lmao)
This commit is contained in:
parent
496b047425
commit
7e56692ce1
2 changed files with 286 additions and 285 deletions
|
|
@ -15,7 +15,7 @@ Rectangle {
|
||||||
Process {
|
Process {
|
||||||
id: cpuProc
|
id: cpuProc
|
||||||
command: ["sh", "-c", "head -1 /proc/stat"]
|
command: ["sh", "-c", "head -1 /proc/stat"]
|
||||||
property double cpuUsage
|
//property double cpuUsage
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
onRead: data => {
|
onRead: data => {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|
|
||||||
|
|
@ -12,21 +12,27 @@ import QtQuick.Layouts
|
||||||
// Some credit goes to my friends Lucy and Babsi
|
// Some credit goes to my friends Lucy and Babsi
|
||||||
// Zoe here, ignore the wide ass code, emacs qml-mode adds 2 on my tab-width for some reason
|
// Zoe here, ignore the wide ass code, emacs qml-mode adds 2 on my tab-width for some reason
|
||||||
|
|
||||||
PanelWindow {
|
Variants {
|
||||||
|
model: Quickshell.screens
|
||||||
|
delegate: WlrLayershell {
|
||||||
id: root
|
id: root
|
||||||
|
layer: WlrLayer.Top
|
||||||
|
required property ShellScreen modelData
|
||||||
|
screen: modelData
|
||||||
|
|
||||||
property color colBg: "#454545"
|
readonly property color colBg: "#3c1450"
|
||||||
property color colAppBg: "#333333"
|
readonly property color colAppBg: "#1e0a28"
|
||||||
property color colFg: "#ffffff"
|
readonly property color colFg: "#d2d2d2"
|
||||||
property string fontFamily: "Hack Nerd Font"
|
readonly property color colDark: "#230f05"
|
||||||
property int fontSize: 16
|
readonly property string fontFamily: "Iosevka"
|
||||||
property int appletRadHeight: 25
|
readonly property int fontSize: 18
|
||||||
property int appletSpacing: 6
|
readonly property int appletRadHeight: 25
|
||||||
|
readonly property int appletSpacing: 6
|
||||||
|
|
||||||
|
property real lastCpuTotal: 0.0
|
||||||
|
property real lastCpuIdle: 0.0
|
||||||
|
property real cpuUsage
|
||||||
|
|
||||||
property int cpuUsage: 0
|
|
||||||
property var lastCpuIdle: 0
|
|
||||||
property var lastCpuTotal: 0
|
|
||||||
property real ramUsage: 0.00
|
property real ramUsage: 0.00
|
||||||
|
|
||||||
property var batCharMin: (UPower.displayDevice.timeToFull / 60).toFixed(2)
|
property var batCharMin: (UPower.displayDevice.timeToFull / 60).toFixed(2)
|
||||||
|
|
@ -40,140 +46,30 @@ PanelWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
implicitHeight: root.appletRadHeight + 5
|
implicitHeight: root.appletRadHeight + 10
|
||||||
margins {
|
margins {
|
||||||
right: 0 // 5
|
right: 5
|
||||||
left: 0 // 5
|
left: 5
|
||||||
top: 0 // 5
|
top: 5
|
||||||
bottom: 0
|
bottom: 0
|
||||||
}
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: barRect
|
||||||
color: root.colBg
|
color: root.colBg
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
// radius: root.appletRadHeight
|
radius: root.appletRadHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: leftRow
|
id: leftRow
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
Item {
|
|
||||||
id: rootItem
|
|
||||||
implicitWidth: root.appletRadHeight
|
|
||||||
height: root.appletRadHeight
|
|
||||||
Row {
|
|
||||||
id: workspaceRow
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.left: parent.left
|
|
||||||
leftPadding: 10
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
id: wsRepeater
|
|
||||||
model: I3.workspaces
|
|
||||||
anchors.centerIn: parent
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: workspaceNumber
|
|
||||||
property bool isOnMon: {
|
|
||||||
if (!modelData)
|
|
||||||
return false
|
|
||||||
if (!modelData.monitor)
|
|
||||||
return false
|
|
||||||
if (!rootItem.screen)
|
|
||||||
return false;
|
|
||||||
return modelData.monitor.name === rootItem.screen.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
required property var modelData
|
|
||||||
height: root.appletRadHeight * 1.1
|
|
||||||
width: root.appletRadHeight * 1.1
|
|
||||||
radius: root.appletRadHeight
|
|
||||||
color: root.colAppBg
|
|
||||||
Text {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: parent.modelData.number
|
|
||||||
color: root.colFg
|
|
||||||
opacity: workspaceNumber.modelData.focused ? 1 : 0.5
|
|
||||||
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: {parent.modelData.activate();}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
RowLayout {
|
|
||||||
id: centerRow
|
|
||||||
spacing: root.appletSpacing
|
spacing: root.appletSpacing
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
RowLayout {
|
|
||||||
id: rightRow
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
spacing: root.appletSpacing
|
|
||||||
|
|
||||||
Item {
|
|
||||||
Process {
|
|
||||||
id: cpuProc
|
|
||||||
command: ["sh", "-c", "head -1 /proc/stat"]
|
|
||||||
stdout: SplitParser {
|
|
||||||
onRead: data => {
|
|
||||||
if (!data) return
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
Process {
|
|
||||||
id: ramProc
|
|
||||||
command: ["sh", "-c", "free | grep Mem"]
|
|
||||||
stdout: SplitParser {
|
|
||||||
onRead: data => {
|
|
||||||
if (!data) return
|
|
||||||
var parts = data.trim().split(/\s+/)
|
|
||||||
var used = parseInt(parts[2]) || 0
|
|
||||||
ramUsage = used /1048576
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Component.onCompleted: running = true
|
|
||||||
}
|
|
||||||
Timer {
|
|
||||||
interval: 2000
|
|
||||||
running: true
|
|
||||||
repeat: true
|
|
||||||
onTriggered: {
|
|
||||||
cpuProc.running = true
|
|
||||||
ramProc.running = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Item {
|
|
||||||
id: procItem
|
|
||||||
Row {
|
|
||||||
id: procRow
|
|
||||||
spacing: root.appletSpacing
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
leftPadding: 10
|
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: batLoader
|
id: batLoader
|
||||||
active: true
|
active: true
|
||||||
|
Layout.leftMargin: 8
|
||||||
sourceComponent: Rectangle {
|
sourceComponent: Rectangle {
|
||||||
id: batRect
|
id: batRect
|
||||||
clip: true
|
clip: true
|
||||||
|
|
@ -209,34 +105,182 @@ PanelWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
height: root.appletRadHeight
|
id: cpuRect
|
||||||
width: cpuText.paintedWidth + 25
|
|
||||||
radius: root.appletRadHeight
|
|
||||||
color: root.colAppBg
|
color: root.colAppBg
|
||||||
|
implicitHeight: root.appletRadHeight
|
||||||
|
implicitWidth: cpuText.width + 25
|
||||||
|
radius: root.appletRadHeight
|
||||||
|
Process {
|
||||||
|
id: cpuProc
|
||||||
|
command: ["sh", "-c", "head -1 /proc/stat"]
|
||||||
|
stdout: SplitParser {
|
||||||
|
onRead: data => {
|
||||||
|
if (!data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
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);
|
||||||
|
root.cpuUsage = Math.round(100 * (1 - (idle - root.lastCpuIdle) / (total - root.lastCpuTotal)));
|
||||||
|
root.lastCpuTotal = total;
|
||||||
|
root.lastCpuIdle = idle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Component.onCompleted: running = true
|
||||||
|
}
|
||||||
|
Timer {
|
||||||
|
id: cpuProcRestarter
|
||||||
|
interval: 2000
|
||||||
|
repeat: true
|
||||||
|
running: true
|
||||||
|
onTriggered: cpuProc.running = true
|
||||||
|
}
|
||||||
Text {
|
Text {
|
||||||
id: cpuText
|
id: cpuText
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: "CPU: " + cpuUsage + "%"
|
|
||||||
color: root.colFg
|
color: root.colFg
|
||||||
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
||||||
|
text: "CPU: " + root.cpuUsage + "%"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rectangle {
|
|
||||||
height: root.appletRadHeight
|
|
||||||
width: ramText.paintedWidth + 28
|
|
||||||
radius: root.appletRadHeight
|
|
||||||
color: root.colAppBg
|
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: ramRect
|
||||||
|
implicitHeight: root.appletRadHeight
|
||||||
|
radius: root.appletRadHeight
|
||||||
|
implicitWidth: ramText.width + 25
|
||||||
|
color: root.colAppBg
|
||||||
|
Process {
|
||||||
|
id: ramProc
|
||||||
|
command: ["sh", "-c", "free | grep Mem"]
|
||||||
|
running: true
|
||||||
|
stdout: SplitParser {
|
||||||
|
onRead: data => {
|
||||||
|
if (!data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var parts = data.trim().split(/\s+/);
|
||||||
|
var used = parseInt(parts[2]) || 0;
|
||||||
|
root.ramUsage = used / 1048576;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Timer {
|
||||||
|
id: ramProcRestarter
|
||||||
|
interval: 2000
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
onTriggered: ramProc.running = true
|
||||||
|
}
|
||||||
Text {
|
Text {
|
||||||
id: ramText
|
id: ramText
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: ramRect
|
||||||
text: "RAM: " + ramUsage.toFixed(2) + " GiB"
|
text: "RAM: " + root.ramUsage.toFixed(2) + " GiB"
|
||||||
color: root.colFg
|
|
||||||
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
||||||
|
color: root.colFg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout {
|
||||||
|
id: centerRow
|
||||||
|
anchors.centerIn: parent
|
||||||
|
spacing: root.appletSpacing
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: wsItem
|
||||||
|
implicitWidth: root.appletRadHeight
|
||||||
|
height: root.appletRadHeight
|
||||||
|
Row {
|
||||||
|
id: workspaceRow
|
||||||
|
anchors.centerIn: parent
|
||||||
|
leftPadding: 10
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
id: wsRepeater
|
||||||
|
model: I3.workspaces
|
||||||
|
anchors.centerIn: parent
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: workspaceNumber
|
||||||
|
property bool isOnMon: {
|
||||||
|
if (!modelData)
|
||||||
|
return false
|
||||||
|
if (!modelData.monitor)
|
||||||
|
return false
|
||||||
|
if (!wsItem.screen)
|
||||||
|
return false;
|
||||||
|
return modelData.monitor.name === wsItem.screen.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
required property var modelData
|
||||||
|
height: root.appletRadHeight * 1.1
|
||||||
|
width: root.appletRadHeight * 1.1
|
||||||
|
radius: root.appletRadHeight
|
||||||
|
color: root.colAppBg
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: parent.modelData.number
|
||||||
|
color: root.colFg
|
||||||
|
opacity: workspaceNumber.modelData.focused ? 1 : 0.5
|
||||||
|
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {parent.modelData.activate();}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout {
|
||||||
|
id: rightRow
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
spacing: root.appletSpacing
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: trayWholeRow
|
||||||
|
Rectangle {
|
||||||
|
id: trayRect
|
||||||
|
color: root.colAppBg
|
||||||
|
visible: iconRepeater.count != 0
|
||||||
|
radius: root.appletRadHeight
|
||||||
|
Layout.fillHeight: true
|
||||||
|
implicitHeight: root.appletRadHeight
|
||||||
|
implicitWidth: iconlayout.implicitWidth + 16
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: iconlayout
|
||||||
|
anchors.centerIn: trayRect
|
||||||
|
Repeater {
|
||||||
|
id: iconRepeater
|
||||||
|
model: SystemTray.items
|
||||||
|
delegate: WrapperMouseArea {
|
||||||
|
id: iconWrapper
|
||||||
|
required property var modelData
|
||||||
|
child: IconImage {
|
||||||
|
source: iconWrapper.modelData.icon
|
||||||
|
implicitSize: 16
|
||||||
|
}
|
||||||
|
QsMenuAnchor {
|
||||||
|
id: menu
|
||||||
|
anchor.item: iconWrapper
|
||||||
|
menu: modelData.menu
|
||||||
|
}
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
onClicked: mouse => {
|
||||||
|
if (mouse.button == Qt.RightButton) {
|
||||||
|
menu.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
@ -276,12 +320,9 @@ PanelWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: clockRow
|
id: clockRow
|
||||||
|
Layout.rightMargin: 8
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: clockRect
|
id: clockRect
|
||||||
clip: true
|
clip: true
|
||||||
|
|
@ -302,46 +343,6 @@ PanelWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Row {
|
|
||||||
id: trayWholeRow
|
|
||||||
rightPadding: 10
|
|
||||||
Rectangle {
|
|
||||||
id: trayRect
|
|
||||||
color: root.colAppBg
|
|
||||||
visible: iconRepeater.count != 0
|
|
||||||
radius: root.appletRadHeight
|
|
||||||
Layout.fillHeight: true
|
|
||||||
implicitHeight: root.appletRadHeight
|
|
||||||
implicitWidth: iconlayout.implicitWidth + 16
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: iconlayout
|
|
||||||
anchors.centerIn: trayRect
|
|
||||||
Repeater {
|
|
||||||
id: iconRepeater
|
|
||||||
model: SystemTray.items
|
|
||||||
delegate: WrapperMouseArea {
|
|
||||||
id: iconWrapper
|
|
||||||
required property var modelData
|
|
||||||
child: IconImage {
|
|
||||||
source: iconWrapper.modelData.icon
|
|
||||||
implicitSize: 16
|
|
||||||
}
|
|
||||||
QsMenuAnchor {
|
|
||||||
id: menu
|
|
||||||
anchor.item: iconWrapper
|
|
||||||
menu: modelData.menu
|
|
||||||
}
|
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
||||||
onClicked: mouse => {
|
|
||||||
if (mouse.button == Qt.RightButton) {
|
|
||||||
menu.open();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue