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+h=write_screen_file:copy
|
||||||
keybind = ctrl+shift+j=text:ghostty-capture\n
|
keybind = ctrl+shift+j=text:ghostty-capture\n
|
||||||
|
keybind = ctrl+enter=unbind
|
||||||
|
|
||||||
command = exec fish
|
command = exec fish
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ keybind = ctrl+shift+r=reload_config
|
|||||||
|
|
||||||
keybind = ctrl+shift+h=write_screen_file:copy
|
keybind = ctrl+shift+h=write_screen_file:copy
|
||||||
keybind = ctrl+shift+j=text:ghostty-capture\n
|
keybind = ctrl+shift+j=text:ghostty-capture\n
|
||||||
|
keybind = ctrl+enter=unbind
|
||||||
|
|
||||||
command = exec fish
|
command = exec fish
|
||||||
|
|
||||||
@@ -23,4 +24,4 @@ adjust-cursor-thickness = 3
|
|||||||
|
|
||||||
custom-shader = cursor-shaders/cursor-smear.glsl
|
custom-shader = cursor-shaders/cursor-smear.glsl
|
||||||
|
|
||||||
quit-after-last-window-closed = false
|
quit-after-last-window-closed = false
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ Singleton {
|
|||||||
property bool inOverview: false
|
property bool inOverview: false
|
||||||
property string focusedWindowTitle: ""
|
property string focusedWindowTitle: ""
|
||||||
property string focusedWindowAppId: ""
|
property string focusedWindowAppId: ""
|
||||||
|
property var onScreenshotCaptured: null
|
||||||
|
|
||||||
function updateFocusedWindowTitle() {
|
function updateFocusedWindowTitle() {
|
||||||
if (windows && windows[focusedWindowId]) {
|
if (windows && windows[focusedWindowId]) {
|
||||||
@@ -84,7 +85,8 @@ Singleton {
|
|||||||
const event = JSON.parse(data.trim());
|
const event = JSON.parse(data.trim());
|
||||||
if (event.WorkspacesChanged) {
|
if (event.WorkspacesChanged) {
|
||||||
workspaceProcess.running = true;
|
workspaceProcess.running = true;
|
||||||
} else if (event.WindowsChanged) {
|
}
|
||||||
|
if (event.WindowsChanged) {
|
||||||
try {
|
try {
|
||||||
const windowsData = event.WindowsChanged.windows;
|
const windowsData = event.WindowsChanged.windows;
|
||||||
const windowsMap = {};
|
const windowsMap = {};
|
||||||
@@ -104,9 +106,11 @@ Singleton {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logger.error("Niri", "Error parsing windows event:", e);
|
Logger.error("Niri", "Error parsing windows event:", e);
|
||||||
}
|
}
|
||||||
} else if (event.WorkspaceActivated) {
|
}
|
||||||
|
if (event.WorkspaceActivated) {
|
||||||
workspaceProcess.running = true;
|
workspaceProcess.running = true;
|
||||||
} else if (event.WindowFocusChanged) {
|
}
|
||||||
|
if (event.WindowFocusChanged) {
|
||||||
try {
|
try {
|
||||||
const focusedId = event.WindowFocusChanged.id;
|
const focusedId = event.WindowFocusChanged.id;
|
||||||
if (focusedId) {
|
if (focusedId) {
|
||||||
@@ -123,13 +127,15 @@ Singleton {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logger.error("Niri", "Error parsing window focus event:", e);
|
Logger.error("Niri", "Error parsing window focus event:", e);
|
||||||
}
|
}
|
||||||
} else if (event.OverviewOpenedOrClosed) {
|
}
|
||||||
|
if (event.OverviewOpenedOrClosed) {
|
||||||
try {
|
try {
|
||||||
root.inOverview = event.OverviewOpenedOrClosed.is_open === true;
|
root.inOverview = event.OverviewOpenedOrClosed.is_open === true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logger.error("Niri", "Error parsing overview state:", e);
|
Logger.error("Niri", "Error parsing overview state:", e);
|
||||||
}
|
}
|
||||||
} else if (event.WindowOpenedOrChanged) {
|
}
|
||||||
|
if (event.WindowOpenedOrChanged) {
|
||||||
try {
|
try {
|
||||||
const targetWin = event.WindowOpenedOrChanged.window;
|
const targetWin = event.WindowOpenedOrChanged.window;
|
||||||
const id = targetWin.id;
|
const id = targetWin.id;
|
||||||
@@ -165,7 +171,8 @@ Singleton {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logger.error("Niri", "Error parsing window opened/changed event:", e);
|
Logger.error("Niri", "Error parsing window opened/changed event:", e);
|
||||||
}
|
}
|
||||||
} else if (event.windowClosed) {
|
}
|
||||||
|
if (event.windowClosed) {
|
||||||
try {
|
try {
|
||||||
const closedId = event.windowClosed.id;
|
const closedId = event.windowClosed.id;
|
||||||
if (closedId && (root.windows && root.windows[closedId])) {
|
if (closedId && (root.windows && root.windows[closedId])) {
|
||||||
@@ -179,6 +186,17 @@ Singleton {
|
|||||||
Logger.error("Niri", "Error parsing window closed event:", e);
|
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) {
|
} catch (e) {
|
||||||
Logger.error("Niri", "Error parsing event stream:", e, data);
|
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 {
|
sourceComponent: Item {
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
SunsetService;
|
SunsetService;
|
||||||
|
Niri.onScreenshotCaptured = Screenshot.onScreenshotCaptured;
|
||||||
}
|
}
|
||||||
|
|
||||||
Notification {
|
Notification {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class ScreenshotType(Enum):
|
|||||||
FULL = "full"
|
FULL = "full"
|
||||||
AREA = "area"
|
AREA = "area"
|
||||||
WINDOW = "window"
|
WINDOW = "window"
|
||||||
|
EDIT = "edit"
|
||||||
|
|
||||||
|
|
||||||
SCREENSHOT_DIR = Path.home() / "Pictures" / "Screenshots"
|
SCREENSHOT_DIR = Path.home() / "Pictures" / "Screenshots"
|
||||||
@@ -125,15 +126,29 @@ if __name__ == "__main__":
|
|||||||
choices=[t.value for t in ScreenshotType],
|
choices=[t.value for t in ScreenshotType],
|
||||||
help="Type of screenshot to take.",
|
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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# file path
|
filepath: Path = Path()
|
||||||
SCREENSHOT_DIR.mkdir(parents=True, exist_ok=True)
|
if not args.type == ScreenshotType.EDIT.value:
|
||||||
filename = gen_file_name()
|
# file path
|
||||||
filepath = SCREENSHOT_DIR / filename
|
SCREENSHOT_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
filename = gen_file_name()
|
||||||
|
filepath = SCREENSHOT_DIR / filename
|
||||||
|
|
||||||
# take screenshot
|
# take screenshot
|
||||||
take_screenshot(filepath, args.type)
|
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
|
# create loop instance
|
||||||
loop = GLib.MainLoop()
|
loop = GLib.MainLoop()
|
||||||
@@ -156,9 +171,9 @@ if __name__ == "__main__":
|
|||||||
loop.quit()
|
loop.quit()
|
||||||
|
|
||||||
n = Notify.Notification.new(
|
n = Notify.Notification.new(
|
||||||
"Screenshot Taken",
|
|
||||||
# Mako doesn't have action buttons displayed with notification cards,
|
# Mako doesn't have action buttons displayed with notification cards,
|
||||||
"Click to edit",
|
"Click to edit",
|
||||||
|
str(filepath),
|
||||||
)
|
)
|
||||||
n.add_action(
|
n.add_action(
|
||||||
# so default action is used, which will be triggered on simply clicking the notification card
|
# so default action is used, which will be triggered on simply clicking the notification card
|
||||||
|
|||||||
Reference in New Issue
Block a user