Last active
October 9, 2017 14:04
-
-
Save gfonseca/8c41d07942e967080a185933f4c8f809 to your computer and use it in GitHub Desktop.
Google chrome app window opener
This file contains hidden or 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 | |
#This script allow to easily start chrome pages as app windows | |
function register { | |
read -p "The app alias: " alias | |
read -p "The complete domain: " domain | |
if echo "$alias $domain" >> $HOME/.gcapp | |
then | |
echo "Registration OK" | |
else | |
echo "Registration failed" | |
fi | |
} | |
function load { | |
if [ -z $1 ] | |
then | |
read -p "Alias: " alias | |
set -- "$alias" | |
fi | |
i=0 | |
while read p; do | |
app=(`echo $p | sed 's/,/\n/g'`) | |
if [ "${app[0]}" == "$1" ] | |
then | |
i=$[ $i + 1 ] | |
`echo "google-chrome --app=${app[1]} >> /dev/null &"` | |
break | |
fi | |
done < $HOME/.gcapp | |
if [ $i -eq 0 ] | |
then | |
echo "App not found" | |
else | |
echo "Done." | |
fi | |
} | |
function list { | |
echo "_____________________________________________________" | |
i=1 | |
while read p; do | |
echo "$i. $p"; | |
i=$[ $i + 1 ] | |
done < $HOME/.gcapp | |
echo "_____________________________________________________" | |
} | |
function prompt { | |
echo "Google chrome terminal apps." | |
echo "1. Register" | |
echo "2. Load" | |
echo "3. remove" | |
echo "4. list" | |
echo "5. done" | |
read -p " > " opt | |
if [ $opt -eq 1 ] | |
then | |
register; | |
elif [ $opt -eq 2 ] | |
then | |
load; | |
elif [ $opt -eq 3 ] | |
then | |
remove; | |
elif [ $opt -eq 4 ] | |
then | |
list; | |
elif [ $opt -eq 5 ] | |
then | |
break | |
else | |
echo "Invalid option" | |
fi | |
} | |
while true; do | |
if [ -z "$1" ] | |
then | |
prompt | |
else | |
while [ -n "$1" ] | |
do | |
load "$1" | |
shift | |
done | |
break | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment