Solved question about xscreensaver with awesome in freebsd 14.2 ?

Dear all:
now i have used awesome desktop GUI in freebsd14.2 . and install xscreensaver for screen lock .
question : what is correct way to let xscreensaver running as a daemon when user login,or system boot ?
run_once({ "xscreensaver &"}) is right way ?
.
and how to binding a key to active lock screen in awesome , i have read more post, but don't find a solution .
below was my configuration.
awful.key({ modkey ,"Control"},"l" , function() awful.util.spawn("xscreensaver-command -lock") end,
{description = "lock screen " })
this configure got error. please help me .

thanks.
 
Add this to the end of your rc.lua
Code:
function run_once(prg,arg_string,pname,screen)
    if not prg then
        do return nil end
    end

    if not pname then
       pname = prg
    end

    if not arg_string then
        awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. "' || (" .. prg .. ")",screen)
    else
        awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. " ".. arg_string .."' || (" .. prg .. " " .. arg_string .. ")",screen)
    end
end

run_once("xscreensaver","-nosplash")
 
Add this to the end of your rc.lua
Code:
function run_once(prg,arg_string,pname,screen)
    if not prg then
        do return nil end
    end

    if not pname then
       pname = prg
    end

    if not arg_string then
        awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. "' || (" .. prg .. ")",screen)
    else
        awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. " ".. arg_string .."' || (" .. prg .. " " .. arg_string .. ")",screen)
    end
end

run_once("xscreensaver","-nosplash")
Dear sirdice :
i have done . code was blow. thanks.
-- my custom's content at 2025
--1. running screenlock daemon
local function run_once(cmd_arr)
for _, cmd in ipairs(cmd_arr) do
awful.spawn.with_shell(string.format("pgrep -u $USER -fx '%s' > /dev/null || (%s)", cmd, cmd))
end
end

run_once({ "xscreensaver --no-splash"})

--2 . define bindingkey for lock screen .

awful.key({ modkey ,"Control"},"l" , function() awful.spawn("xscreensaver-command -lock") end,
{description = "lock screen " }),

below 2 items, you must edit your ~/.config/awesome/rc.lua

thanks for master sirdice . maybe help others.
 
Back
Top