add networking info in bar
This commit is contained in:
parent
d216659564
commit
1f06bf5ee4
13 changed files with 179 additions and 78 deletions
14
Colors.qml
14
Colors.qml
|
|
@ -2,22 +2,10 @@ pragma ComponentBehavior: Bound
|
|||
pragma Singleton
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "Colors.js" as Colors
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
Process {
|
||||
running: true
|
||||
id: checkRosePine
|
||||
command: [ "tinty", "current" ]
|
||||
stdout: StdioCollector {
|
||||
id: collector
|
||||
}
|
||||
onExited: { console.log(collector.text) }
|
||||
}
|
||||
|
||||
id: root
|
||||
readonly property color accent: base0D
|
||||
readonly property color barBg: base01
|
||||
readonly property color moduleBg: Qt.hsla(base01.hslHue, base01.hslSaturation, base01.hslLightness + 0.05, 1.0)
|
||||
|
|
|
|||
44
modules/Services/Network.qml
Normal file
44
modules/Services/Network.qml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
pragma Singleton
|
||||
import Quickshell
|
||||
import Quickshell.Networking
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
property bool wifiEnabled: Networking.wifiEnabled
|
||||
readonly property list<NetworkDevice> devices: Networking.devices.values
|
||||
property WifiDevice wifiDev: devices.find(dev => dev.type === DeviceType.Wifi) ?? null
|
||||
property WiredDevice wiredDev: devices.find(dev => dev.type === DeviceType.Wired) ?? null
|
||||
property list<WifiNetwork> wifiNetworks: wifiDev?.networks.values ?? []
|
||||
property WifiNetwork connectedNet: wifiNetworks.find(net => net.connected) ?? null
|
||||
function getWiredIcon() {
|
||||
if (wiredDev?.hasLink ?? false) {
|
||||
if (wiredDev.connected ?? false) {
|
||||
return "network-wired-activated";
|
||||
} else
|
||||
return "network-wired-unavailable";
|
||||
} else
|
||||
return "network-wired-unavailable";
|
||||
}
|
||||
function getWifiIcon() {
|
||||
Networking.checkConnectivity();
|
||||
let state = wifiDev?.state ?? ConnectionState.Unknown;
|
||||
if (state === ConnectionState.Disconnected || state === ConnectionState.Unknown)
|
||||
return "network-wireless-disconnected";
|
||||
if (state === ConnectionState.Connecting || state === ConnectionState.Disconnecting)
|
||||
return "network-wireless-acquiring";
|
||||
|
||||
if (wifiDev?.connected ?? false) {
|
||||
let strength = connectedNet?.signalStrength ?? 0.0;
|
||||
if (strength <= 0.2)
|
||||
return "network-wireless-signal-none";
|
||||
if (strength <= 0.40)
|
||||
return "network-wireless-signal-weak";
|
||||
if (strength <= 0.60)
|
||||
return "network-wireless-signal-ok";
|
||||
if (strength <= 0.80)
|
||||
return "network-wireless-signal-good";
|
||||
if (strength > 0.80)
|
||||
return "network-wireless-signal-excellect";
|
||||
}
|
||||
}
|
||||
}
|
||||
21
modules/Services/Network.qml~
Normal file
21
modules/Services/Network.qml~
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
pragma Singleton
|
||||
import Quickshell
|
||||
import Quickshell.Networking
|
||||
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
property bool wifiEnabled: Networking.wifiEnabled
|
||||
property string connectivity: Networking.connectivity.toString(Networking.connectivity)
|
||||
readonly property list<NetworkDevice> devices: Networking.devices.values
|
||||
|
||||
function getConnectedDevice() {
|
||||
for(let i=0; i < devices.length; ++i) {
|
||||
console.log(i)
|
||||
if(devices[i].connected) {
|
||||
return devices[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -46,7 +46,9 @@ Variants {
|
|||
WallPicker {
|
||||
screenHeight: root.screen.height
|
||||
}
|
||||
|
||||
Pw {}
|
||||
Netstatus {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,15 +18,8 @@ BarComponent {
|
|||
RowLayout {
|
||||
id: clockLayout
|
||||
anchors.centerIn: parent
|
||||
IconImage {
|
||||
source: Quickshell.iconPath("clock-applet-symbolic")
|
||||
implicitSize: Config.iconSize
|
||||
layer.enabled: true
|
||||
layer.effect: MultiEffect {
|
||||
colorization: 1.0
|
||||
colorizationColor: Colors.text
|
||||
brightness: 0.5
|
||||
}
|
||||
StyledIcon {
|
||||
iconName: "clock-alt-symbolic"
|
||||
}
|
||||
StyledText {
|
||||
id: clockText
|
||||
|
|
|
|||
22
modules/bar/Netstatus.qml
Normal file
22
modules/bar/Netstatus.qml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import qs.modules.Services
|
||||
import qs.widgets
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
BarComponent {
|
||||
id: root
|
||||
implicitWidth: networkLayout.implicitWidth + 24
|
||||
RowLayout {
|
||||
id: networkLayout
|
||||
anchors.centerIn: root
|
||||
spacing: 10
|
||||
StyledIcon {
|
||||
iconName: Network.getWifiIcon()
|
||||
}
|
||||
StyledIcon {
|
||||
Layout.topMargin: 2
|
||||
iconName: Network.getWiredIcon()
|
||||
visible: Network.wiredDev != null
|
||||
}
|
||||
}
|
||||
}
|
||||
29
modules/bar/Netstatus.qml~
Normal file
29
modules/bar/Netstatus.qml~
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import qs
|
||||
import qs.modules.Services
|
||||
import qs.widgets
|
||||
import qs.settings
|
||||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
BarComponent {
|
||||
id: root
|
||||
implicitWidth: networkLayout.implicitWidth + 24
|
||||
RowLayout {
|
||||
anchors.centerIn: root
|
||||
id: networkLayout
|
||||
StyledText {
|
||||
id: status
|
||||
text: Network.wifiEnabled ? "Wifi enabled :3" : "Wifi disabled :("
|
||||
}
|
||||
StyledText {
|
||||
id: wifiDevName
|
||||
text: Network.connectedWifiDev?.name ?? "not connected via wifi"
|
||||
}
|
||||
StyledText{
|
||||
id: wiredDevName
|
||||
text: Network.connectedWiredDev?.name ?? "not connected via wired"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
import Quickshell.Services.Pipewire
|
||||
import Quickshell.Io
|
||||
import Quickshell.Widgets
|
||||
import Quickshell
|
||||
import QtQuick
|
||||
|
|
@ -13,25 +12,16 @@ import qs.modules.Services
|
|||
|
||||
BarComponent {
|
||||
id: root
|
||||
color: clickHandler.containsMouse ? Colors.activeModuleBg : Colors.moduleBg
|
||||
property PwNode defaultAudio: Pipewire.ready ? Pipewire.defaultAudioSink : null
|
||||
property bool mute: Pipewire.ready ? defaultAudio?.audio.muted : null
|
||||
active: clickHandler.containsMouse
|
||||
implicitHeight: Config.moduleHeight
|
||||
implicitWidth: pwLayout.implicitWidth + 16
|
||||
RowLayout {
|
||||
id: pwLayout
|
||||
anchors.centerIn: root
|
||||
spacing: 4
|
||||
IconImage {
|
||||
source: Quickshell.iconPath(Audio.getVolumeIcon(Audio.defaultAudio))
|
||||
implicitSize: 14
|
||||
layer.enabled: true
|
||||
layer.effect: MultiEffect {
|
||||
colorization: 1.0
|
||||
colorizationColor: Colors.text
|
||||
brightness: 0.0
|
||||
}
|
||||
}
|
||||
StyledIcon {
|
||||
iconName: Audio.getVolumeIcon(Audio.preferredAudio)
|
||||
}
|
||||
StyledText {
|
||||
text: Audio.percentage + "%"
|
||||
opacity: Audio.muted ? 0.6 : 1.0
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
import qs
|
||||
import qs.settings
|
||||
import Quickshell
|
||||
|
|
@ -6,8 +7,7 @@ import qs.widgets
|
|||
import qs.modules.Services
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import Quickshell.Widgets
|
||||
import QtQuick.Effects
|
||||
|
||||
|
||||
PopupWindow {
|
||||
implicitWidth: 400
|
||||
|
|
@ -16,19 +16,20 @@ PopupWindow {
|
|||
anchor.gravity: Edges.Bottom | Edges.Left
|
||||
anchor.margins.top: 40
|
||||
color: 'transparent'
|
||||
grabFocus: true
|
||||
Rectangle {
|
||||
id: test
|
||||
id: root
|
||||
anchors.fill: parent
|
||||
color: Colors.moduleBg
|
||||
radius: Config.rounding
|
||||
ColumnLayout {
|
||||
id: audioLayout
|
||||
anchors.fill: parent
|
||||
anchors.centerIn: parent
|
||||
anchors.centerIn: parent
|
||||
anchors.margins: 10
|
||||
spacing: 8
|
||||
Repeater {
|
||||
|
||||
|
||||
model: Audio.sinks
|
||||
delegate: Rectangle {
|
||||
id: audioDelContainer
|
||||
|
|
@ -46,45 +47,29 @@ PopupWindow {
|
|||
|
||||
StyledText {
|
||||
text: audioDelContainer.modelData.nickname
|
||||
Layout.leftMargin: 10
|
||||
Layout.leftMargin: 10
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
IconImage {
|
||||
source: Quickshell.iconPath(Audio.getVolumeIcon(audioDelContainer.modelData))
|
||||
implicitSize: 16
|
||||
layer.enabled: true
|
||||
layer.effect: MultiEffect {
|
||||
colorization: 1.0
|
||||
colorizationColor: Colors.text
|
||||
|
||||
|
||||
}
|
||||
StyledIcon {
|
||||
iconName: Audio.getVolumeIcon(audioDelContainer.modelData)
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onClicked: {
|
||||
audioDelContainer.modelData.audio.muted = !audioDelContainer.modelData.audio.muted
|
||||
}
|
||||
onClicked: {
|
||||
audioDelContainer.modelData.audio.muted = !audioDelContainer.modelData.audio.muted;
|
||||
}
|
||||
}
|
||||
}
|
||||
IconImage {
|
||||
source: Quickshell.iconPath(audioDelContainer.modelData === Audio.preferredAudio ? "radio-checked-symbolic" : "radio-symbolic")
|
||||
implicitSize: 16
|
||||
layer.enabled: true
|
||||
layer.effect: MultiEffect {
|
||||
colorization: 1.0
|
||||
colorizationColor: Colors.text
|
||||
brightness: 0.5
|
||||
|
||||
}
|
||||
StyledIcon {
|
||||
iconName: audioDelContainer.modelData === Audio.preferredAudio ? "radio-checked-symbolic" : "radio-symbolic"
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onClicked: {
|
||||
Audio.setDefaultSink(audioDelContainer.modelData)
|
||||
}
|
||||
onClicked: {
|
||||
Audio.setDefaultSink(audioDelContainer.modelData);
|
||||
}
|
||||
}
|
||||
}
|
||||
Slider {
|
||||
|
|
|
|||
|
|
@ -15,16 +15,9 @@ BarComponent {
|
|||
implicitWidth: Config.moduleHeight
|
||||
required property int screenHeight
|
||||
id: main
|
||||
IconImage {
|
||||
source: Quickshell.iconPath("preferences-desktop-wallpaper-symbolic")
|
||||
implicitSize: Config.iconSize
|
||||
StyledIcon {
|
||||
iconName: "preferences-desktop-wallpaper-symbolic"
|
||||
anchors.centerIn: parent
|
||||
layer.enabled: true
|
||||
layer.effect: MultiEffect {
|
||||
colorization: 1.0
|
||||
colorizationColor: Colors.text
|
||||
brightness: 0.5
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
id: clickHandler
|
||||
|
|
|
|||
|
|
@ -9,4 +9,4 @@ primaryMon=eDP-1
|
|||
rounding=16
|
||||
showCorners=true
|
||||
wallDir=file:///home/lucy/.walls
|
||||
wallpaper=@Variant(\0\0\0\x11\0\0\0\x1b/home/lucy/.walls/faris.png)
|
||||
wallpaper=@Variant(\0\0\0\x11\0\0\0\x1f/home/lucy/.walls/lain_blue.png)
|
||||
|
|
|
|||
17
widgets/StyledIcon.qml
Normal file
17
widgets/StyledIcon.qml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
import QtQuick.Effects
|
||||
import qs
|
||||
import qs.settings
|
||||
|
||||
IconImage {
|
||||
required property string iconName
|
||||
implicitSize: Config.iconSize
|
||||
source: Quickshell.iconPath(iconName)
|
||||
layer.enabled: true
|
||||
layer.effect: MultiEffect {
|
||||
colorization: 1.0
|
||||
colorizationColor: Colors.text
|
||||
brightness: 1.0
|
||||
}
|
||||
}
|
||||
17
widgets/StyledIcon.qml~
Normal file
17
widgets/StyledIcon.qml~
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
import QtQuick.Effects
|
||||
import qs
|
||||
import qs.settings
|
||||
|
||||
IconImage {
|
||||
required property string iconName
|
||||
implicitSize: Config.iconSize
|
||||
source: iconName
|
||||
layer.enabled: true
|
||||
layer.effect: MultiEffect {
|
||||
colorization: 1.0
|
||||
colorizationColor: Colors.text
|
||||
brightness: 0.5
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue