From aed36b160f3049e393f9a24b80ba6c8a5e9c558f Mon Sep 17 00:00:00 2001
From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Date: Fri, 4 Apr 2025 18:30:08 +1100
Subject: feat: uwsm app -> app2unit

Also xdg-open -> app2unit
---
 src/modules/bar.tsx | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

(limited to 'src/modules/bar.tsx')

diff --git a/src/modules/bar.tsx b/src/modules/bar.tsx
index 731e3e7..998a442 100644
--- a/src/modules/bar.tsx
+++ b/src/modules/bar.tsx
@@ -7,7 +7,7 @@ import { bindCurrentTime, osIcon } from "@/utils/system";
 import type { AstalWidget } from "@/utils/types";
 import { setupCustomTooltip } from "@/utils/widgets";
 import ScreenCorner from "@/widgets/screencorner";
-import { execAsync, Variable } from "astal";
+import { execAsync, GLib, Variable } from "astal";
 import { bind, kebabify } from "astal/binding";
 import { App, Astal, Gtk, Widget } from "astal/gtk3";
 import { bar as config } from "config";
@@ -294,13 +294,16 @@ const Network = ({ monitor }: { monitor: Monitor }) => (
             const network = AstalNetwork.get_default();
             if (event.button === Astal.MouseButton.PRIMARY) switchPane(monitor, "connectivity");
             else if (event.button === Astal.MouseButton.SECONDARY) network.wifi.enabled = !network.wifi.enabled;
-            else if (event.button === Astal.MouseButton.MIDDLE)
-                execAsync("uwsm app -- gnome-control-center wifi").catch(() => {
+            else if (event.button === Astal.MouseButton.MIDDLE) {
+                if (GLib.find_program_in_path("gnome-control-center"))
+                    execAsync("app2unit -- gnome-control-center wifi").catch(console.error);
+                else {
                     network.wifi.scan();
                     execAsync(
-                        "uwsm app -- foot -T nmtui -- fish -c 'sleep .1; set -e COLORTERM; TERM=xterm-old nmtui connect'"
+                        "app2unit -- foot -T nmtui -- fish -c 'sleep .1; set -e COLORTERM; TERM=xterm-old nmtui connect'"
                     ).catch(() => {}); // Ignore errors
-                });
+                }
+            }
         }}
         setup={self => {
             const network = AstalNetwork.get_default();
@@ -399,7 +402,7 @@ const BluetoothDevice = ({ monitor, device }: { monitor: Monitor; device: AstalB
             else if (event.button === Astal.MouseButton.SECONDARY)
                 device.disconnect_device((_, res) => device.disconnect_device_finish(res));
             else if (event.button === Astal.MouseButton.MIDDLE)
-                execAsync("uwsm app -- blueman-manager").catch(console.error);
+                execAsync("app2unit -- blueman-manager").catch(console.error);
         }}
         setup={self => setupCustomTooltip(self, bind(device, "alias"))}
     >
@@ -418,7 +421,7 @@ const Bluetooth = ({ monitor }: { monitor: Monitor }) => (
                 if (event.button === Astal.MouseButton.PRIMARY) switchPane(monitor, "connectivity");
                 else if (event.button === Astal.MouseButton.SECONDARY) AstalBluetooth.get_default().toggle();
                 else if (event.button === Astal.MouseButton.MIDDLE)
-                    execAsync("uwsm app -- blueman-manager").catch(console.error);
+                    execAsync("app2unit -- blueman-manager").catch(console.error);
             }}
             setup={self => {
                 const bluetooth = AstalBluetooth.get_default();
-- 
cgit v1.2.3-freya

