feat: bar network icon
This commit is contained in:
parent
2cfc5002d9
commit
fa5b312924
6 changed files with 87 additions and 3 deletions
|
|
@ -60,11 +60,23 @@ Item {
|
|||
anchors.right: parent.right
|
||||
|
||||
Clock {
|
||||
id: clock
|
||||
|
||||
vertical: BarConfig.vertical
|
||||
|
||||
anchors.horizontalCenter: root.get(undefined, parent.horizontalCenter)
|
||||
anchors.verticalCenter: root.get(parent.verticalCenter, undefined)
|
||||
}
|
||||
|
||||
StatusIcons {
|
||||
anchors.left: root.get(clock.right, undefined)
|
||||
anchors.leftMargin: root.get(Appearance.padding.smaller, 0)
|
||||
anchors.top: root.get(undefined, clock.bottom)
|
||||
anchors.topMargin: root.get(0, Appearance.padding.smaller)
|
||||
|
||||
anchors.horizontalCenter: root.get(undefined, parent.horizontalCenter)
|
||||
anchors.verticalCenter: root.get(parent.verticalCenter, undefined)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import "root:/services"
|
|||
import "root:/utils"
|
||||
import "root:/config"
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
StyledRect {
|
||||
id: root
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import "root:/widgets"
|
|||
import "root:/services"
|
||||
import "root:/config"
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
StyledRect {
|
||||
id: root
|
||||
|
|
|
|||
18
modules/bar/components/StatusIcons.qml
Normal file
18
modules/bar/components/StatusIcons.qml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import "root:/widgets"
|
||||
import "root:/services"
|
||||
import "root:/utils"
|
||||
import "root:/config"
|
||||
import QtQuick
|
||||
|
||||
StyledRect {
|
||||
id: root
|
||||
|
||||
readonly property color colour: Appearance.colours.rosewater
|
||||
|
||||
MaterialIcon {
|
||||
id: icon
|
||||
|
||||
text: Icons.getNetworkIcon(Network.active.strength)
|
||||
color: root.colour
|
||||
}
|
||||
}
|
||||
44
services/Network.qml
Normal file
44
services/Network.qml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
pragma Singleton
|
||||
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
readonly property AccessPoint active: AccessPoint {
|
||||
active: true
|
||||
}
|
||||
|
||||
Process {
|
||||
running: true
|
||||
command: ["nmcli", "m"]
|
||||
stdout: SplitParser {
|
||||
onRead: getNetworks.running = true
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: getNetworks
|
||||
running: true
|
||||
command: ["nmcli", "-g", "ACTIVE,SIGNAL,FREQ,SSID", "d", "w"]
|
||||
stdout: SplitParser {
|
||||
onRead: data => {
|
||||
const [active, strength, frequency, ssid] = data.split(":");
|
||||
if (active === "yes") {
|
||||
root.active.ssid = ssid;
|
||||
root.active.strength = parseInt(strength);
|
||||
root.active.frequency = parseInt(frequency);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component AccessPoint: QtObject {
|
||||
property string ssid
|
||||
property int strength
|
||||
property int frequency
|
||||
property bool active
|
||||
}
|
||||
}
|
||||
|
|
@ -152,7 +152,7 @@ Singleton {
|
|||
|
||||
property string osIcon: ""
|
||||
|
||||
function getAppCategoryIcon(name) {
|
||||
function getAppCategoryIcon(name: string): string {
|
||||
if (!name)
|
||||
return null;
|
||||
|
||||
|
|
@ -165,6 +165,18 @@ Singleton {
|
|||
return "terminal";
|
||||
}
|
||||
|
||||
function getNetworkIcon(strength: int): string {
|
||||
if (strength >= 80)
|
||||
return "signal_wifi_4_bar";
|
||||
if (strength >= 60)
|
||||
return "network_wifi_3_bar";
|
||||
if (strength >= 40)
|
||||
return "network_wifi_2_bar";
|
||||
if (strength >= 20)
|
||||
return "network_wifi_1_bar";
|
||||
return "signal_wifi_0_bar";
|
||||
}
|
||||
|
||||
FileView {
|
||||
path: "/etc/os-release"
|
||||
onLoaded: {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue