24 lines
688 B
TypeScript
24 lines
688 B
TypeScript
import { Gtk, Gdk } from "astal/gtk4";
|
|
|
|
export type If<Condition, Then, Else> = Condition extends true ? Then : Else;
|
|
export type Belongs<T, U> = {
|
|
[K in keyof T]: T[K] extends U ? K : never;
|
|
}[keyof T];
|
|
|
|
export const hideWindow = (self: Gtk.Window, keyval: number) => {
|
|
const keys = ["quick_settings"].includes(self.name)
|
|
? [Gdk.KEY_Escape]
|
|
: [
|
|
Gdk.KEY_Escape,
|
|
Gdk.KEY_Super_L,
|
|
Gdk.KEY_Super_R
|
|
];
|
|
|
|
if (keys.some(key => key === keyval)) self.hide();
|
|
}
|
|
|
|
export const openOnButton = (event: Gdk.ButtonEvent, keyval: number) => (action: () => void) => {
|
|
if (event.get_button() !== keyval) return;
|
|
|
|
action();
|
|
} |