Cleanup unused code (#625)
This commit is contained in:
42
app.ts
42
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());
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user