これを行うためにbashスクリプトを作成しました。xdotoolコマンドを使用して、コードセグメント内のURLおよびマウスの位置とボタンクリックをカスタマイズできることに注意してください。ソースコードは次のとおりです。
via:bashプレイリストのすべての素晴らしいYTC
#!/bin/bash
echo " "
sudo apt-get install xdotool -y
sleep 2
echo " "
echo "# NASA/NOAA/NHC Hurricane Satellite Imagery Bot [H.S.I.B]"
echo "# Coded by Scott Hermann "
echo "[ YouTube: https://www.youtube.com/user/postulatedstate/videos/ ]"
echo " "
# * * Instructions * *
# 1] Click on map to select area to monitor.
# 2] Set delay variable ( time between saves )
# The script will now refresh and save the images-
# -every X seconds, and save using the filenames
# filename-X.jpg; filename-X.jpg; etc..
export PS1="\e[0;30m[\u@\h \W]\$ \e[m "
# make black prompt - color code=[0;30]
chromsat_loop()
{
chromium -new-tab https://weather.msfc.nasa.gov
sleep 2
notify-send "Your browser will now open the NASA website. Select the section of earth to monitor via Satallite by clicking on it, and then enter Y or N (caps) into the terminal, or press the [Begin] button on the GUI."
echo " "
}
get_settings()
{
echo -n "Enter storm name: "; read stormname
echo -n "Season? [ Ex: 2017 ] "; read season
echo -n "Month "; read month
# echo -n "data"; <- remember ;
sleep 2
echo " "
echo "Checking to see if a database for hurricane $stormname of the $season season exist in the month of $month"
sleep 2
echo " "
# if dir $season = true then confirm
if [ -d /root/Desktop/$season ]; then
notify-send "The hurricane season exist in the database."
echo "The hurricane season exist in the database."
echo " "
else
echo "It doesn't appear that this season is in the database. I will create it for you."
mkdir /root/Desktop/$season
fi
# if dir $season/$month = true then confirm
if [ -d /root/Desktop/$season/$month ]; then
notify-send "The month entered has data in the database."
echo "The month entered has data in the database."
echo " "
else
mkdir /root/Desktop/$season/$month
fi
# if dir $season/$month/$stormname = true then confirm
if [ -d /root/Desktop/$season/$month/$stormname ]; then
notify-send "This storm is in the database."
echo "This storm is in the database."
else
echo "Adding the storm to the database."
notify-send "Adding the storm to the database."
echo " "
sleep 1
mkdir /root/Desktop/$season/$month/$stormname
fi
echo " "
sleep 2
echo -n "Enter data retrieval delay variable: ( 1200 = 20 minutes ) "; read delay
echo " "
sleep 2
echo " "
echo "1] Chromium"
echo "2] Firefox"
echo "3] Qupzilla"
echo "4] Modori"
echo " "
echo -n "Which Web-Browser are you using? "; read browser
if [ "$browser" = "1" ]; then
echo "Initializing NASA Data Transfer..."
chromsat_loop
fi
if [ "$browser" = "2" ]; then
echo "$browser set to Firefox"
fi
# End Of Function
}
get_settings
# Note: Calling functions in bash -> fun_ction
# Create 4 functions for the 4 browsers it will support..
ready_ornot()
{
notify-send "In 45 seconds, the script will begin data retrieval.. Go ahead and select the portion of the storm on the map that you wish to monitor. Save the first image to the directory on your desktop. It's listed under the year, the month, and the storm. From there, the bot will save the images to that folder."
echo "In 45 seconds, the script will begin data retrieval.. Go ahead and select the portion of the storm on the map that you wish to monitor. It's listed under the year, the month, and the storm. From there, the bot will save the images to that folder."
newloop=0
until [ "$newloop" = "45" ]
do
sleep 1
echo "Initializing data retrieval process in 45 seconds. @ $newloop second(s)...."
newloop=`expr $newloop + 1`
done
notify-send "Initializing data retrieval process.. "
echo "Initializing data retrieval process.."
echo " "
}
ready_ornot
begin_dataretr()
{
sleep 2
notify-send "@ Data Retrieval Function."
# url opened in new tab waiting
# variables=value; = NO space [x]-> var = 1<-(wrong)
forever=1
looper=1
while [ "$forever" == "1" ];
do
# refresh chromium page
sleep $delay && echo $delay # 60 for test; 1800=30 mins
# Save images after refresh;
# plug\/ looper \/ variable in filenames
# file1.jpg file2.jpg file3.jpg etc.
# <!--#!/bin/bash-> to be modified and completed * * * * * * * * * #!/bin/bash -!>
# CD to folder
# /root/Desktop/season/month/stornname
# ( that should make the save as file dialog box open in our folder )
echo " "
echo "Done sleeping.."
echo " "
# xdotool getmouselocation --shell
xdotool mousemove 765 438
# mouse positioned to click on save file box
# for loop through var to save file name as
sleep 1
xdotool click 1
# text box clicked and waiting.
sleep 1
xdotool key F5
sleep 7
xdotool mousemove 953 229
sleep 1
xdotool click 1
sleep 5
xdotool click 3
sleep 3
xdotool key Down
xdotool key Down
sleep 2
xdotool mousemove 983 261
sleep 1
xdotool click 1
sleep 1
# xdotool key Enter
sleep 1
xdotool mousemove 1146 763
sleep 1
xdotool click 1
notify-send "New data retrieval has been saved to database.."
# <!--#!/bin/bash-> to be modified and completed * * * * * * * * * #!/bin/bash -!>
done
}
begin_dataretr
# no () when calling functions.
# - - - - - - - only when def them.