Updated QuickSettings, added list of nmcli vpn connections with functionality for toggling the vpn connection
This commit is contained in:
1 parent
ea17c08587
commit
81de20ca68
4 files changed
+176
-37
No files matched your search
Generated
+6
-3
@@ -1,9 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ags",
|
"name": "tacitshell",
|
||||||
|
"version": "0.1.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
|
"name": "tacitshell",
|
||||||
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ags": "*",
|
"ags": "*",
|
||||||
"gnim": "*",
|
"gnim": "*",
|
||||||
@@ -19,7 +22,7 @@
|
|||||||
},
|
},
|
||||||
"../../../../usr/share/ags/js": {
|
"../../../../usr/share/ags/js": {
|
||||||
"name": "ags",
|
"name": "ags",
|
||||||
"version": "3.1.0",
|
"version": "3.1.2",
|
||||||
"license": "LGPL-2.1",
|
"license": "LGPL-2.1",
|
||||||
"os": [
|
"os": [
|
||||||
"linux"
|
"linux"
|
||||||
@@ -38,7 +41,7 @@
|
|||||||
"url": "https://ko-fi.com/aylur"
|
"url": "https://ko-fi.com/aylur"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"gnim": "^1.9.0"
|
"gnim": "^1.9.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"../../../../usr/share/ags/js/node_modules/gnim": {
|
"../../../../usr/share/ags/js/node_modules/gnim": {
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "qileshell",
|
"name": "tacitshell",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ags": "*",
|
"ags": "*",
|
||||||
|
|||||||
+55
-13
@@ -3,7 +3,6 @@
|
|||||||
$fg-color: wal.$foreground;
|
$fg-color: wal.$foreground;
|
||||||
$bg-color: rgba(wal.$background, 0.8);
|
$bg-color: rgba(wal.$background, 0.8);
|
||||||
|
|
||||||
// Unified sizing variables
|
|
||||||
$btn-height: 30px;
|
$btn-height: 30px;
|
||||||
$btn-radius: 8px;
|
$btn-radius: 8px;
|
||||||
$btn-margin: 4px 2px;
|
$btn-margin: 4px 2px;
|
||||||
@@ -27,18 +26,12 @@ window.Bar {
|
|||||||
padding: 0 4px;
|
padding: 0 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base button styling for absolute uniformity
|
|
||||||
button {
|
button {
|
||||||
border-radius: $btn-radius;
|
border-radius: $btn-radius;
|
||||||
margin: $btn-margin;
|
margin: $btn-margin;
|
||||||
min-height: $btn-height;
|
min-height: $btn-height;
|
||||||
transition: all 0.2s ease-in-out;
|
transition: all 0.2s ease-in-out;
|
||||||
background: rgba(
|
background: rgba(150, 150, 150, 0.1);
|
||||||
150,
|
|
||||||
150,
|
|
||||||
150,
|
|
||||||
0.1
|
|
||||||
); // Slight base background for all buttons
|
|
||||||
border: none;
|
border: none;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
|
|
||||||
@@ -49,14 +42,14 @@ window.Bar {
|
|||||||
|
|
||||||
.workspaces {
|
.workspaces {
|
||||||
.workspace-btn {
|
.workspace-btn {
|
||||||
min-width: $btn-height; // Base square size
|
min-width: $btn-height;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border-radius: 100px; // Pill shape instead of blocky squares
|
border-radius: 100px;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
|
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
min-width: 45px; // Horizontal expansion, slightly less wide
|
min-width: 45px;
|
||||||
background-color: wal.$color2;
|
background-color: wal.$color2;
|
||||||
color: wal.$background;
|
color: wal.$background;
|
||||||
}
|
}
|
||||||
@@ -108,12 +101,11 @@ window.Bar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Icon-only control buttons (wallpaper, settings, power, etc)
|
|
||||||
.control-btn,
|
.control-btn,
|
||||||
.wallpaper-btn,
|
.wallpaper-btn,
|
||||||
.power-btn {
|
.power-btn {
|
||||||
min-width: $btn-height;
|
min-width: $btn-height;
|
||||||
padding: 0; // Square buttons should have 0 padding, width handles size
|
padding: 0;
|
||||||
image {
|
image {
|
||||||
-gtk-icon-size: $icon-size;
|
-gtk-icon-size: $icon-size;
|
||||||
}
|
}
|
||||||
@@ -215,3 +207,53 @@ window.PowerMenu {
|
|||||||
transition: all 0.2s ease-in-out;
|
transition: all 0.2s ease-in-out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.media-controls {
|
||||||
|
.media-ctrl-btn {
|
||||||
|
border-radius: 50%;
|
||||||
|
min-width: 40px;
|
||||||
|
min-height: 40px;
|
||||||
|
padding: 0;
|
||||||
|
background: rgba(wal.$foreground, 0.08);
|
||||||
|
border: 1px solid rgba(wal.$foreground, 0.1);
|
||||||
|
transition: all 0.2s ease-in-out;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgba(wal.$foreground, 0.18);
|
||||||
|
transform: scale(1.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
transform: scale(0.95);
|
||||||
|
background: rgba(wal.$foreground, 0.25);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.play-pause-btn {
|
||||||
|
min-width: 48px;
|
||||||
|
min-height: 48px;
|
||||||
|
background: wal.$color2;
|
||||||
|
color: wal.$background;
|
||||||
|
border: none;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgba(wal.$color2, 0.85);
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
image {
|
||||||
|
color: wal.$background;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.skip-btn {
|
||||||
|
background: transparent;
|
||||||
|
border: 1.5px solid rgba(wal.$foreground, 0.2);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgba(wal.$foreground, 0.1);
|
||||||
|
border-color: rgba(wal.$foreground, 0.35);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+114
-20
@@ -2,37 +2,75 @@ import { Gtk } from "ags/gtk4"
|
|||||||
import AstalNetwork from "gi://AstalNetwork?version=0.1"
|
import AstalNetwork from "gi://AstalNetwork?version=0.1"
|
||||||
import AstalBluetooth from "gi://AstalBluetooth?version=0.1"
|
import AstalBluetooth from "gi://AstalBluetooth?version=0.1"
|
||||||
import AstalWp from "gi://AstalWp?version=0.1"
|
import AstalWp from "gi://AstalWp?version=0.1"
|
||||||
import { createBinding } from "ags"
|
import { createBinding, createComputed, createState, For } from "ags"
|
||||||
import { execAsync } from "ags/process"
|
import { interval } from "ags/time"
|
||||||
|
import { exec, execAsync } from "ags/process"
|
||||||
|
|
||||||
|
interface VpnConn {
|
||||||
|
name: string
|
||||||
|
active: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const VPN_TYPES = new Set(["vpn", "wireguard"])
|
||||||
|
|
||||||
|
function fetchVpns(): VpnConn[] {
|
||||||
|
try {
|
||||||
|
const stdout = exec([
|
||||||
|
"nmcli",
|
||||||
|
"-t",
|
||||||
|
"-f",
|
||||||
|
"NAME,TYPE,DEVICE",
|
||||||
|
"connection",
|
||||||
|
"show",
|
||||||
|
])
|
||||||
|
return stdout
|
||||||
|
.trim()
|
||||||
|
.split("\n")
|
||||||
|
.map((line) => line.split(":"))
|
||||||
|
.filter(([, type]) => VPN_TYPES.has(type))
|
||||||
|
.map(([name, , device]) => ({ name, active: !!device }))
|
||||||
|
} catch (e) {
|
||||||
|
console.error("nmcli query failed:", e)
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [vpns, setVpns] = createState<VpnConn[]>(fetchVpns())
|
||||||
|
|
||||||
|
interval(2000, () => setVpns(fetchVpns()))
|
||||||
|
|
||||||
|
const vpnActive = vpns((list) => list.some((c) => c.active))
|
||||||
|
|
||||||
function NetworkItem() {
|
function NetworkItem() {
|
||||||
const network = AstalNetwork.Network.get_default()
|
const network = AstalNetwork.Network.get_default()
|
||||||
|
const primary = createBinding(network, "primary")
|
||||||
|
|
||||||
return (
|
const label = createComputed(() => {
|
||||||
<box spacing={12} valign={Gtk.Align.CENTER} cssClasses={["qs-item"]}>
|
const p = primary()
|
||||||
<image
|
|
||||||
iconName={createBinding(network, "primary").as((p) => {
|
|
||||||
if (p === AstalNetwork.Primary.WIFI && network.wifi) {
|
|
||||||
return network.wifi.icon_name
|
|
||||||
} else if (p === AstalNetwork.Primary.WIRED && network.wired) {
|
|
||||||
return network.wired.icon_name
|
|
||||||
}
|
|
||||||
return "network-offline-symbolic"
|
|
||||||
})}
|
|
||||||
cssClasses={["qs-icon"]}
|
|
||||||
/>
|
|
||||||
<label
|
|
||||||
label={createBinding(network, "primary").as((p) => {
|
|
||||||
if (p === AstalNetwork.Primary.WIFI && network.wifi) {
|
if (p === AstalNetwork.Primary.WIFI && network.wifi) {
|
||||||
return network.wifi.ssid || "Unknown Wi-Fi"
|
return network.wifi.ssid || "Unknown Wi-Fi"
|
||||||
} else if (p === AstalNetwork.Primary.WIRED) {
|
} else if (p === AstalNetwork.Primary.WIRED) {
|
||||||
return "Wired Connection"
|
return "Wired Connection"
|
||||||
}
|
}
|
||||||
return "Disconnected"
|
return vpnActive() ? "Connected to VPN" : "Disconnected"
|
||||||
|
})
|
||||||
|
|
||||||
|
return (
|
||||||
|
<box spacing={12} valign={Gtk.Align.CENTER} cssClasses={["qs-item"]}>
|
||||||
|
<image
|
||||||
|
iconName={primary.as((p) => {
|
||||||
|
if (p === AstalNetwork.Primary.WIFI && network.wifi) {
|
||||||
|
return network.wifi.icon_name
|
||||||
|
} else if (p === AstalNetwork.Primary.WIRED && network.wired) {
|
||||||
|
return network.wired.icon_name
|
||||||
|
}
|
||||||
|
return vpnActive()
|
||||||
|
? "network-vpn-symbolic"
|
||||||
|
: "network-offline-symbolic"
|
||||||
})}
|
})}
|
||||||
halign={Gtk.Align.START}
|
cssClasses={["qs-icon"]}
|
||||||
hexpand
|
|
||||||
/>
|
/>
|
||||||
|
<label label={label} halign={Gtk.Align.START} hexpand />
|
||||||
</box>
|
</box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -97,6 +135,61 @@ function AudioSlider({ type }: { type: "speaker" | "microphone" }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function VpnList() {
|
||||||
|
const isEmpty = vpns((list) => list.length === 0)
|
||||||
|
|
||||||
|
function toggle(conn: VpnConn) {
|
||||||
|
const cmd = conn.active
|
||||||
|
? ["nmcli", "connection", "down", conn.name]
|
||||||
|
: ["nmcli", "connection", "up", conn.name]
|
||||||
|
execAsync(cmd)
|
||||||
|
.then(() => setVpns(fetchVpns()))
|
||||||
|
.catch((e) => console.error("VPN toggle failed:", e))
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<box orientation={Gtk.Orientation.VERTICAL} spacing={8}>
|
||||||
|
<label label="VPN" cssClasses={["qs-title"]} halign={Gtk.Align.START} />
|
||||||
|
<box
|
||||||
|
spacing={12}
|
||||||
|
valign={Gtk.Align.CENTER}
|
||||||
|
cssClasses={["qs-item"]}
|
||||||
|
visible={isEmpty}
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
label="No VPN connections configured"
|
||||||
|
halign={Gtk.Align.START}
|
||||||
|
hexpand
|
||||||
|
/>
|
||||||
|
</box>
|
||||||
|
<For each={vpns}>
|
||||||
|
{(conn: VpnConn) => (
|
||||||
|
<box spacing={12} valign={Gtk.Align.CENTER} cssClasses={["qs-item"]}>
|
||||||
|
<image
|
||||||
|
iconName={
|
||||||
|
conn.active
|
||||||
|
? "network-vpn-symbolic"
|
||||||
|
: "network-vpn-no-route-symbolic"
|
||||||
|
}
|
||||||
|
cssClasses={["qs-icon"]}
|
||||||
|
/>
|
||||||
|
<label label={conn.name} halign={Gtk.Align.START} hexpand />
|
||||||
|
<switch
|
||||||
|
valign={Gtk.Align.CENTER}
|
||||||
|
active={conn.active}
|
||||||
|
onNotifyActive={(sw) => {
|
||||||
|
if (sw.get_active() !== conn.active) {
|
||||||
|
toggle(conn)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</box>
|
||||||
|
)}
|
||||||
|
</For>
|
||||||
|
</box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default function QuickSettings() {
|
export default function QuickSettings() {
|
||||||
return (
|
return (
|
||||||
<menubutton
|
<menubutton
|
||||||
@@ -119,6 +212,7 @@ export default function QuickSettings() {
|
|||||||
<NetworkItem />
|
<NetworkItem />
|
||||||
<BluetoothItem />
|
<BluetoothItem />
|
||||||
</box>
|
</box>
|
||||||
|
<VpnList />
|
||||||
<box orientation={Gtk.Orientation.VERTICAL} spacing={8}>
|
<box orientation={Gtk.Orientation.VERTICAL} spacing={8}>
|
||||||
<button
|
<button
|
||||||
cssClasses={["qs-title"]}
|
cssClasses={["qs-title"]}
|
||||||
|
|||||||
Reference in new issue
Block a user