This commit is contained in:
benvonh
2024-12-26 04:18:03 +10:00
2 changed files with 6 additions and 46 deletions

42
app.ts
View File

@@ -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());
}
});

View File

@@ -81,14 +81,8 @@ export default ({
<revealer
revealChild={false}
setup={(self: Revealer) => {
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}