Reno is the second iteration of the AWMTK-powered AwesomeWM config.
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.

36 lines
1.7 KiB

2 years ago
  1. -- This file is part of Reno desktop.
  2. --
  3. -- Reno desktop is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  4. --
  5. -- Reno desktop is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  6. --
  7. -- You should have received a copy of the GNU General Public License along with Reno desktop. If not, see <https://www.gnu.org/licenses/>.
  8. -- A small utility function to generate thumbnails for images
  9. local spawn = require("awful.spawn")
  10. local thumbnailer = {}
  11. -- annoying shit but that's what happens
  12. if _VERSION ~= "Lua 5.1" then
  13. execute = function(comm)
  14. return select(3,os.execute(comm))
  15. end
  16. else
  17. execute = os.execute
  18. end
  19. thumbnailer.generate = function(path,thumb_path,height)
  20. assert(type(path) == "string", "argumenr #1 (path) is not a string")
  21. assert(type(thumb_path) == "string", "argument #2 (thumbnail path) is not a string")
  22. assert(type(height) == "number","argument #3 (height) is not a number")
  23. if execute("ls "..path) ~= 0 then
  24. return false, "unable to access image directory"
  25. end
  26. if execute("ls "..thumb_path) == 0 then
  27. return true
  28. end
  29. if execute("mkdir "..thumb_path) ~= 0 then
  30. return false, "unable to create thumbnail directory"
  31. end
  32. spawn("mogrify -thumbnail x"..tostring(height).." -path '"..thumb_path.."' '"..path.."'/*.{jpg,png}")
  33. return true
  34. end
  35. return thumbnailer