Switched to Codeberg
This commit is contained in:
commit
a611bcdf15
29 changed files with 2302 additions and 0 deletions
64
quickshell/modules/bar/Bar.qml
Normal file
64
quickshell/modules/bar/Bar.qml
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import qs
|
||||
|
||||
Variants {
|
||||
model: Quickshell.screens
|
||||
// Variants so that we get a bar on all monitors
|
||||
delegate: WlrLayershell {
|
||||
// use wlrlayershell instead of panelwindow because it's almost the same except wlrlayershell is easier to work with
|
||||
id: root
|
||||
layer: WlrLayer.Top
|
||||
required property ShellScreen modelData
|
||||
screen: modelData
|
||||
implicitHeight: Appearance.appletRadHeight + 10
|
||||
color: 'transparent'
|
||||
anchors {
|
||||
top: true
|
||||
left: true
|
||||
right: true
|
||||
}
|
||||
margins {
|
||||
right: 5
|
||||
left: 5
|
||||
top: 5
|
||||
bottom: 0
|
||||
}
|
||||
Rectangle {
|
||||
id: barContainer
|
||||
anchors.fill: parent
|
||||
color: Appearance.colBg
|
||||
radius: Appearance.appletRadHeight
|
||||
RowLayout {
|
||||
id: leftLayout
|
||||
spacing: Appearance.appletSpacing
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
Battery {
|
||||
//Layout.leftMargin: ((Appearance.appletRadHeight + 10) - Appearance.appletRadHeight) / 2 // to have the same padding on the left no matter what the height it
|
||||
Layout.leftMargin: 8 // ^ This but simpler i guess
|
||||
}
|
||||
Cpu {}
|
||||
Mem {}
|
||||
}
|
||||
RowLayout {
|
||||
id: centerLayout
|
||||
anchors.centerIn: parent
|
||||
MangoWs {}
|
||||
}
|
||||
RowLayout {
|
||||
id: rightLayout
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
Tray {}
|
||||
Pw {}
|
||||
Clock {
|
||||
//Layout.rightMargin: ((Appearance.appletRadHeight + 10) - Appearance.appletRadHeight) / 2 // to have the same padding on the left no matter what the height it
|
||||
Layout.rightMargin: 8 // ^ This but again simpler?
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
43
quickshell/modules/bar/Battery.qml
Normal file
43
quickshell/modules/bar/Battery.qml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import Quickshell.Services.UPower
|
||||
import QtQuick
|
||||
import qs
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
clip: true
|
||||
color: Appearance.colAppBg
|
||||
visible: UPower.displayDevice.isPresent
|
||||
property var batCharMin: (UPower.displayDevice.timeToFull / 60).toFixed(2)
|
||||
property var batDisMin: (UPower.displayDevice.timeToEmpty / 60).toFixed(2)
|
||||
property var batTime: 0
|
||||
implicitHeight: Appearance.appletRadHeight
|
||||
implicitWidth: batText.implicitWidth + 25
|
||||
radius: Appearance.appletRadHeight
|
||||
|
||||
function getBatStat() {
|
||||
if (UPower.displayDevice.state == UPowerDeviceState.Discharging) {
|
||||
batTime = Math.floor(batDisMin / 60) + "h " + ((batDisMin - (Math.floor(batDisMin / 60) * 60)).toFixed(0)) + "min"
|
||||
return batTime;
|
||||
}
|
||||
if (UPower.displayDevice.state == UPowerDeviceState.Charging) {
|
||||
batTime = Math.floor(batCharMin / 60) + "h " + ((batCharMin - (Math.floor(batCharMin / 60) * 60)).toFixed(0)) + "min"
|
||||
return batTime;
|
||||
}
|
||||
if (UPower.displayDevice.state == UPowerDeviceState.FullyCharged) {
|
||||
return "Full";
|
||||
}
|
||||
}
|
||||
function batStatProc() {
|
||||
return Math.round(UPower.displayDevice.percentage * 100) + "%";
|
||||
}
|
||||
|
||||
Text {
|
||||
id: batText
|
||||
anchors.centerIn: parent
|
||||
text: batStatProc() + " - " + getBatStat()
|
||||
font.family: Appearance.font
|
||||
font.pixelSize: Appearance.fontSize
|
||||
font.bold: true
|
||||
color: Appearance.colFg
|
||||
}
|
||||
}
|
||||
25
quickshell/modules/bar/Clock.qml
Normal file
25
quickshell/modules/bar/Clock.qml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import Quickshell
|
||||
import QtQuick
|
||||
import qs
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
clip: true
|
||||
implicitHeight: Appearance.appletRadHeight
|
||||
implicitWidth: clockText.implicitWidth + 25
|
||||
color: Appearance.colAppBg
|
||||
radius: Appearance.appletRadHeight
|
||||
SystemClock {
|
||||
id: clock
|
||||
precision: SystemClock.Seconds
|
||||
}
|
||||
Text {
|
||||
id: clockText
|
||||
anchors.centerIn: root
|
||||
font.family: Appearance.font
|
||||
font.pixelSize: Appearance.fontSize
|
||||
font.bold: true
|
||||
color: Appearance.colFg
|
||||
text: Qt.formatDateTime(clock.date, "yyyy.mm.dd - hh:mm:ss")
|
||||
}
|
||||
}
|
||||
52
quickshell/modules/bar/Cpu.qml
Normal file
52
quickshell/modules/bar/Cpu.qml
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
import qs
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
property real lastCpuTotal: 0.0
|
||||
property real lastCpuIdle: 0.0
|
||||
property real cpuUsage: 0.0
|
||||
color: Appearance.colAppBg
|
||||
implicitHeight: Appearance.appletRadHeight
|
||||
implicitWidth: cpuText.width + 25
|
||||
radius: Appearance.appletRadHeight
|
||||
Process {
|
||||
id: cpuProc
|
||||
command: ["sh", "-c", "head -1 /proc/stat"]
|
||||
property double cpuUsage
|
||||
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 {
|
||||
font.family: Appearance.font
|
||||
font.pixelSize: Appearance.fontSize
|
||||
font.bold: true
|
||||
color: Appearance.colFg
|
||||
id: cpuText
|
||||
anchors.centerIn: parent
|
||||
text: "CPU: " + root.cpuUsage + "%"
|
||||
}
|
||||
}
|
||||
50
quickshell/modules/bar/MangoWs.qml
Normal file
50
quickshell/modules/bar/MangoWs.qml
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell.WindowManager
|
||||
import qs
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
color: Appearance.colAppBg
|
||||
RowLayout {
|
||||
id: wsNumLayout
|
||||
anchors.centerIn: parent
|
||||
spacing: 2
|
||||
Repeater {
|
||||
id: wsNumRepeater
|
||||
model: WindowManager.windowsets
|
||||
Rectangle {
|
||||
required property var modelData
|
||||
function isOverview() {
|
||||
if (modelData.name == "overview") {
|
||||
return 85 + Appearance.appletRadHeight;
|
||||
}
|
||||
else {
|
||||
return Appearance.appletRadHeight;
|
||||
}
|
||||
}
|
||||
id: wsNum
|
||||
implicitWidth: isOverview()
|
||||
implicitHeight: Appearance.appletRadHeight
|
||||
color: Appearance.colAppBg
|
||||
radius: Appearance.appletRadHeight
|
||||
visible: modelData.shouldDisplay
|
||||
Text {
|
||||
id: wsText
|
||||
anchors.centerIn: parent
|
||||
text: modelData.name
|
||||
color: Appearance.colFg
|
||||
opacity: modelData.active ? 1 : 0.3
|
||||
font {
|
||||
family: Appearance.font
|
||||
pixelSize: Appearance.fontSize
|
||||
bold: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
44
quickshell/modules/bar/Mem.qml
Normal file
44
quickshell/modules/bar/Mem.qml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
import qs
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
property real ramUsage
|
||||
implicitHeight: Appearance.appletRadHeight
|
||||
radius: Appearance.appletRadHeight
|
||||
implicitWidth: ramText.width + 25
|
||||
color: Appearance.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 {
|
||||
id: ramText
|
||||
anchors.centerIn: root
|
||||
text: "RAM: " + root.ramUsage.toFixed(2) + " GiB"
|
||||
font.family: Appearance.font
|
||||
font.pixelSize: Appearance.fontSize
|
||||
font.bold: true
|
||||
color: Appearance.colFg
|
||||
}
|
||||
}
|
||||
42
quickshell/modules/bar/Pw.qml
Normal file
42
quickshell/modules/bar/Pw.qml
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import Quickshell.Services.Pipewire
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
import qs
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
color: Appearance.colAppBg
|
||||
property PwNode defaultAudio: Pipewire.ready ? Pipewire.preferredDefaultAudioSink : null
|
||||
property bool mute: Pipewire.ready ? defaultAudio?.audio.muted : null
|
||||
radius: Appearance.appletRadHeight
|
||||
implicitHeight: Appearance.appletRadHeight
|
||||
implicitWidth: pwText.implicitWidth + 25
|
||||
PwObjectTracker {
|
||||
objects: [Pipewire.ready ? Pipewire.defaultAudioSink : null]
|
||||
}
|
||||
|
||||
Process {
|
||||
id: pavuLauncher
|
||||
command: ["pavucontrol"]
|
||||
running: false
|
||||
}
|
||||
|
||||
Text {
|
||||
id: pwText
|
||||
font.family: Appearance.font
|
||||
font.pixelSize: Appearance.fontSize
|
||||
font.bold: true
|
||||
color: Appearance.colFg
|
||||
anchors.centerIn: root
|
||||
text: root.mute ? "MUT: " + Math.floor(root.defaultAudio?.audio.volume * 100) + "%" : "VOL: " + Math.floor(root.defaultAudio?.audio.volume * 100) + "%"
|
||||
opacity: root.defaultAudio?.audio.muted ? 0.6 : 1.0
|
||||
}
|
||||
MouseArea {
|
||||
id: clickHandler
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.LeftButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
anchors.fill: root
|
||||
onClicked: pavuLauncher.running = true
|
||||
}
|
||||
}
|
||||
45
quickshell/modules/bar/Tray.qml
Normal file
45
quickshell/modules/bar/Tray.qml
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
import Quickshell
|
||||
import Quickshell.Services.SystemTray
|
||||
import Quickshell.Widgets
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import qs
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
color: Appearance.colAppBg
|
||||
visible: iconRepeater.count != 0
|
||||
radius: Appearance.appletRadHeight
|
||||
Layout.fillHeight: true
|
||||
implicitHeight: Appearance.appletRadHeight
|
||||
implicitWidth: iconlayout.implicitWidth + 16
|
||||
|
||||
RowLayout {
|
||||
id: iconlayout
|
||||
anchors.centerIn: root
|
||||
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