How to send selected/hovered file as argument to shell command #2102
Replies: 4 comments
-
i have removed used code form my previous code and now swww is working but for some reason swww Task is still running if i add notify code local get_url = ya.sync(function()
-- You can access all app data through the `cx`,
-- within the `sync()` block, in an async plugin
local h = cx.active.current.hovered
-- return h and state.a .. tostring(h.url) or b
return tostring(h.url)
end)
return {
entry = function()
local h = get_url()
ya.dbg(h)
local wallpaper_cmd = string.format('swww img "%s" --transition-type=wipe --transition-duration=5', h)
ya.dbg(wallpaper_cmd)
local wallpaper_status, wallpaper_err = os.execute(wallpaper_cmd)
ya.notify({
title = "Wallpaper Set",
content = "Wallpaper set to " .. selected_file,
level = "info",
timeout = 5,
})
end,
} Any suggestions ? |
Beta Was this translation helpful? Give feedback.
-
After adding --- @sync entry the code seems to be working . My final code : --- @sync entry
local get_url = ya.sync(function()
local h = cx.active.current.hovered
return tostring(h.url)
end)
return {
entry = function()
local h = get_url()
-- ya.dbg(h)
local wallpaper_cmd = string.format('swww img "%s" --transition-type=wipe --transition-duration=5', h)
-- ya.dbg(wallpaper_cmd)
local wallpaper_status, wallpaper_err = os.execute(wallpaper_cmd)
ya.notify({
title = "Wallpaper Set",
content = "Wallpaper set to " .. h,
level = "info",
timeout = 5,
})
end,
} I have no idea about efficiency of the code so any suggestion will be deeply appreciated. |
Beta Was this translation helpful? Give feedback.
-
There's no
|
Beta Was this translation helpful? Give feedback.
-
Thanks , it is working . |
Beta Was this translation helpful? Give feedback.
-
What system are you running Yazi on?
Linux Wayland
What terminal are you running Yazi in?
kitty
yazi --debug
outputDescribe the question
Hi all ,
i want to set wallpaper using swww command by mapping c + g . In ranger it is quite easy to do by appending the following :
"map cg shell swww img %s --transition-type=wipe --transition-duration=5" to rc.conf file of ranger.
i have already tried to mimic this in yazi by appending following to keymap.toml file :
[[manager.prepend_keymap]]
on = [ "c", "g" ]
run = "swww img %s --transition-type=wipe --transition-duration=5"
desc = "Set wallpaper"
But i cannot find anything in the documentation of yazi to pass selected file as argument .
is it even possible in yazi ?
Do i need to write a custom plugin to achieve this ?
Any suggestions ?
Anything else?
i have written this custom plugin to achieve this based on compressor plugin but the problem is that i have to manually input the file name of image file to set the wallpaper which is not ideal.
Checklist
Beta Was this translation helpful? Give feedback.
All reactions