Rename files

This commit is contained in:
Fedor Indutny
2025-10-16 17:33:01 -07:00
parent 3387cf6a77
commit 44076ece79
2411 changed files with 0 additions and 0 deletions

53
ts/util/os/osMain.node.ts Normal file
View File

@@ -0,0 +1,53 @@
// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import os from 'node:os';
import fsExtra from 'fs-extra';
import { getOSFunctions } from './shared.std.js';
const { readFileSync } = fsExtra;
function getLinuxName(): string | undefined {
if (os.platform() !== 'linux') {
return undefined;
}
const etcOsRelease = readFileSync('/etc/os-release', 'utf-8');
const match = etcOsRelease.match(/^PRETTY_NAME=(.+?)$/m);
if (!match) {
return undefined;
}
return match[1];
}
function isFlatpak(): boolean {
if (process.env.container === 'flatpak') {
return true;
}
const linuxName = getLinuxName();
if (linuxName && linuxName.toLowerCase().includes('flatpak')) {
return true;
}
return false;
}
function isWaylandEnabled(): boolean {
return Boolean(process.env.WAYLAND_DISPLAY);
}
function isLinuxUsingKDE(): boolean {
return os.platform() === 'linux' && process.env.XDG_CURRENT_DESKTOP === 'KDE';
}
const OS = {
...getOSFunctions(os.release()),
getLinuxName,
isFlatpak,
isLinuxUsingKDE,
isWaylandEnabled,
};
export default OS;