mirror of
https://github.com/tuxdotrs/tpanel.git
synced 2026-09-19 18:19:02 +05:30
Compare commits
5 Commits
c9310e802b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
352eb99568
|
|||
|
f2268f65e7
|
|||
|
6357b949b3
|
|||
|
77c56f9945
|
|||
|
570eea59ae
|
@@ -1,6 +1,7 @@
|
|||||||
[general]
|
[general]
|
||||||
bars = 14
|
bars = 14
|
||||||
framerate = 60
|
framerate = 60
|
||||||
|
sensitivity=140
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
method = pulse
|
method = pulse
|
||||||
|
|||||||
1
assets/icons/network.svg
Normal file
1
assets/icons/network.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M14 22H10C6.22876 22 4.34315 22 3.17157 20.7881C2 19.5763 2 17.6258 2 13.725V12.2039C2 9.91549 2 8.77128 2.5192 7.82274C3.0384 6.87421 3.98695 6.28551 5.88403 5.10813L7.88403 3.86687C9.88939 2.62229 10.8921 2 12 2C13.1079 2 14.1106 2.62229 16.116 3.86687L18.116 5.10812C20.0131 6.28551 20.9616 6.87421 21.4808 7.82274C22 8.77128 22 9.91549 22 12.2039V13.725C22 17.6258 22 19.5763 20.8284 20.7881C19.6569 22 17.7712 22 14 22ZM17.4498 12.192C14.4329 8.93571 9.56706 8.93571 6.55017 12.192C6.26866 12.4959 5.79413 12.514 5.49028 12.2325C5.18643 11.951 5.16832 11.4764 5.44983 11.1726C9.06036 7.27552 14.9396 7.27552 18.5502 11.1726C18.8317 11.4764 18.8136 11.951 18.5097 12.2325C18.2059 12.514 17.7313 12.4959 17.4498 12.192ZM15.4498 14.3505C13.5375 12.2864 10.4625 12.2864 8.55019 14.3505C8.26868 14.6544 7.79415 14.6725 7.4903 14.391C7.18645 14.1095 7.16834 13.6349 7.44985 13.3311C9.95581 10.6262 14.0442 10.6262 16.5502 13.3311C16.8317 13.6349 16.8136 14.1095 16.5097 14.391C16.2059 14.6725 15.7314 14.6544 15.4498 14.3505ZM13.4499 16.5095C12.6421 15.6377 11.358 15.6377 10.5502 16.5095C10.2687 16.8134 9.79417 16.8315 9.49031 16.55C9.18646 16.2684 9.16835 15.7939 9.44986 15.4901C10.8513 13.9775 13.1488 13.9775 14.5502 15.4901C14.8317 15.7939 14.8136 16.2684 14.5098 16.55C14.2059 16.8315 13.7314 16.8134 13.4499 16.5095Z" fill="#000"></path> </g></svg>
|
||||||
|
After Width: | Height: | Size: 1.6 KiB |
@@ -11,7 +11,7 @@ Singleton {
|
|||||||
return `${Quickshell.shellPath("modules/bar")}/${name}.qml`;
|
return `${Quickshell.shellPath("modules/bar")}/${name}.qml`;
|
||||||
}
|
}
|
||||||
|
|
||||||
property var left: [root.widget("LauncherButton"), root.widget("PowerProfileWidget"), root.widget("GPUWidget"), root.widget("HomeWidget"), root.widget("MusicWidget")]
|
property var left: [root.widget("LauncherButton"), root.widget("NetworkWidget"), root.widget("PowerProfileWidget"), root.widget("GPUWidget"), root.widget("HomeWidget"), root.widget("MusicWidget")]
|
||||||
|
|
||||||
property var center: [root.widget("CavaVisualizer"), root.widget("Workspaces"), root.widget("CavaVisualizer"),]
|
property var center: [root.widget("CavaVisualizer"), root.widget("Workspaces"), root.widget("CavaVisualizer"),]
|
||||||
|
|
||||||
|
|||||||
111
flake.nix
111
flake.nix
@@ -15,66 +15,63 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs = {
|
||||||
{
|
self,
|
||||||
self,
|
nixpkgs,
|
||||||
nixpkgs,
|
quickshell,
|
||||||
quickshell,
|
treefmt-nix,
|
||||||
treefmt-nix,
|
}: let
|
||||||
}:
|
system = "x86_64-linux";
|
||||||
let
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
system = "x86_64-linux";
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
|
|
||||||
quickshellWithModules = quickshell.packages.${system}.default.withModules [
|
quickshellWithModules = quickshell.packages.${system}.default.withModules [
|
||||||
pkgs.qt6.qtbase
|
pkgs.qt6.qtbase
|
||||||
pkgs.qt6.qtdeclarative
|
pkgs.qt6.qtdeclarative
|
||||||
pkgs.qt6.qtmultimedia
|
pkgs.qt6.qtmultimedia
|
||||||
pkgs.qt6.qttranslations
|
pkgs.qt6.qttranslations
|
||||||
];
|
];
|
||||||
|
|
||||||
treefmtEval = treefmt-nix.lib.evalModule pkgs {
|
treefmtEval = treefmt-nix.lib.evalModule pkgs {
|
||||||
projectRootFile = "flake.nix";
|
projectRootFile = "flake.nix";
|
||||||
|
|
||||||
programs = {
|
programs = {
|
||||||
nixfmt.enable = true;
|
alejandra.enable = true;
|
||||||
qmlformat.enable = true;
|
qmlformat.enable = true;
|
||||||
clang-format.enable = true;
|
clang-format.enable = true;
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
rec {
|
|
||||||
formatter.${system} = treefmtEval.config.build.wrapper;
|
|
||||||
|
|
||||||
packages.${system} = {
|
|
||||||
tshell = pkgs.callPackage ./package.nix {
|
|
||||||
inherit quickshellWithModules;
|
|
||||||
};
|
|
||||||
default = packages.${system}.tshell;
|
|
||||||
};
|
|
||||||
|
|
||||||
devShells.${system}.default = pkgs.mkShell {
|
|
||||||
packages = [
|
|
||||||
quickshellWithModules
|
|
||||||
pkgs.cava
|
|
||||||
pkgs.wallust
|
|
||||||
pkgs.dbus
|
|
||||||
pkgs.cmake
|
|
||||||
pkgs.ninja
|
|
||||||
pkgs.qt6.qtbase
|
|
||||||
pkgs.qt6.qtdeclarative
|
|
||||||
];
|
|
||||||
|
|
||||||
shellHook = ''
|
|
||||||
if [ -d "$PWD/plugin/dist/lib/qt-6/qml" ]; then
|
|
||||||
export NIXPKGS_QT6_QML_IMPORT_PATH="$PWD/plugin/dist/lib/qt-6/qml''${NIXPKGS_QT6_QML_IMPORT_PATH:+:$NIXPKGS_QT6_QML_IMPORT_PATH}"
|
|
||||||
export QML2_IMPORT_PATH="$PWD/plugin/dist/lib/qt-6/qml''${QML2_IMPORT_PATH:+:$QML2_IMPORT_PATH}"
|
|
||||||
else
|
|
||||||
echo "gpu plugin is not built; run from the repo root to enable 'import Tshell.Cardwire':"
|
|
||||||
echo " cmake -S plugin -B plugin/dist -DCMAKE_INSTALL_PREFIX=\$PWD/plugin/dist"
|
|
||||||
echo " cmake --build plugin/dist --target install"
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
in rec {
|
||||||
|
formatter.${system} = treefmtEval.config.build.wrapper;
|
||||||
|
|
||||||
|
packages.${system} = {
|
||||||
|
tshell = pkgs.callPackage ./package.nix {
|
||||||
|
inherit quickshellWithModules;
|
||||||
|
};
|
||||||
|
default = packages.${system}.tshell;
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.${system}.default = pkgs.mkShell {
|
||||||
|
packages = [
|
||||||
|
quickshellWithModules
|
||||||
|
pkgs.cava
|
||||||
|
pkgs.wallust
|
||||||
|
pkgs.dbus
|
||||||
|
pkgs.cmake
|
||||||
|
pkgs.ninja
|
||||||
|
pkgs.qt6.qtbase
|
||||||
|
pkgs.qt6.qtdeclarative
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
if [ -d "$PWD/plugin/dist/lib/qt-6/qml" ]; then
|
||||||
|
export NIXPKGS_QT6_QML_IMPORT_PATH="$PWD/plugin/dist/lib/qt-6/qml''${NIXPKGS_QT6_QML_IMPORT_PATH:+:$NIXPKGS_QT6_QML_IMPORT_PATH}"
|
||||||
|
export QML2_IMPORT_PATH="$PWD/plugin/dist/lib/qt-6/qml''${QML2_IMPORT_PATH:+:$QML2_IMPORT_PATH}"
|
||||||
|
else
|
||||||
|
echo "gpu plugin is not built; run from the repo root to enable 'import Tshell.Cardwire':"
|
||||||
|
echo " cmake -S plugin -B plugin/dist -DCMAKE_INSTALL_PREFIX=\$PWD/plugin/dist"
|
||||||
|
echo " cmake --build plugin/dist --target install"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,14 +31,28 @@ Rectangle {
|
|||||||
id: bar
|
id: bar
|
||||||
|
|
||||||
required property int index
|
required property int index
|
||||||
readonly property real value: Cava.values[index] ?? 0
|
readonly property real level: Math.min(1, (Cava.values[index] ?? 0) / root.maxValue)
|
||||||
|
|
||||||
width: (barRow.width - barRow.spacing * (root.barCount - 1)) / root.barCount
|
width: (barRow.width - barRow.spacing * (root.barCount - 1)) / root.barCount
|
||||||
height: Math.max(Theme.cava.barMinHeight, (bar.value / root.maxValue) * barRow.height)
|
height: Math.max(Theme.cava.barMinHeight, Math.pow(bar.level, 0.6) * barRow.height)
|
||||||
anchors.bottom: parent.bottom
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
radius: bar.width / 2
|
radius: bar.width / 2
|
||||||
color: Theme.colors.accent
|
color: Theme.colors.accent
|
||||||
antialiasing: true
|
antialiasing: true
|
||||||
|
opacity: 0.45 + (bar.level * 0.55)
|
||||||
|
|
||||||
|
Behavior on height {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 90
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 150
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
modules/bar/NetworkWidget.qml
Normal file
11
modules/bar/NetworkWidget.qml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import qs.ui
|
||||||
|
import qs.services
|
||||||
|
|
||||||
|
BarButton {
|
||||||
|
hoverHighlight: false
|
||||||
|
pointerCursor: false
|
||||||
|
label: Network.statusText
|
||||||
|
iconSource: Network.icon
|
||||||
|
}
|
||||||
@@ -4,57 +4,141 @@ import QtQuick
|
|||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
import qs.config
|
import qs.config
|
||||||
|
|
||||||
Row {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property int count: 7
|
property int count: 7
|
||||||
|
|
||||||
spacing: Theme.spacing
|
implicitWidth: pillsRow.implicitWidth
|
||||||
|
implicitHeight: Theme.workspaces.height
|
||||||
|
Behavior on implicitWidth {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration
|
||||||
|
easing.type: Easing.OutQuint
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Repeater {
|
Row {
|
||||||
model: root.count
|
id: pillsRow
|
||||||
|
|
||||||
Rectangle {
|
anchors.fill: parent
|
||||||
id: pill
|
spacing: Theme.spacing
|
||||||
|
|
||||||
required property int index
|
Repeater {
|
||||||
property var ws: Hyprland.workspaces.values.find(w => w.id === pill.index + 1)
|
model: root.count
|
||||||
property bool isActive: Hyprland.focusedWorkspace?.id === (pill.index + 1)
|
|
||||||
|
|
||||||
radius: Theme.workspaces.radius
|
Rectangle {
|
||||||
implicitHeight: Theme.workspaces.height
|
id: pill
|
||||||
implicitWidth: pill.isActive ? pill.implicitHeight * Theme.workspaces.activeWidthRatio : pill.implicitHeight
|
|
||||||
color: {
|
|
||||||
if (handler.hovered)
|
|
||||||
return Theme.colors.accent;
|
|
||||||
if (pill.isActive || pill.ws)
|
|
||||||
return Theme.colors.accent;
|
|
||||||
return Theme.colors.inActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
required property int index
|
||||||
hoverEnabled: true
|
property var ws: Hyprland.workspaces.values.find(w => w.id === pill.index + 1)
|
||||||
anchors.fill: parent
|
property bool isActive: Hyprland.focusedWorkspace?.id === (pill.index + 1)
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: Hyprland.dispatch("workspace " + (pill.index + 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
HoverHandler {
|
z: 1
|
||||||
id: handler
|
radius: Theme.workspaces.radius
|
||||||
}
|
implicitHeight: Theme.workspaces.height
|
||||||
|
implicitWidth: pill.isActive ? pill.implicitHeight * Theme.workspaces.activeWidthRatio : pill.implicitHeight
|
||||||
Behavior on color {
|
color: {
|
||||||
ColorAnimation {
|
if (pill.isActive)
|
||||||
duration: Theme.duration
|
return "transparent";
|
||||||
|
if (handler.hovered)
|
||||||
|
return Theme.colors.accent;
|
||||||
|
if (pill.ws)
|
||||||
|
return Theme.colors.secondaryForeground;
|
||||||
|
return Theme.colors.inActive;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on implicitWidth {
|
MouseArea {
|
||||||
NumberAnimation {
|
hoverEnabled: true
|
||||||
duration: Theme.duration
|
anchors.fill: parent
|
||||||
easing.type: Easing.OutQuad
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: Hyprland.dispatch("hl.dsp.focus({ workspace = " + (pill.index + 1) + " })")
|
||||||
|
}
|
||||||
|
|
||||||
|
HoverHandler {
|
||||||
|
id: handler
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on color {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: Theme.duration + 50
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on implicitWidth {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration
|
||||||
|
easing.type: Easing.OutQuad
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: highlight
|
||||||
|
|
||||||
|
z: 2
|
||||||
|
radius: Theme.workspaces.radius
|
||||||
|
color: Theme.colors.accent
|
||||||
|
|
||||||
|
readonly property real activeW: Theme.workspaces.height * Theme.workspaces.activeWidthRatio
|
||||||
|
readonly property real inactiveW: Theme.workspaces.height
|
||||||
|
property int curIdx: Hyprland.focusedWorkspace ? Hyprland.focusedWorkspace.id - 1 : -1
|
||||||
|
property int prevIdx: 0
|
||||||
|
|
||||||
|
function getX(index, activeIndex) {
|
||||||
|
if (index < 0)
|
||||||
|
return 0;
|
||||||
|
let x = 0;
|
||||||
|
for (let i = 0; i < index; i++)
|
||||||
|
x += (i === activeIndex ? activeW : inactiveW) + pillsRow.spacing;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
property real targetLeft: curIdx >= 0 ? getX(curIdx, curIdx) : 0
|
||||||
|
property real targetRight: curIdx >= 0 ? targetLeft + activeW : 0
|
||||||
|
property real actualLeft: targetLeft
|
||||||
|
property real actualRight: targetRight
|
||||||
|
|
||||||
|
Behavior on actualLeft {
|
||||||
|
NumberAnimation {
|
||||||
|
id: leftAnim
|
||||||
|
duration: Theme.duration
|
||||||
|
easing.type: Easing.OutQuint
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on actualRight {
|
||||||
|
NumberAnimation {
|
||||||
|
id: rightAnim
|
||||||
|
duration: Theme.duration
|
||||||
|
easing.type: Easing.OutQuint
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onCurIdxChanged: {
|
||||||
|
if (curIdx >= 0 && prevIdx >= 0) {
|
||||||
|
if (curIdx > prevIdx) {
|
||||||
|
leftAnim.duration = 400;
|
||||||
|
rightAnim.duration = 300;
|
||||||
|
} else if (curIdx < prevIdx) {
|
||||||
|
leftAnim.duration = 300;
|
||||||
|
rightAnim.duration = 400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (curIdx >= 0)
|
||||||
|
prevIdx = curIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
x: actualLeft
|
||||||
|
width: actualRight - actualLeft
|
||||||
|
height: parent.height
|
||||||
|
opacity: curIdx >= 0 ? 1 : 0
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 180
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
98
package.nix
98
package.nix
@@ -10,73 +10,71 @@
|
|||||||
cava,
|
cava,
|
||||||
wallust,
|
wallust,
|
||||||
nerd-fonts,
|
nerd-fonts,
|
||||||
extraRuntimeDeps ? [ ],
|
extraRuntimeDeps ? [],
|
||||||
}:
|
}: let
|
||||||
let
|
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
|
|
||||||
runtimeDeps = [
|
runtimeDeps =
|
||||||
cava
|
[
|
||||||
wallust
|
cava
|
||||||
]
|
wallust
|
||||||
++ extraRuntimeDeps;
|
]
|
||||||
|
++ extraRuntimeDeps;
|
||||||
|
|
||||||
fontconfig = makeFontsConf {
|
fontconfig = makeFontsConf {
|
||||||
fontDirectories = [ nerd-fonts.fira-code ];
|
fontDirectories = [nerd-fonts.fira-code];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Unlike lib.fileset, this keeps untracked files (the flake only sees
|
# Unlike lib.fileset, this keeps untracked files (the flake only sees
|
||||||
# git-tracked paths) while dropping build artifacts.
|
# git-tracked paths) while dropping build artifacts.
|
||||||
src = lib.cleanSourceWith {
|
src = lib.cleanSourceWith {
|
||||||
src = lib.cleanSource ./.;
|
src = lib.cleanSource ./.;
|
||||||
filter =
|
filter = path: _: let
|
||||||
path: _:
|
name = baseNameOf path;
|
||||||
let
|
in
|
||||||
name = baseNameOf path;
|
|
||||||
in
|
|
||||||
!(name == "dist" || name == "result" || name == "result-bin" || lib.hasPrefix "build" name);
|
!(name == "dist" || name == "result" || name == "result-bin" || lib.hasPrefix "build" name);
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
inherit version src;
|
inherit version src;
|
||||||
pname = "tshell";
|
pname = "tshell";
|
||||||
|
|
||||||
dontWrapQtApps = true;
|
dontWrapQtApps = true;
|
||||||
|
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
cd plugin
|
cd plugin
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
cmake
|
cmake
|
||||||
ninja
|
ninja
|
||||||
makeWrapper
|
makeWrapper
|
||||||
];
|
];
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
qt6.qtbase
|
qt6.qtbase
|
||||||
qt6.qtdeclarative
|
qt6.qtdeclarative
|
||||||
];
|
];
|
||||||
propagatedBuildInputs = runtimeDeps;
|
propagatedBuildInputs = runtimeDeps;
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
mkdir -p $out/bin $out/share/tshell
|
mkdir -p $out/bin $out/share/tshell
|
||||||
|
|
||||||
for entry in shell.qml assets config modules services ui windows; do
|
for entry in shell.qml assets config modules services ui windows; do
|
||||||
cp -r "$src/$entry" $out/share/tshell/
|
cp -r "$src/$entry" $out/share/tshell/
|
||||||
done
|
done
|
||||||
|
|
||||||
makeWrapper ${quickshellWithModules}/bin/qs $out/bin/tshell \
|
makeWrapper ${quickshellWithModules}/bin/qs $out/bin/tshell \
|
||||||
--prefix PATH : "${lib.makeBinPath runtimeDeps}" \
|
--prefix PATH : "${lib.makeBinPath runtimeDeps}" \
|
||||||
--set FONTCONFIG_FILE "${fontconfig}" \
|
--set FONTCONFIG_FILE "${fontconfig}" \
|
||||||
--suffix NIXPKGS_QT6_QML_IMPORT_PATH : "$out/lib/qt-6/qml" \
|
--suffix NIXPKGS_QT6_QML_IMPORT_PATH : "$out/lib/qt-6/qml" \
|
||||||
--add-flags "-p $out/share/tshell"
|
--add-flags "-p $out/share/tshell"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "tux's widgets for wayland";
|
description = "tux's widgets for wayland";
|
||||||
homepage = "https://github.com/tuxdotrs/tshell";
|
homepage = "https://github.com/tuxdotrs/tshell";
|
||||||
license = lib.licenses.gpl3Only;
|
license = lib.licenses.gpl3Only;
|
||||||
mainProgram = "tshell";
|
mainProgram = "tshell";
|
||||||
platforms = lib.platforms.linux;
|
platforms = lib.platforms.linux;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
81
services/Network.qml
Normal file
81
services/Network.qml
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Networking
|
||||||
|
|
||||||
|
Singleton {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
readonly property url icon: `${Quickshell.shellPath("assets")}/icons/network.svg`
|
||||||
|
|
||||||
|
property var wifiDevice: {
|
||||||
|
for (const device of Networking.devices.values) {
|
||||||
|
if (device.type === DeviceType.Wifi)
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
property var wiredDevice: {
|
||||||
|
for (const device of Networking.devices.values) {
|
||||||
|
if (device.type === DeviceType.Wired)
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property bool ethernetConnected: !!(root.wiredDevice && root.wiredDevice.connected)
|
||||||
|
|
||||||
|
readonly property bool wifiConnected: !!(root.wifiDevice && root.wifiDevice.connected)
|
||||||
|
|
||||||
|
readonly property bool wifiConnecting: !!(root.wifiDevice && root.wifiDevice.state === ConnectionState.Connecting)
|
||||||
|
|
||||||
|
property var activeNetwork: null
|
||||||
|
|
||||||
|
function refreshActiveNetwork() {
|
||||||
|
root.activeNetwork = null;
|
||||||
|
|
||||||
|
if (!root.wifiDevice || !root.wifiDevice.networks)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (const network of root.wifiDevice.networks.values) {
|
||||||
|
if (network.connected) {
|
||||||
|
root.activeNetwork = network;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property string statusText: {
|
||||||
|
if (root.ethernetConnected)
|
||||||
|
return "Wired";
|
||||||
|
|
||||||
|
if (root.wifiConnecting)
|
||||||
|
return "Connecting";
|
||||||
|
|
||||||
|
if (root.wifiConnected && root.activeNetwork)
|
||||||
|
return root.activeNetwork.name;
|
||||||
|
|
||||||
|
return "NA";
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: root.wifiDevice ? root.wifiDevice.networks : null
|
||||||
|
|
||||||
|
function onValuesChanged() {
|
||||||
|
root.refreshActiveNetwork();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
interval: 1000
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
triggeredOnStart: true
|
||||||
|
|
||||||
|
onTriggered: {
|
||||||
|
root.refreshActiveNetwork();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user