
awesome-windowmanager가 시작되면 로그인 후 일부 명령을 실행하고 싶습니다. awesome-config에 시작 명령을 어떻게 추가할 수 있나요?
답변1
이에 따르면아치리눅스 위키다음을 추가하면 됩니다 rc.lua
.
-- Autorun programs
autorun = true
autorunApps =
{
"swiftfox",
"mutt",
"consonance",
"linux-fetion",
"weechat-curses",
}
if autorun then
for app = 1, #autorunApps do
awful.util.spawn(autorunApps[app])
end
end
위키에서는 동일한 효과를 얻을 수 있는 몇 가지 다른 방법도 보여줍니다.
답변2
나는 함께 갈 것이다덱스, 지금까지.
$ cat /etc/X11/Sessions/awesome
#!/bin/sh
# Awesome Xsession starter, based on Xsession shipped by x11-apps/xinit-1.0.5-r1
...
zenity --title "Autostart" --timeout=30 --question --text="Launch autostart items?" && dex -a
exec ck-launch-session /usr/bin/awesome
그러면 몇 가지 자동 시작 항목도 만들어 보겠습니다.
$ ls -1 ~/.config/autostart/
gol.desktop
KeePass 2.desktop
skype-skype.desktop
tomboy.desktop
wpa_gui-wpa_supplicant.desktop
xterm-logs.desktop
자동 시작 항목의 예:
$ cat ~/.config/autostart/gol.desktop
[Desktop Entry]
Type=Application
Terminal=false
Name=Growl For Linux
Comment=Growl Desktop Notification System For Linux
Categories=GNOME;GTK;Utility;
Exec=/usr/bin/gol
Icon=/usr/share/growl-for-linux/data/icon.png
X-GNOME-Autostart-enabled=true
X-KDE-autostart-after=panel
X-Desktop-File-Install-Version=0.18
답변3
그만큼멋진 위키가 제안합니다이 방법은 Awesome을 다시 로드할 때 작동합니다.
이것을 runonce.lua에 넣으세요.
-- @author Peter J. Kranz (Absurd-Mind, [email protected])
-- Any questions, criticism or praise just drop me an email
local M = {}
-- get the current Pid of awesome
local function getCurrentPid()
-- get awesome pid from pgrep
local fpid = io.popen("pgrep -u " .. os.getenv("USER") .. " -o awesome")
local pid = fpid:read("*n")
fpid:close()
-- sanity check
if pid == nil then
return -1
end
return pid
end
local function getOldPid(filename)
-- open file
local pidFile = io.open(filename)
if pidFile == nil then
return -1
end
-- read number
local pid = pidFile:read("*n")
pidFile:close()
-- sanity check
if pid <= 0 then
return -1
end
return pid;
end
local function writePid(filename, pid)
local pidFile = io.open(filename, "w+")
pidFile:write(pid)
pidFile:close()
end
local function shallExecute(oldPid, newPid)
-- simple check if equivalent
if oldPid == newPid then
return false
end
return true
end
local function getPidFile()
local host = io.lines("/proc/sys/kernel/hostname")()
return awful.util.getdir("cache") .. "/awesome." .. host .. ".pid"
end
-- run Once per real awesome start (config reload works)
-- does not cover "pkill awesome && awesome"
function M.run(shellCommand)
-- check and Execute
if shallExecute(M.oldPid, M.currentPid) then
awful.util.spawn_with_shell(shellCommand)
end
end
M.pidFile = getPidFile()
M.oldPid = getOldPid(M.pidFile)
M.currentPid = getCurrentPid()
writePid(M.pidFile, M.currentPid)
return M
다음과 같이 사용하세요:
local r = require("runonce")
r.run("urxvtd -q -o -f")
r.run("urxvtc")
r.run("urxvtc")
r.run("wmname LG3D")
답변4
ArchWiki 접근 방식
새로운 사용자의 경우 ArchWiki에서 다음을 수행해야 함을 알 수 있습니다.
- 생성
~/.config/awesome/autorun.sh
및 추가
#!/usr/bin/env bash
function run {
if ! pgrep -f $1 ;
then
$@&
fi
}
run
프로세스 grep을 사용하여 확인하고(프로세스를 다시 실행하지 않도록) bin을 배경에 바로 넣습니다.
~/.config/awesome.rc.lua
쉘(bash 또는 설정한 것)을 사용하여 해당 파일을 생성하도록 지시합니다 . 이렇게 하면 됩니다(파일의 마지막 줄).
awful.spawn.with_shell("~/.config/awesome/autorun.sh")
더 간단한 접근 방식
이제 나에게는 많은 주장으로 인해 pgrep이 약간 까다로웠습니다. 그래서 나는 최소한 내가 사용하기에는 더 간단하고 좋은 스크립트를 작성했습니다. 이것은 나의 autorun.sh
:
#!/usr/bin/env bash
feh --bg-scale $(ls ${HOME}/wallpaper/*.png|shuf -n1) &
nm-applet &