Skip to content

Commit

Permalink
[Feature] Use XDG_Picture_dir as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzaaft committed Jul 24, 2024
1 parent 06d8e34 commit 5cacfae
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lua/codesnap/static.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
local path_utils = require("codesnap.utils.path")
-- Get user os
-- If linux, use XDG_PICTURE_DIR, if mac use ~/Pictures, if windows use FOLDERID_Pictures (If support is added back)
local default_save_path = nil
local os_name = vim.loop.os_uname().sysname
if os_name == "Linux" then
default_save_path = os.getenv("XDG_PICTURES_DIR") or (os.getenv("HOME") .. "/Pictures")
elseif os_name == "Darwin" then
default_save_path = os.getenv("HOME") .. "/Pictures"
else
error("codesnap.nvim only supports Linux and MacOS")
end

return {
config = {
Expand All @@ -15,6 +26,7 @@ return {
min_width = 0,
bg_x_padding = 122,
bg_y_padding = 82,
save_path = default_save_path,
},
cwd = path_utils.back(path_utils.back(debug.getinfo(1, "S").source:sub(2):match("(.*[/\\])"))),
preview_switch = true,
Expand Down

0 comments on commit 5cacfae

Please sign in to comment.