my complicated awesomewm config (SUNSETTED)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
1.1 KiB

-- A small utility function to generate thumbnails for images
local spawn = require("awful.spawn")
local thumbnailer = {}
-- annoying shit but that's what happens
if _VERSION ~= "Lua 5.1" then
execute = function(comm)
return select(3,os.execute(comm))
end
else
execute = os.execute
end
thumbnailer.generate = function(path,thumb_path,height)
assert(type(path) == "string", "argumenr #1 (path) is not a string")
assert(type(thumb_path) == "string", "argument #2 (thumbnail path) is not a string")
assert(type(height) == "number","argument #3 (height) is not a number")
require("naughty").notify({text = tostring(path).." "..tostring(thumb_path.." ")..tostring(height)})
if execute("ls "..path) ~= 0 then
return false, "unable to access image directory"
end
if execute("ls "..thumb_path) == 0 then
return true
end
if execute("mkdir "..thumb_path) ~= 0 then
return false, "unable to create thumbnail directory"
end
spawn("mogrify -thumbnail x"..tostring(height).." -path '"..thumb_path.."' '"..path.."'/*.{jpg,png}")
return true
end
return thumbnailer