From 8f6e21fce240e90f11bd551d9c42bad94791c3d6 Mon Sep 17 00:00:00 2001 From: GourSE Date: Fri, 24 Jun 2022 11:48:33 +0800 Subject: [PATCH 1/3] feat: not-saving functions && fix: clipboard User can now have an option to not save file into ~/Pictures -the method used is to delete the file created Change xclip command to fix clipboard GourSE@Protonmail.com --- README.md | 7 ++++--- init.lua | 3 +++ screenshot.lua | 40 ++++++++++++++++++++++++++++++++++------ 3 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 init.lua diff --git a/README.md b/README.md index 5e40001..48af42c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Get it ------ ```sh -cd $XDG_CONFIG_HOME/awesome/ +cd $HOME/.config/awesome/ git clone https://github.com/denisoster/awesomewm-screenshot.git ``` @@ -23,11 +23,12 @@ Use it ------ Just put these line to the appropriate places in -*$XDG_CONFIG_HOME/awesome/rc.lua*. +*$HOME/.config/awesome/rc.lua*. ```lua -- Load the widget. -local screenshot = require("screenshot") +local screenshot = require("awesomewm-screenshot.screenshot") + -- Configure the hotkeys. awful.key({ }, "Print", scrot_full, diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..e2f57e5 --- /dev/null +++ b/init.lua @@ -0,0 +1,3 @@ +return { + screenshot = require("awesomewm-screenshot.screenshot") +} diff --git a/screenshot.lua b/screenshot.lua index 459ae6b..d0935ea 100644 --- a/screenshot.lua +++ b/screenshot.lua @@ -2,24 +2,51 @@ local awful = require("awful") local naughty = require("naughty") timers = { 5,10 } -screenshot = os.getenv("HOME") .. "/Pictures/scrot/$(date +%F_%T).png" +screenshot = os.getenv("HOME") .. "/Pictures/$(date +%F_%T).png" + + +function scrot_full_d() + scrot("scrot " .. screenshot .. " -e 'xclip -selection clipboard -t image/png -i $f && rm $f'", scrot_callback, "Take a screenshot of entire screen") +end + +function scrot_selection_d() + scrot("sleep 0.5 && scrot -s " .. screenshot .. " -e 'xclip -selection clipboard -t image/png -i $f && rm $f'", scrot_callback, "Take a screenshot of selection") +end + +function scrot_window_d() + scrot("scrot -u " .. screenshot .. " -e 'xclip -selection clipboard -t image/png -i $f && rm $f''", scrot_callback, "Take a screenshot of focused window") +end + +function scrot_delay_d() + items={} + for key, value in ipairs(timers) do + items[#items+1]={tostring(value) , "scrot -d ".. value.." " .. screenshot .. " -e 'xclip -selection clipboard -t image/png -i $f && rm $f''","Take a screenshot of delay" } + end + awful.menu.new( + { + items = items + } + ):show({keygrabber= true}) + scrot_callback() +end + function scrot_full() - scrot("scrot " .. screenshot .. " -e 'xclip -selection c -t image/png < $f', scrot_callback", scrot_callback, "Take a screenshot of entire screen") + scrot("scrot " .. screenshot .. " -e 'xclip -selection clipboard -t image/png -i $f'", scrot_callback, "Take a screenshot of entire screen") end function scrot_selection() - scrot("sleep 0.5 && scrot -s " .. screenshot .. " -e 'xclip -selection c -t image/png < $f'", scrot_callback, "Take a screenshot of selection") + scrot("sleep 0.5 && scrot -s " .. screenshot .. " -e 'xclip -selection clipboard -t image/png -i $f'", scrot_callback, "Take a screenshot of selection") end function scrot_window() - scrot("scrot -u " .. screenshot .. " -e 'xclip -selection c -t image/png < $f'", scrot_callback, "Take a screenshot of focused window") + scrot("scrot -u " .. screenshot .. " -e 'xclip -selection clipboard -t image/png -i $f'", scrot_callback, "Take a screenshot of focused window") end function scrot_delay() items={} for key, value in ipairs(timers) do - items[#items+1]={tostring(value) , "scrot -d ".. value.." " .. screenshot .. " -e 'xclip -selection c -t image/png < $f'","Take a screenshot of delay" } + items[#items+1]={tostring(value) , "scrot -d ".. value.." " .. screenshot .. " -e 'xclip -selection clipboard -t image/png -i $f'","Take a screenshot of delay" } end awful.menu.new( { @@ -29,6 +56,7 @@ function scrot_delay() scrot_callback() end + function scrot(cmd , callback, args) awful.util.spawn_with_shell(cmd) callback(args) @@ -38,4 +66,4 @@ function scrot_callback(text) text = text, timeout = 0.5 }) -end \ No newline at end of file +end From f307bc3a9247dee066cfefac9a6a4caaf62e03c5 Mon Sep 17 00:00:00 2001 From: Pokemob <35000549+GourSE@users.noreply.github.com> Date: Fri, 24 Jun 2022 12:21:19 +0800 Subject: [PATCH 2/3] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 48af42c..06b3540 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ local screenshot = require("awesomewm-screenshot.screenshot") -- Configure the hotkeys. - awful.key({ }, "Print", scrot_full, + awful.key({ }, "Print", scrot_full, {description = "Take a screenshot of entire screen", group = "screenshot"}), awful.key({ modkey, }, "Print", scrot_selection, {description = "Take a screenshot of selection", group = "screenshot"}), @@ -39,6 +39,9 @@ local screenshot = require("awesomewm-screenshot.screenshot") {description = "Take a screenshot of focused window", group = "screenshot"}), awful.key({ "Ctrl" }, "Print", scrot_delay, {description = "Take a screenshot of delay", group = "screenshot"}), +-- Add _d to the end for copy to clipboard only +-- awful.key({ }, "Print", scrot_full_d, +-- {description = "Take a screenshot of entire screen and copy to clipboard only", group = "screenshot"}), ``` the default storage of the ~/Pictures/ From b59d453ee1e11ca22b02dab05d9589315932ba3a Mon Sep 17 00:00:00 2001 From: Pokemob <35000549+GourSE@users.noreply.github.com> Date: Fri, 24 Jun 2022 21:14:26 +0800 Subject: [PATCH 3/3] Update README.md Because original creator doesn't seems to accept pull requests --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 06b3540..29fe969 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Get it ```sh cd $HOME/.config/awesome/ -git clone https://github.com/denisoster/awesomewm-screenshot.git +git clone https://github.com/GourSE/awesomewm-screenshot.git ``` Use it