Created
June 25, 2015 15:31
-
-
Save shoaibi/b63f621f3d91b0983551 to your computer and use it in GitHub Desktop.
Start a workspace (preset programs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# I am mostly working in either of 2 modes: | |
# 1- work [ pass 'work' as first argument ] | |
# 2- not-work [ default] | |
# | |
# And over the years I have found it to be a pain to have to | |
# manually start the same 5-6 prorgams everytime my laptop | |
# got rebooted so I created a script with those presets | |
# and then set openbox to start the relevant workspace | |
# give then day and time | |
# | |
function start_if_not_running() | |
{ | |
program="$1" | |
search_program="$program" | |
if [ "$program" = "google-chrome-stable" ]; then | |
search_program="chrome"; | |
fi | |
if [ "x$program" = "x" ]; then | |
return; | |
fi | |
binary=$(echo $search_program| awk '{print $1}') | |
if [ $(ps aux | grep -v dockmanager | grep -c "$binary") -eq 1 ]; then | |
echo "$binary is not running" | tee -a /tmp/workspace.log | |
eval nohup "$program" 2>&1 1> /dev/null & | |
else | |
echo "$binary is running" | tee -a /tmp/workspace.log | |
fi | |
echo | |
} | |
workspace="$1" | |
rm /tmp/workspace.log | |
start_processes= | |
terminal="terminator" | |
file_manager="nemo" #common | |
sublime_text="subl3" #common | |
chrome="google-chrome-stable" #common | |
skype="skype" #common | |
start_processes[10]="$terminal" | |
start_processes[11]="$file_manager" | |
start_processes[12]="$sublime_text" | |
start_processes[15]="$chrome" | |
start_processes[20]="$skype" | |
if [ "$workspace" = "work" ]; then | |
terminal="${terminal} --layout=my-company-name-here" | |
chromium="chromium" | |
phpstorm="phpstorm" | |
toggl_desktop="toggl-desktop" | |
start_processes[10]="$terminal" | |
start_processes[13]="$toggl_desktop" | |
start_processes[16]="$chromium" | |
start_processes[17]="$phpstorm" | |
fi | |
for i in "${start_processes[@]}" | |
do | |
start_if_not_running "$i" | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment