index posts opinions likes dislikes interesting cgit


My posts about programming and things.
Date format is day/month/year because I'm sane.

startup scripts


I setup and open a few things when I log into my computer through .bash_profile, these include two instances of irssi, mutt, a slack-to-irc gateway and cmus.

This is achieved through three shell scripts:

main.sh - this script launches my other two scripts. It checks for the file /tmp/started, if it exists nothing is done and the script exits. If the file does exist the file /tmp/started is created (empty) and my two other scripts start. /tmp is wiped on boot.


cd "$HOME/programming/bash/autostart"

if [ ! -f /tmp/started ]; then
	touch $TMPFILE
cd $HOME
startup.sh - This script is responsible for launching irssi, cmus and mutt. I open these in a tmux session named main. It has 3 windows named irssi. cmus and mutt respectively.

tmux new-session -d -s main -n irssi
tmux new-window -t main:1 -n cmus
tmux new-window -t main:2 -n mutt

tmux send-keys -t main:0 "firejail irssi" C-m
tmux send-keys -t main:1 "cd $HOME/music/japanese;cmus" C-m
tmux send-keys -t main:2 "firejail mutt" C-m
cd $HOME
slack.sh - This script is responsible for launching my slack-to-irc gateway and an irssi instance that automatically connects to it. Once again a tmux session is created with two windows named lsirc and irssi.
cd $BASE
tmux new-session -d -s slack -n lsirc
tmux new-window -t slack:1 -n irssi

tmux send-keys -t slack:0 "cd $BASE;python3 ./irc.py -j" C-m
sleep 1
tmux send-keys -t slack:1 "firejail irssi --home $HOME/.slackirssi -c -p 9007" C-m
While simple, its really effective and saves a lot of effort every boot. Is there a better way to run a script once when you initially log in? Probably but the effort to search was more than it was worth.

page generated 11-12-2018 01:26:57 using sitegenerator