diff --git a/compile_all.sh b/compile_all.sh old mode 100755 new mode 100644 diff --git a/file.png b/file.png new file mode 100644 index 0000000..57fe2b6 Binary files /dev/null and b/file.png differ diff --git a/fuzzytime.nim b/fuzzytime.nim old mode 100755 new mode 100644 diff --git a/screenshot.nim b/screenshot.nim old mode 100644 new mode 100755 index af57817..d5b2422 --- a/screenshot.nim +++ b/screenshot.nim @@ -2,18 +2,26 @@ import base import std/[times,os,osproc,strutils,sequtils] var screenshot_type = "" +var wayland = false const TYPES = @["region", "fullscreen", "window"] const DATE_FORMAT = "yyyyMMdd-hhmmss" const FILENAME = "Screenshot-%d.png" const TEMP_DIR = "/tmp/" const SCREENSHOT_CMD = "maim -u %s --format png %f" +const SCREENSHOT_CMD_WL = "grim %s %f" +var RUN_CMD = SCREENSHOT_CMD let DATE_STR = now().format(DATE_FORMAT) # where %s is an extra flag or process, i.e. xdotool for getting active window const ACTIVE_WINDOW_CMD = "-i $(xdotool getactivewindow)" const REGION_FLAG = "-s" +const REGION_FLAG_WL = "-g \"$(slurp)\"" +var REGION_CMD = REGION_FLAG +const CLIPBOARD_CMD = "xclip -selection clipboard -t image/png" +const CLIPBOARD_CMD_WL = "wl-copy" +var CLIP_CMD = CLIPBOARD_CMD proc saveToClipboard(filename: string) = - let cmd = "cat " & filename & " | xclip -selection clipboar -t image/png" + let cmd = "cat " & filename & " | " & CLIP_CMD let status = execCmd(cmd) if status == 0 and fileExists(filename): removeFile(filename) @@ -64,12 +72,12 @@ proc showScreenshotTypeSel() = proc takeScreenshot() = let filename = TEMP_DIR & FILENAME.replace("%d",DATE_STR) - var cmd = SCREENSHOT_CMD.replace("%f",filename) + var cmd = RUN_CMD.replace("%f",filename) case screenshot_type: of "window": cmd = cmd.replace("%s",ACTIVE_WINDOW_CMD) of "region": - cmd = cmd.replace("%s",REGION_FLAG) + cmd = cmd.replace("%s",REGION_CMD) else: #fullscreen cmd = cmd.replace("%s","") # sleep for a bit otherwise the screen shot grabs dmenu as well @@ -82,6 +90,10 @@ proc takeScreenshot() = if isMainModule: for arg in args: + if arg == "-w": + RUN_CMD = SCREENSHOT_CMD_WL + REGION_CMD = REGION_FLAG_WL + CLIP_CMD = CLIPBOARD_CMD_WL if arg in TYPES: screenshot_type = arg break diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..e299782 Binary files /dev/null and b/screenshot.png differ diff --git a/volume.nim b/volume.nim old mode 100755 new mode 100644