add networking info in bar
This commit is contained in:
parent
d216659564
commit
1f06bf5ee4
13 changed files with 179 additions and 78 deletions
12
Colors.qml
12
Colors.qml
|
|
@ -2,22 +2,10 @@ pragma ComponentBehavior: Bound
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
|
||||||
import "Colors.js" as Colors
|
import "Colors.js" as Colors
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
Process {
|
|
||||||
running: true
|
|
||||||
id: checkRosePine
|
|
||||||
command: [ "tinty", "current" ]
|
|
||||||
stdout: StdioCollector {
|
|
||||||
id: collector
|
|
||||||
}
|
|
||||||
onExited: { console.log(collector.text) }
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly property color accent: base0D
|
readonly property color accent: base0D
|
||||||
readonly property color barBg: base01
|
readonly property color barBg: base01
|
||||||
readonly property color moduleBg: Qt.hsla(base01.hslHue, base01.hslSaturation, base01.hslLightness + 0.05, 1.0)
|
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 {
|
WallPicker {
|
||||||
screenHeight: root.screen.height
|
screenHeight: root.screen.height
|
||||||
}
|
}
|
||||||
|
|
||||||
Pw {}
|
Pw {}
|
||||||
|
Netstatus {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,8 @@ BarComponent {
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: clockLayout
|
id: clockLayout
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
IconImage {
|
StyledIcon {
|
||||||
source: Quickshell.iconPath("clock-applet-symbolic")
|
iconName: "clock-alt-symbolic"
|
||||||
implicitSize: Config.iconSize
|
|
||||||
layer.enabled: true
|
|
||||||
layer.effect: MultiEffect {
|
|
||||||
colorization: 1.0
|
|
||||||
colorizationColor: Colors.text
|
|
||||||
brightness: 0.5
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
StyledText {
|
StyledText {
|
||||||
id: clockText
|
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
|
pragma ComponentBehavior: Bound
|
||||||
import Quickshell.Services.Pipewire
|
import Quickshell.Services.Pipewire
|
||||||
import Quickshell.Io
|
|
||||||
import Quickshell.Widgets
|
import Quickshell.Widgets
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
@ -13,25 +12,16 @@ import qs.modules.Services
|
||||||
|
|
||||||
BarComponent {
|
BarComponent {
|
||||||
id: root
|
id: root
|
||||||
color: clickHandler.containsMouse ? Colors.activeModuleBg : Colors.moduleBg
|
active: clickHandler.containsMouse
|
||||||
property PwNode defaultAudio: Pipewire.ready ? Pipewire.defaultAudioSink : null
|
|
||||||
property bool mute: Pipewire.ready ? defaultAudio?.audio.muted : null
|
|
||||||
implicitHeight: Config.moduleHeight
|
implicitHeight: Config.moduleHeight
|
||||||
implicitWidth: pwLayout.implicitWidth + 16
|
implicitWidth: pwLayout.implicitWidth + 16
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: pwLayout
|
id: pwLayout
|
||||||
anchors.centerIn: root
|
anchors.centerIn: root
|
||||||
spacing: 4
|
spacing: 4
|
||||||
IconImage {
|
StyledIcon {
|
||||||
source: Quickshell.iconPath(Audio.getVolumeIcon(Audio.defaultAudio))
|
iconName: Audio.getVolumeIcon(Audio.preferredAudio)
|
||||||
implicitSize: 14
|
}
|
||||||
layer.enabled: true
|
|
||||||
layer.effect: MultiEffect {
|
|
||||||
colorization: 1.0
|
|
||||||
colorizationColor: Colors.text
|
|
||||||
brightness: 0.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: Audio.percentage + "%"
|
text: Audio.percentage + "%"
|
||||||
opacity: Audio.muted ? 0.6 : 1.0
|
opacity: Audio.muted ? 0.6 : 1.0
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
import qs
|
import qs
|
||||||
import qs.settings
|
import qs.settings
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
|
@ -6,8 +7,7 @@ import qs.widgets
|
||||||
import qs.modules.Services
|
import qs.modules.Services
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import Quickshell.Widgets
|
|
||||||
import QtQuick.Effects
|
|
||||||
|
|
||||||
PopupWindow {
|
PopupWindow {
|
||||||
implicitWidth: 400
|
implicitWidth: 400
|
||||||
|
|
@ -16,15 +16,16 @@ PopupWindow {
|
||||||
anchor.gravity: Edges.Bottom | Edges.Left
|
anchor.gravity: Edges.Bottom | Edges.Left
|
||||||
anchor.margins.top: 40
|
anchor.margins.top: 40
|
||||||
color: 'transparent'
|
color: 'transparent'
|
||||||
|
grabFocus: true
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: test
|
id: root
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: Colors.moduleBg
|
color: Colors.moduleBg
|
||||||
radius: Config.rounding
|
radius: Config.rounding
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: audioLayout
|
id: audioLayout
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
anchors.margins: 10
|
anchors.margins: 10
|
||||||
spacing: 8
|
spacing: 8
|
||||||
Repeater {
|
Repeater {
|
||||||
|
|
@ -46,45 +47,29 @@ PopupWindow {
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: audioDelContainer.modelData.nickname
|
text: audioDelContainer.modelData.nickname
|
||||||
Layout.leftMargin: 10
|
Layout.leftMargin: 10
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
IconImage {
|
StyledIcon {
|
||||||
source: Quickshell.iconPath(Audio.getVolumeIcon(audioDelContainer.modelData))
|
iconName: Audio.getVolumeIcon(audioDelContainer.modelData)
|
||||||
implicitSize: 16
|
|
||||||
layer.enabled: true
|
|
||||||
layer.effect: MultiEffect {
|
|
||||||
colorization: 1.0
|
|
||||||
colorizationColor: Colors.text
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onClicked: {
|
onClicked: {
|
||||||
audioDelContainer.modelData.audio.muted = !audioDelContainer.modelData.audio.muted
|
audioDelContainer.modelData.audio.muted = !audioDelContainer.modelData.audio.muted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IconImage {
|
StyledIcon {
|
||||||
source: Quickshell.iconPath(audioDelContainer.modelData === Audio.preferredAudio ? "radio-checked-symbolic" : "radio-symbolic")
|
iconName: 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
|
|
||||||
|
|
||||||
}
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Audio.setDefaultSink(audioDelContainer.modelData)
|
Audio.setDefaultSink(audioDelContainer.modelData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Slider {
|
Slider {
|
||||||
|
|
|
||||||
|
|
@ -15,16 +15,9 @@ BarComponent {
|
||||||
implicitWidth: Config.moduleHeight
|
implicitWidth: Config.moduleHeight
|
||||||
required property int screenHeight
|
required property int screenHeight
|
||||||
id: main
|
id: main
|
||||||
IconImage {
|
StyledIcon {
|
||||||
source: Quickshell.iconPath("preferences-desktop-wallpaper-symbolic")
|
iconName: "preferences-desktop-wallpaper-symbolic"
|
||||||
implicitSize: Config.iconSize
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
layer.enabled: true
|
|
||||||
layer.effect: MultiEffect {
|
|
||||||
colorization: 1.0
|
|
||||||
colorizationColor: Colors.text
|
|
||||||
brightness: 0.5
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: clickHandler
|
id: clickHandler
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@ primaryMon=eDP-1
|
||||||
rounding=16
|
rounding=16
|
||||||
showCorners=true
|
showCorners=true
|
||||||
wallDir=file:///home/lucy/.walls
|
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