diff --git a/README.md b/README.md index 5e40001..29fe969 100644 --- a/README.md +++ b/README.md @@ -15,22 +15,23 @@ Get it ------ ```sh -cd $XDG_CONFIG_HOME/awesome/ -git clone https://github.com/denisoster/awesomewm-screenshot.git +cd $HOME/.config/awesome/ +git clone https://github.com/GourSE/awesomewm-screenshot.git ``` 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, + 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"}), @@ -38,6 +39,9 @@ local screenshot = require("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/ 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