waiting...
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
16
config/quickshell/.config/quickshell/Services/Screenshot.qml
Normal file
16
config/quickshell/.config/quickshell/Services/Screenshot.qml
Normal file
@@ -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]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,6 +18,7 @@ ShellRoot {
|
||||
sourceComponent: Item {
|
||||
Component.onCompleted: {
|
||||
SunsetService;
|
||||
Niri.onScreenshotCaptured = Screenshot.onScreenshotCaptured;
|
||||
}
|
||||
|
||||
Notification {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user