Implemented autostart
This commit is contained in:
26
src/autostart.lua
Normal file
26
src/autostart.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
local io = require('io')
|
||||
local spawn = require('awful').spawn.spawn
|
||||
local readable = require('gears.filesystem').file_readable
|
||||
local confdir = require('src.util.path').conf_dir
|
||||
|
||||
local xres_name = 'awesome.did_autostart'
|
||||
-- check
|
||||
local xres_fp = io.popen('xrdb -query')
|
||||
if xres_fp == nil then return end
|
||||
local xres = xres_fp:read('*a')
|
||||
if xres:match(xres_name) then return end
|
||||
-- set
|
||||
xres_fp = io.popen('xrdb -merge', 'w')
|
||||
if xres_fp == nil then return end
|
||||
xres_fp:write(xres_name, ':true')
|
||||
xres_fp:close()
|
||||
|
||||
local autostart_file = confdir .. '/autostart'
|
||||
if readable(autostart_file) then
|
||||
for line in io.lines(autostart_file, "*l") do
|
||||
---@cast line string
|
||||
if line:len() > 0 then
|
||||
spawn(line)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user