move hardcoded network values to configuration file

This commit is contained in:
Franek 2025-05-19 20:26:35 +02:00
parent d05f6174b7
commit e9e35035e0
2 changed files with 12 additions and 3 deletions

View File

@ -1,5 +1,9 @@
{ {
"SHELL": "fish", "SHELL": "fish",
"IDLE_INHIBIT_SCRIPT": "$HOME/.config/hypr/scripts/idle-inhibitor.py", "IDLE_INHIBIT_SCRIPT": "$HOME/.config/hypr/scripts/idle-inhibitor.py",
"SWITCH_THEME_SCRIPT": "command -v darkman &>/dev/null && darkman toggle" "SWITCH_THEME_SCRIPT": "command -v darkman &>/dev/null && darkman toggle",
"NETWORK_INTERFACES": {
"wired": "enp0s31f6",
"wifi": "wlp4s0"
}
} }

View File

@ -1,6 +1,8 @@
import { NETWORK_INTERFACES } from "@/settings.json";
import { toHumanReadable } from "@/lib/utils";
import Network from "gi://AstalNetwork"; import Network from "gi://AstalNetwork";
import { bind, Variable } from "astal"; import { bind, Variable } from "astal";
import { toHumanReadable } from "@/lib/utils";
type IpOutput = Array<{ type IpOutput = Array<{
ifname: string; ifname: string;
@ -43,7 +45,10 @@ export default function NetworkInfo() {
} }
}) })
const networkInterface = net.primary == 1 ? "enp0s31f6" : "wlp4s0"; const networkInterface = net.primary == 1
? NETWORK_INTERFACES.wired
: NETWORK_INTERFACES.wifi;
const networkUsage = Variable<Usage>({ const networkUsage = Variable<Usage>({
initialRx: null, initialRx: null,
initialTx: null, initialTx: null,