Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,33 @@ 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"}),
awful.key({ "Shift" }, "Print", scrot_window,
{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/
Expand Down
3 changes: 3 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
screenshot = require("awesomewm-screenshot.screenshot")
}
40 changes: 34 additions & 6 deletions screenshot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand All @@ -29,6 +56,7 @@ function scrot_delay()
scrot_callback()
end


function scrot(cmd , callback, args)
awful.util.spawn_with_shell(cmd)
callback(args)
Expand All @@ -38,4 +66,4 @@ function scrot_callback(text)
text = text,
timeout = 0.5
})
end
end