From 99b173bc581e7a4409b3931726cf8e775c7264b9 Mon Sep 17 00:00:00 2001 From: Jas Singh Date: Wed, 25 Dec 2024 01:18:27 -0800 Subject: [PATCH] Cleanup unused code (#625) --- app.ts | 42 ++----------------- .../menus/shared/dropdown/index.tsx | 10 +---- 2 files changed, 6 insertions(+), 46 deletions(-) diff --git a/app.ts b/app.ts index c7516ae..15e5822 100644 --- a/app.ts +++ b/app.ts @@ -15,7 +15,7 @@ import { bash, forMonitors } from 'src/lib/utils'; import options from 'src/options'; import OSD from 'src/components/osd/index'; import { App } from 'astal/gtk3'; -import { exec, execAsync } from 'astal'; +import { execAsync } from 'astal'; import { hyprlandService } from 'src/lib/constants/services'; import { handleRealization } from 'src/components/menus/shared/dropdown/helpers'; import { isDropdownMenu } from 'src/lib/constants/options.js'; @@ -64,44 +64,10 @@ App.start({ }, }); -/** - * Function to determine if the current OS is NixOS by parsing /etc/os-release. - * @returns True if NixOS, false otherwise. - */ -const isNixOS = (): boolean => { - try { - const osRelease = exec('cat /etc/os-release').toString(); - const idMatch = osRelease.match(/^ID\s*=\s*"?([^"\n]+)"?/m); - - if (idMatch && idMatch[1].toLowerCase() === 'nixos') { - return true; - } - - return false; - } catch (error) { - console.error('Error detecting OS:', error); - return false; - } -}; - -/** - * Function to generate the appropriate restart command based on the OS. - * @returns The modified or original restart command. - */ -const getRestartCommand = (): string => { - const isNix = isNixOS(); - const command = options.hyprpanel.restartCommand.get(); - - if (isNix) { - return command.replace(/\bags\b/g, 'hyprpanel'); - } - - return command; -}; - hyprlandService.connect('monitor-added', () => { + const { restartCommand } = options.hyprpanel; + if (options.hyprpanel.restartAgs.get()) { - const restartAgsCommand = getRestartCommand(); - bash(restartAgsCommand); + bash(restartCommand.get()); } }); diff --git a/src/components/menus/shared/dropdown/index.tsx b/src/components/menus/shared/dropdown/index.tsx index f0dd3bc..27975fe 100644 --- a/src/components/menus/shared/dropdown/index.tsx +++ b/src/components/menus/shared/dropdown/index.tsx @@ -81,14 +81,8 @@ export default ({ { - App.connect('window-toggled', (app) => { - const targetWindow = app.get_window(name); - - const visibility = targetWindow?.get_visible(); - - if (targetWindow?.name === name) { - self.set_reveal_child(visibility ?? false); - } + App.connect('window-toggled', (_, window) => { + self.set_reveal_child(window.visible); }); }} transitionType={transition}