Also use gtk truncate for active window and media playing For some reason, odd numbers of workspaces need the adjustment, but even don't
11 lines
545 B
TypeScript
11 lines
545 B
TypeScript
export const basename = (path: string, stripExt = true) => {
|
|
const lastSlash = path.lastIndexOf("/");
|
|
const lastDot = path.lastIndexOf(".");
|
|
return path.slice(lastSlash + 1, stripExt && lastDot > lastSlash ? lastDot : undefined);
|
|
};
|
|
|
|
export const pathToFileName = (path: string, ext?: string) => {
|
|
const start = /[a-z]+:\/\//.test(path) ? 0 : path.indexOf("/") + 1;
|
|
const dir = path.slice(start, path.lastIndexOf("/")).replaceAll("/", "-");
|
|
return `${dir}-${basename(path, ext !== undefined)}${ext ? `.${ext}` : ""}`;
|
|
};
|