refactor: make screenshots even less bad, and copy to the clipboard

This commit is contained in:
kossLAN 2025-10-15 15:12:42 -04:00
parent 62ed66e60a
commit 29658fa910
Signed by: kossLAN
SSH key fingerprint: SHA256:bdV0x+wdQHGJ6LgmstH3KV8OpWY+OOFmJcPcB0wQPV8
4 changed files with 52 additions and 7 deletions

View file

@ -5,6 +5,7 @@ import Quickshell
import Quickshell.Io
import Quickshell.Wayland
import QtQuick
import qs
Singleton {
id: root
@ -53,10 +54,30 @@ Singleton {
const height = Math.floor(selection.height);
let position = `${x},${y} ${width}x${height}`;
let path = "/home/koss/Pictures/screenshot.png";
// i hate javascript
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth();
let day = date.getDay();
let dateString = `${year}-${month}-${day}`;
let hour = date.getHours();
let minutes = date.getMinutes();
let seconds = date.getSeconds();
let timeString = `${hour}:${minutes}:${seconds}`;
let fileName = `screenshot-${dateString}-${timeString}.png`
const path = `${ShellSettings.settings.screenshotPath}/${fileName}`;
console.log(`Screenshot saved to ${path}`);
// take a screenshot with grim, probably a better way to get this path...
let scriptUrl = Qt.resolvedUrl("root:scripts/screenshot.sh").toLocaleString();
let scriptPath = scriptUrl.replace(/^(file:\/{2})/, "");
Quickshell.execDetached({
command: ["grim", "-g", position, path]
command: ["sh", scriptPath, position, path]
});
root.windowOpen = false;