Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
benvonh committed Dec 25, 2024
2 parents 66fe660 + da83b62 commit 32c0281
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 46 deletions.
42 changes: 4 additions & 38 deletions app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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());
}
});
10 changes: 2 additions & 8 deletions src/components/menus/shared/dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 32c0281

Please sign in to comment.