- 1. 概要
- 2. 定義
- 3. FreeBSD で真似っこ
1. 概要
「xmonad」で、ログイン時に自動起動するプロセスは、他のタイル型ウィンドウマネージャと同様、独自の記述があるようです。
すなわち、タイル型以外で「~/.xinitrc」「~/.xprofile」に記述したり、「~/.config/autostart」配下に、「.desktop」ファイルを置くものではないようです。
2. 定義
現在(2020年5月28日)、動作しているものは、「AcroLinux 19.12.15 xmonad」のものしかないので、これを参考に見ていきます。
vi ~/.xmonad/xmonad.hs
まず
myStartupHook = do
spawn "$HOME/.xmonad/scripts/autostart.sh"
setWMName "LG3D"
という定義がありまして、末尾の方で
main :: IO ()
main = do
dbus <- D.connectSession
-- Request access to the DBus name
D.requestName dbus (D.busName_ "org.xmonad.Log")
[D.nameAllowReplacement, D.nameReplaceExisting, D.nameDoNotQueue]
xmonad . ewmh $
--Keyboard layouts
--qwerty users use this line
myBaseConfig
--French Azerty users use this line
--myBaseConfig { keys = azertyKeys <+> keys azertyConfig }
--Belgian Azerty users use this line
--myBaseConfig { keys = belgianKeys <+> keys belgianConfig }
{startupHook = myStartupHook
, layoutHook = gaps [(U,35), (D,5), (R,5), (L,5)] $ myLayout ||| layoutHook myBaseConfig
, manageHook = manageSpawn <+> myManageHook <+> manageHook myBaseConfig
, modMask = myModMask
, borderWidth = myBorderWidth
, handleEventHook = handleEventHook myBaseConfig <+> fullscreenEventHook
, focusFollowsMouse = myFocusFollowsMouse
, workspaces = myWorkspaces
, focusedBorderColor = focdBord
, normalBorderColor = normBord
, keys = myKeys
, mouseBindings = myMouseBindings
}
361行目の定義で、43行で定義したものを生かしているようです。
となれば、44行目の記述から
~/.xmonad/scripts/autostart.sh
に起動スクリプトがあるのではないか?
・・・ありました。
短いので、まんま、のっけてみます。
#!/bin/bash
function run {
if ! pgrep $1 ;
then
$@&
fi
}
#Set your native resolution IF it does not exist in xrandr
#More info in the script
#run $HOME/.xmonad/scripts/set-screen-resolution-in-virtualbox.sh
#Find out your monitor name with xrandr or arandr (save and you get this line)
#xrandr --output VGA-1 --primary --mode 1360x768 --pos 0x0 --rotate normal
#xrandr --output DP2 --primary --mode 1920x1080 --rate 60.00 --output LVDS1 --off &
#xrandr --output LVDS1 --mode 1366x768 --output DP3 --mode 1920x1080 --right-of LVDS1
#xrandr --output HDMI2 --mode 1920x1080 --pos 1920x0 --rotate normal --output HDMI1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output VIRTUAL1 --off
(sleep 2; run $HOME/.config/polybar/launch.sh) &
#change your keyboard if you need it
#setxkbmap -layout be
#cursor active at boot
xsetroot -cursor_name left_ptr &
#Some ways to set your wallpaper besides variety or nitrogen
feh --bg-fill /usr/share/backgrounds/arcolinux/arco-wallpaper.jpg &
#start the conky to learn the shortcuts
(conky -c $HOME/.xmonad/scripts/system-overview) &
#starting utility applications at boot time
run variety &
run nm-applet &
run pamac-tray &
run xfce4-power-manager &
numlockx on &
blueberry-tray &
picom --config $HOME/.xmonad/scripts/picom.conf &
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &
/usr/lib/xfce4/notifyd/xfce4-notifyd &
#starting user applications at boot time
#nitrogen --restore &
#run caffeine &
#run vivaldi-stable &
#run firefox &
#run thunar &
#run spotify &
#run atom &
#run volumeicon &
#run telegram-desktop &
#run discord &
#run dropbox &
#run insync start &
#run ckb-next -b &
つまり、末尾の方に
run 実行ファイル名
と記述しちゃえば、起動できるようです。
3. FreeBSD で真似っこ
果たして、「FreeBSD」で、真似できるであろうか・・・。
軽く、「autostart.h」を作成。
「VBoxClient-all」「xrandr」を記述してみます。
mkdir -pv ~/.xmonad/scripts
cat << EOF >> ~/.xmonad/scripts/autostart.sh
#!/usr/local/bin/bash
function run {
if ! pgrep -lfa $1 ;
then
\$@&
fi
}
run /usr/local/bin/VBoxClient-all
run xrandr -s 1366x768
EOF
chmod +x ~/.xmonad/scripts/autostart.sh
あ~これ、「bash」が必要なので、インストールしていなければ、「root」ユーザで
pkg install -y bash
が必要です。
次に
vi ~/.xmonad/xmonad.hs
-- By default, do nothing.
myStartupHook = return ()
を下記に変更します。
-- By default, do nothing.
myStartupHook = do
spawn "$HOME/.xmonad/scripts/autostart.sh"
以降は、
~/.xmonad/scripts/autostart.sh
に、ログイン時に自動起動したいモジュールを追加していけば、いいことになります。
|