diff --git a/ags/app.ts b/ags/app.ts index 67ee1ee..9df801c 100644 --- a/ags/app.ts +++ b/ags/app.ts @@ -6,28 +6,30 @@ import Hyprland from "gi://AstalHyprland"; import QuickSettings from "widget/quick_settings/quick_settings"; import BluetoothWindow from "widget/quick_settings/bluetooth"; +import Shortcuts from "./widget/launcher/shortcuts"; import Clipboard from "widget/launcher/clipboard"; -import Launcher from "widget/launcher/launcher"; import BatteryInfo from "widget/bar/battery_info"; +import Launcher from "widget/launcher/launcher"; import Bar from "widget/bar/bar"; const hypr = Hyprland.get_default(); const windows = new Map(); const components = [ - Bar, - Launcher, - QuickSettings, + Bar, + Launcher, + QuickSettings, BluetoothWindow, BatteryInfo, - Clipboard + Clipboard, + Shortcuts ]; const setupBars = async (monitor_id: number) => { - const windows = await Promise.all( - components.map(item => Promise.resolve(item(monitor_id)) as Promise) - ); + const windows = await Promise.all( + components.map(item => Promise.resolve(item(monitor_id)) as Promise) + ); - return windows; + return windows; }; const STYLES = GLib.get_user_config_dir() + "/ags/styles/style.scss"; @@ -55,7 +57,7 @@ App.start({ hypr.connect("monitor-added", async (_, monitor: Hyprland.Monitor) => { if (!windows.has(monitor.id)) windows.set(monitor.id, await setupBars(monitor.id)) }); - + hypr.connect("monitor-removed", (_, monitor_id: number) => { const monitorWindows = windows.get(monitor_id) if (monitorWindows) { diff --git a/ags/lib/utils.ts b/ags/lib/utils.ts index 96eab72..682935e 100644 --- a/ags/lib/utils.ts +++ b/ags/lib/utils.ts @@ -5,6 +5,37 @@ export type Belongs = { [K in keyof T]: T[K] extends U ? K : never; }[keyof T]; +export const generateModmaskMap = () => { + const MODIFIERS: Record = { + 1: "SHIFT", + 4: "CTRL", + 8: "ALT", + 64: "SUPER" + }; + + const modmaskMap: Record = {}; + + const modifierValues = Object.keys(MODIFIERS).map(Number); + const totalCombinations = 1 << modifierValues.length; + + for (let i = 0; i < totalCombinations; i++) { + let modmask = 0; + const labels: string[] = []; + + modifierValues.forEach((value, index) => { + if (i & (1 << index)) { + modmask |= value; + labels.push(MODIFIERS[value]); + } + }); + + modmaskMap[modmask] = labels.reverse().join(" + "); + } + + return modmaskMap; +}; + + export const hideWindow = (self: Gtk.Window, keyval: number) => { const keys = ["quick_settings"].includes(self.name) ? [Gdk.KEY_Escape] @@ -27,6 +58,6 @@ export const limit = (list: T[], max: number) => list.filter((_, i) => i <= ( export const skip = (list: T[], items: number) => list.filter((_, i) => { if (items < 0) items = 0; if (items > (list.length - 1)) items = list.length; - + return i > (items - 1); }); \ No newline at end of file diff --git a/ags/styles/components/_index.scss b/ags/styles/components/_index.scss index fd8d0e6..bb3adb4 100644 --- a/ags/styles/components/_index.scss +++ b/ags/styles/components/_index.scss @@ -1,5 +1,6 @@ @forward '_bar'; @forward '_launcher'; @forward '_clipboard'; +@forward '_shortcuts'; @forward '_battery_info'; @forward '_quick_settings'; \ No newline at end of file diff --git a/ags/styles/components/_shortcuts.scss b/ags/styles/components/_shortcuts.scss new file mode 100644 index 0000000..5ef345d --- /dev/null +++ b/ags/styles/components/_shortcuts.scss @@ -0,0 +1,52 @@ +@use '../theme_colors.scss' as *; + +.shortcuts { + .entry { + padding: 10px; + background: $base0B; + border-radius: 8px; + transition: background 0.2s ease; + + &:hover { + background: $base00; + + >label { + color: $base0B; + } + + >.kbd { + background: $base0B; + color: $base00; + } + } + + label { + color: $base00; + font-size: 14px; + font-weight: 600; + } + + .kbd { + padding: 2px 6px; + font-size: 0.9em; + font-family: monospace; + border-radius: 4px; + margin: 0 2px; + + background: $base00; + color: $base0B; + } + } + + .not-found { + background: $base0B; + color: $base00; + font-size: 14px; + padding: 10px; + border-radius: 8px; + + image { + margin-bottom: 8px; + } + } +} \ No newline at end of file diff --git a/ags/widget/launcher/clipboard.tsx b/ags/widget/launcher/clipboard.tsx index 96d9661..dde626b 100644 --- a/ags/widget/launcher/clipboard.tsx +++ b/ags/widget/launcher/clipboard.tsx @@ -69,7 +69,7 @@ export default async function Clipboard(_monitor_id: number) { }; const setup = (self: Gtk.Window) => self.connect('notify::visible', async () => { - await getClipboardHistory(history) + if (self.is_visible()) await getClipboardHistory(history) }) return + {entry.modmask !== 0 &&