diff --git a/config/ghostty/.config/.alt/ghostty-default/config b/config/ghostty/.config/.alt/ghostty-default/config index bfc586a..29d074d 100644 --- a/config/ghostty/.config/.alt/ghostty-default/config +++ b/config/ghostty/.config/.alt/ghostty-default/config @@ -10,6 +10,7 @@ keybind = ctrl+shift+r=reload_config keybind = ctrl+shift+h=write_screen_file:copy keybind = ctrl+shift+j=text:ghostty-capture\n +keybind = ctrl+enter=unbind command = exec fish diff --git a/config/ghostty/.config/.alt/ghostty-niri/config b/config/ghostty/.config/.alt/ghostty-niri/config index 0f7b99e..3a731e7 100644 --- a/config/ghostty/.config/.alt/ghostty-niri/config +++ b/config/ghostty/.config/.alt/ghostty-niri/config @@ -10,6 +10,7 @@ keybind = ctrl+shift+r=reload_config keybind = ctrl+shift+h=write_screen_file:copy keybind = ctrl+shift+j=text:ghostty-capture\n +keybind = ctrl+enter=unbind command = exec fish @@ -23,4 +24,4 @@ adjust-cursor-thickness = 3 custom-shader = cursor-shaders/cursor-smear.glsl -quit-after-last-window-closed = false \ No newline at end of file +quit-after-last-window-closed = false diff --git a/config/quickshell/.config/quickshell/Services/Niri.qml b/config/quickshell/.config/quickshell/Services/Niri.qml index 93e47bf..410fc19 100644 --- a/config/quickshell/.config/quickshell/Services/Niri.qml +++ b/config/quickshell/.config/quickshell/Services/Niri.qml @@ -15,6 +15,7 @@ Singleton { property bool inOverview: false property string focusedWindowTitle: "" property string focusedWindowAppId: "" + property var onScreenshotCaptured: null function updateFocusedWindowTitle() { if (windows && windows[focusedWindowId]) { @@ -84,7 +85,8 @@ Singleton { const event = JSON.parse(data.trim()); if (event.WorkspacesChanged) { workspaceProcess.running = true; - } else if (event.WindowsChanged) { + } + if (event.WindowsChanged) { try { const windowsData = event.WindowsChanged.windows; const windowsMap = {}; @@ -104,9 +106,11 @@ Singleton { } catch (e) { Logger.error("Niri", "Error parsing windows event:", e); } - } else if (event.WorkspaceActivated) { + } + if (event.WorkspaceActivated) { workspaceProcess.running = true; - } else if (event.WindowFocusChanged) { + } + if (event.WindowFocusChanged) { try { const focusedId = event.WindowFocusChanged.id; if (focusedId) { @@ -123,13 +127,15 @@ Singleton { } catch (e) { Logger.error("Niri", "Error parsing window focus event:", e); } - } else if (event.OverviewOpenedOrClosed) { + } + if (event.OverviewOpenedOrClosed) { try { root.inOverview = event.OverviewOpenedOrClosed.is_open === true; } catch (e) { Logger.error("Niri", "Error parsing overview state:", e); } - } else if (event.WindowOpenedOrChanged) { + } + if (event.WindowOpenedOrChanged) { try { const targetWin = event.WindowOpenedOrChanged.window; const id = targetWin.id; @@ -165,7 +171,8 @@ Singleton { } catch (e) { Logger.error("Niri", "Error parsing window opened/changed event:", e); } - } else if (event.windowClosed) { + } + if (event.windowClosed) { try { const closedId = event.windowClosed.id; if (closedId && (root.windows && root.windows[closedId])) { @@ -179,6 +186,17 @@ Singleton { Logger.error("Niri", "Error parsing window closed event:", e); } } + if (event.ScreenshotCaptured) { + try { + const path = event.ScreenshotCaptured.path || ""; + if (!path) return; + if (root.onScreenshotCaptured && typeof root.onScreenshotCaptured === "function") { + root.onScreenshotCaptured(path); + } + } catch (e) { + Logger.error("Niri", "Error parsing screenshot captured event:", e); + } + } } catch (e) { Logger.error("Niri", "Error parsing event stream:", e, data); } diff --git a/config/quickshell/.config/quickshell/Services/Screenshot.qml b/config/quickshell/.config/quickshell/Services/Screenshot.qml new file mode 100644 index 0000000..cdcdd02 --- /dev/null +++ b/config/quickshell/.config/quickshell/Services/Screenshot.qml @@ -0,0 +1,16 @@ +import QtQuick +import Quickshell +import Quickshell.Io +pragma Singleton + +Singleton { + id: root + + function onScreenshotCaptured(path) { + if (!path || typeof path !== "string") + return ; + + Quickshell.execDetached(["~/.local/scripts/screenshot-script", "edit", path]); + } + +} diff --git a/config/quickshell/.config/quickshell/shell.qml b/config/quickshell/.config/quickshell/shell.qml index a8a6aec..735ad3e 100644 --- a/config/quickshell/.config/quickshell/shell.qml +++ b/config/quickshell/.config/quickshell/shell.qml @@ -18,6 +18,7 @@ ShellRoot { sourceComponent: Item { Component.onCompleted: { SunsetService; + Niri.onScreenshotCaptured = Screenshot.onScreenshotCaptured; } Notification { diff --git a/config/scripts/.local/scripts/screenshot-script b/config/scripts/.local/scripts/screenshot-script index 0679324..a771985 100755 --- a/config/scripts/.local/scripts/screenshot-script +++ b/config/scripts/.local/scripts/screenshot-script @@ -32,6 +32,7 @@ class ScreenshotType(Enum): FULL = "full" AREA = "area" WINDOW = "window" + EDIT = "edit" SCREENSHOT_DIR = Path.home() / "Pictures" / "Screenshots" @@ -125,15 +126,29 @@ if __name__ == "__main__": choices=[t.value for t in ScreenshotType], help="Type of screenshot to take.", ) + parser.add_argument( + "path", + nargs="?", + default="", + help="Path of the given screenshot file (for edit type only).", + ) args = parser.parse_args() - # file path - SCREENSHOT_DIR.mkdir(parents=True, exist_ok=True) - filename = gen_file_name() - filepath = SCREENSHOT_DIR / filename + filepath: Path = Path() + if not args.type == ScreenshotType.EDIT.value: + # file path + SCREENSHOT_DIR.mkdir(parents=True, exist_ok=True) + filename = gen_file_name() + filepath = SCREENSHOT_DIR / filename - # take screenshot - take_screenshot(filepath, args.type) + # take screenshot + take_screenshot(filepath, args.type) + else: + if not args.path: + raise RuntimeError("Path argument is required for edit type.") + filepath = Path(args.path).expanduser() + if not filepath.exists(): + raise RuntimeError(f"File does not exist: {filepath}") # create loop instance loop = GLib.MainLoop() @@ -156,9 +171,9 @@ if __name__ == "__main__": loop.quit() n = Notify.Notification.new( - "Screenshot Taken", # Mako doesn't have action buttons displayed with notification cards, "Click to edit", + str(filepath), ) n.add_action( # so default action is used, which will be triggered on simply clicking the notification card diff --git a/config/wallpaper/Pictures/backgrounds b/config/wallpaper/Pictures/backgrounds index 4cbce34..a549b96 160000 --- a/config/wallpaper/Pictures/backgrounds +++ b/config/wallpaper/Pictures/backgrounds @@ -1 +1 @@ -Subproject commit 4cbce346d5c74a75d55077e5d259d8e4f283e845 +Subproject commit a549b962e97df0bb848d6fa9e89aabb05f1cf75b