forked from Shinonome/dots-hyprland
wifinetworks:big improvement, and more bugfix
This commit is contained in:
@@ -17,6 +17,8 @@ const MATERIAL_SYMBOL_SIGNAL_STRENGTH = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let connectAttempt = '';
|
let connectAttempt = '';
|
||||||
|
let networkAuth = null;
|
||||||
|
let networkAuthSSID = null;
|
||||||
|
|
||||||
const WifiNetwork = (accessPoint) => {
|
const WifiNetwork = (accessPoint) => {
|
||||||
const networkStrength = MaterialIcon(MATERIAL_SYMBOL_SIGNAL_STRENGTH[accessPoint.iconName], 'hugerass')
|
const networkStrength = MaterialIcon(MATERIAL_SYMBOL_SIGNAL_STRENGTH[accessPoint.iconName], 'hugerass')
|
||||||
@@ -35,15 +37,34 @@ const WifiNetwork = (accessPoint) => {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
return Button({
|
return Button({
|
||||||
onClicked: accessPoint.active ? () => { } : () => execAsync(`nmcli device wifi connect ${accessPoint.bssid}`)
|
onClicked: accessPoint.active ? () => {} : () => {
|
||||||
// .catch(e => {
|
connectAttempt = accessPoint.ssid;
|
||||||
// Utils.notify({
|
networkAuthSSID.label = `Connecting to: ${connectAttempt}`;
|
||||||
// summary: "Network",
|
|
||||||
// body: e,
|
// Cek apakah SSID sudah tersimpan
|
||||||
// actions: { "Open network manager": () => execAsync("nm-connection-editor").catch(print) }
|
execAsync(['nmcli', '-g', 'NAME', 'connection', 'show'])
|
||||||
// });
|
.then((savedConnections) => {
|
||||||
// })
|
const savedSSIDs = savedConnections.split('\n');
|
||||||
.catch(print),
|
|
||||||
|
if (!savedSSIDs.includes(connectAttempt)) {
|
||||||
|
// Jika SSID belum tersimpan, tampilkan input password
|
||||||
|
if (networkAuth) {
|
||||||
|
networkAuth.revealChild = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Jika SSID sudah tersimpan, sembunyikan input password
|
||||||
|
if (networkAuth) {
|
||||||
|
networkAuth.revealChild = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Langsung konek tanpa input password
|
||||||
|
execAsync(['nmcli', 'device', 'wifi', 'connect', connectAttempt])
|
||||||
|
.catch(print);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(print);
|
||||||
|
|
||||||
|
},
|
||||||
child: Box({
|
child: Box({
|
||||||
className: 'sidebar-wifinetworks-network spacing-h-10',
|
className: 'sidebar-wifinetworks-network spacing-h-10',
|
||||||
children: [
|
children: [
|
||||||
@@ -124,28 +145,108 @@ const CurrentNetwork = () => {
|
|||||||
self.label = Network.wifi.state;
|
self.label = Network.wifi.state;
|
||||||
}),
|
}),
|
||||||
})]
|
})]
|
||||||
})
|
});
|
||||||
const networkAuth = Revealer({
|
networkAuthSSID = Label({
|
||||||
|
className: 'margin-left-5',
|
||||||
|
hpack: 'start',
|
||||||
|
hexpand: true,
|
||||||
|
label: '',
|
||||||
|
});
|
||||||
|
const cancelAuthButton = Button({
|
||||||
|
className: 'txt sidebar-centermodules-rightbar-button',
|
||||||
|
label: 'Cancel',
|
||||||
|
hpack: 'end',
|
||||||
|
onClicked: () => {
|
||||||
|
networkAuth.revealChild = false;
|
||||||
|
networkAuthSSID.label = '';
|
||||||
|
networkName.children[1].label = Network.wifi?.ssid;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const authHeader = Box({
|
||||||
|
vertical: false,
|
||||||
|
hpack: 'fill',
|
||||||
|
spacing: 10,
|
||||||
|
children: [
|
||||||
|
networkAuthSSID,
|
||||||
|
cancelAuthButton
|
||||||
|
]
|
||||||
|
});
|
||||||
|
const forgetButton = Button({
|
||||||
|
label: 'Forget Network',
|
||||||
|
hexpand: true,
|
||||||
|
className: 'txt sidebar-centermodules-rightbar-button',
|
||||||
|
onClicked: () => {
|
||||||
|
execAsync(['nmcli', '-t', '-f', 'ACTIVE,NAME', 'connection', 'show'])
|
||||||
|
.then(output => {
|
||||||
|
const activeSSID = output
|
||||||
|
.split('\n')
|
||||||
|
.find(line => line.startsWith('yes:'))
|
||||||
|
?.split(':')[1];
|
||||||
|
|
||||||
|
if (activeSSID) {
|
||||||
|
execAsync(['nmcli', 'connection', 'delete', activeSSID])
|
||||||
|
.then(() => notify(`Forgot network: ${activeSSID}`))
|
||||||
|
.catch(err => notify(`Failed to forget network: ${err}`));
|
||||||
|
} else {
|
||||||
|
notify('No active network to forget');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => notify(`Error: ${err}`));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const settingsButton = Button({
|
||||||
|
label: 'Network Properties',
|
||||||
|
className: 'txt sidebar-centermodules-rightbar-button',
|
||||||
|
hexpand: true,
|
||||||
|
onClicked: () => {
|
||||||
|
Utils.execAsync('nmcli -t -f uuid connection show --active').then(uuid => {
|
||||||
|
if (uuid.trim()) {
|
||||||
|
Utils.execAsync(`nm-connection-editor --edit ${uuid.trim()}`);
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
Utils.notify('Failed to get connection UUID');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const networkProp = Box({
|
||||||
|
vertical: false,
|
||||||
|
hpack: 'fill',
|
||||||
|
homogeneous: true,
|
||||||
|
spacing: 10,
|
||||||
|
children: [
|
||||||
|
settingsButton,
|
||||||
|
forgetButton,
|
||||||
|
]
|
||||||
|
});
|
||||||
|
networkAuth = Revealer({
|
||||||
transition: 'slide_down',
|
transition: 'slide_down',
|
||||||
transitionDuration: userOptions.animations.durationLarge,
|
transitionDuration: userOptions.animations.durationLarge,
|
||||||
child: Box({
|
child: Box({
|
||||||
className: 'margin-top-10 spacing-v-5',
|
className: 'margin-top-10 spacing-v-5',
|
||||||
vertical: true,
|
vertical: true,
|
||||||
children: [
|
children: [
|
||||||
Label({
|
authHeader,
|
||||||
className: 'margin-left-5',
|
|
||||||
hpack: 'start',
|
|
||||||
label: getString("Authentication"),
|
|
||||||
}),
|
|
||||||
Entry({
|
Entry({
|
||||||
className: 'sidebar-wifinetworks-auth-entry',
|
className: 'sidebar-wifinetworks-auth-entry',
|
||||||
visibility: false,
|
visibility: false,
|
||||||
onAccept: (self) => {
|
onAccept: (self) => {
|
||||||
authLock = false;
|
authLock = false;
|
||||||
networkAuth.revealChild = false;
|
// Hapus koneksi SSID sebelum mencoba menyambung ulang
|
||||||
|
execAsync(['nmcli', 'connection', 'delete', connectAttempt])
|
||||||
|
.catch(() => {}); // Abaikan error jika SSID tidak ditemukan
|
||||||
|
|
||||||
execAsync(['nmcli', 'device', 'wifi', 'connect', connectAttempt, 'password', self.text])
|
execAsync(['nmcli', 'device', 'wifi', 'connect', connectAttempt, 'password', self.text])
|
||||||
.catch(print);
|
.then(() => {
|
||||||
}
|
connectAttempt = ''; // Reset SSID setelah koneksi berhasil
|
||||||
|
networkAuth.revealChild = false; // Sembunyikan input jika berhasil
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
// Jika koneksi gagal, tampilkan kembali input password
|
||||||
|
networkAuth.revealChild = true;
|
||||||
|
networkAuthSSID.label = `Authentication failed. Retry for: ${connectAttempt}`;
|
||||||
|
self.text = ''; // Kosongkan input untuk coba lagi
|
||||||
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
@@ -192,6 +293,7 @@ const CurrentNetwork = () => {
|
|||||||
networkAuth,
|
networkAuth,
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
|
networkProp,
|
||||||
bottomSeparator,
|
bottomSeparator,
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1039,3 +1039,17 @@ $waifu_image_overlay_transparency: 0.7;
|
|||||||
.sidebar-centermodules-scrollgradient-bottom {
|
.sidebar-centermodules-scrollgradient-bottom {
|
||||||
background: linear-gradient(to top, $layer1 0%, transparentize($layer1, 1) 1.023rem);
|
background: linear-gradient(to top, $layer1 0%, transparentize($layer1, 1) 1.023rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar-centermodules-rightbar-button {
|
||||||
|
@include full-rounding;
|
||||||
|
@include element_decel;
|
||||||
|
min-width: 6.818rem;
|
||||||
|
min-height: 2.25rem;
|
||||||
|
background-color: $layer2Hover;
|
||||||
|
color: $onLayer2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-centermodules-rightbar-button:hover,
|
||||||
|
.sidebar-centermodules-rightbar-button:focus {
|
||||||
|
background-color: $layer2Active;
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ windowrulev2 = noblur, class:.*
|
|||||||
# Specific floating windows.
|
# Specific floating windows.
|
||||||
windowrulev2 = float, class:^(blueberry\.py)$
|
windowrulev2 = float, class:^(blueberry\.py)$
|
||||||
windowrulev2 = float, class:^(steam)$
|
windowrulev2 = float, class:^(steam)$
|
||||||
|
windowrulev2 = float, class:^(nm-connection-editor)$
|
||||||
windowrulev2 = float, class:^(guifetch)$ # FlafyDev/guifetch
|
windowrulev2 = float, class:^(guifetch)$ # FlafyDev/guifetch
|
||||||
|
|
||||||
# Tiling rule for a specific app.
|
# Tiling rule for a specific app.
|
||||||
@@ -40,6 +41,11 @@ windowrulev2 = move 73% 72%, title:^([Pp]icture[-\s]?[Ii]n[-\s]?[Pp]icture)(.*)$
|
|||||||
windowrulev2 = size 25%, title:^([Pp]icture[-\s]?[Ii]n[-\s]?[Pp]icture)(.*)$
|
windowrulev2 = size 25%, title:^([Pp]icture[-\s]?[Ii]n[-\s]?[Pp]icture)(.*)$
|
||||||
windowrulev2 = float, title:^([Pp]icture[-\s]?[Ii]n[-\s]?[Pp]icture)(.*)$
|
windowrulev2 = float, title:^([Pp]icture[-\s]?[Ii]n[-\s]?[Pp]icture)(.*)$
|
||||||
windowrulev2 = pin, title:^([Pp]icture[-\s]?[Ii]n[-\s]?[Pp]icture)(.*)$
|
windowrulev2 = pin, title:^([Pp]icture[-\s]?[Ii]n[-\s]?[Pp]icture)(.*)$
|
||||||
|
windowrulev2 = size 45%, class:^(pavucontrol)$
|
||||||
|
windowrulev2 = center, class:^(pavucontrol)$
|
||||||
|
windowrulev2 = size 45%, class:^(nm-connection-editor)$
|
||||||
|
windowrulev2 = center, class:^(nm-connection-editor)$
|
||||||
|
|
||||||
|
|
||||||
# --- Tearing ---
|
# --- Tearing ---
|
||||||
windowrulev2 = immediate, title:.*\.exe
|
windowrulev2 = immediate, title:.*\.exe
|
||||||
|
|||||||
Reference in New Issue
Block a user