Copy Link
Add to Bookmark
Report

NULL mag Issue 08 19 Autorun downloaded files

eZine's profile picture
Published in 
null magazine
 · 3 years ago

  




one feature of all modern browsers, is that while you download a file
they let you choose to open the file or just save it. this is very
helpful specially when you want to read/listen/view something "on the
fly"
the moment you download it.

i have made this request in the past, publicly... i think from here,
but i don't suppose that will see it embedded, very soon in any telnet
client. so i made my own version... kinda... that resembles this
functionality.

first of all... it's for linux! windows users you can keep reading the
other articles in here :p second, you have to install the packages
"zenity" and "inotify-tools". if you don't know how... you are also
outta here... :p

third... copy/paste the following script and make it executable. you
have to start this script, every time you run your telnet client and
let it run in the background. my favorite client is Netrunner, so i
made another script to launch both Netrunner and the "watch" script.
you can find it in the bottom.

you must setup your client to download files in the same directory the
"watchdir" script does. you can configure the watchdir script with an
editor to do that. you can also change other things.

as you can see the watchdir script detects newly created files in the
specified directory. it gets the extension of that file and if it
matches one of our categories (ansi, music, text, archive) executes
the specified program to view/listen the file. it uses the zenity
dialogs to ask you first, if you want to launch the viewer, in case
you don't.

it's a very cool feature to add and at least, personally, it helps me
a lot while visiting BBSes. hope you like it and use it a lot.


---- watchdir.sh --------------------------------------------------------
#!/bin/bash

musictype="MOD;S3M;IT;XM"
ansitype="ANS;ASC;DIZ"
texttype="TXT;DOC"
archives="ZIP;RAR;7Z;TAR"
musicplayer="audacious"
ansiviewer="xansiviewer"
zipviewer="file-roller"
textviewer="geany"
$downloaddir="/home/user/Downloads"

inotifywait -m $downloaddir -e create -e moved_to |
while read filepath action file; do
#echo "The file '$file' appeared in directory '$filepath' via '$action'"
# do something with the file
extension="${file##*.}"
filename="${file%.*}"
ext="${extension^^}"
if grep -q "$ext" <<<"$musictype"; then
zenity --question --text "Play file: $file ?"
if [ $? = 0 ]; then
nohup $musicplayer "$filepath$file" &
fi
fi
if grep -q "$ext" <<<"$ansitype"; then
zenity --question --text "View file: $file ?"
if [ $? = 0 ]; then
nohup $ansiviewer "$filepath$file" &
fi
fi
if grep -q "$ext" <<<"$archives"; then
zenity --question --text "View file: $file ?"
if [ $? = 0 ]; then
nohup $zipviewer "$filepath$file" &
fi
fi
if grep -q "$ext" <<<"$texttype"; then
zenity --question --text "View file: $file ?"
if [ $? = 0 ]; then
nohup $textviewer "$filepath$file" &
fi
fi
done
-------------------------------------------------------------------------

---- netrunner.sh -------------------------------------------------------
#!/bin/bash
pcd=$(pwd)
/home/user/scripts/watch_bbs_dir.sh &
cd /home/user/bin/netrunner
./netrunner
cd "$pcd"
-------------------------------------------------------------------------





<<< null e-magazine x008 (text edition) >>>
____ _____ _____ _____ http://github.com/xqtr/null
___/. \/ /_________/. /__/. /__jp!_ andr01d.zapto.org:9999
//_ \ . / / \ / _// agency.bbs.nz
/____/\____/ / /__________________\ d1st.org
\________/

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

lostcivilizations's profile picture
Lost Civilizations (@lostcivilizations)
6 Nov 2024
Thank you! I've corrected the date in the article. However, some websites list January 1980 as the date of death.

guest's profile picture
@guest
5 Nov 2024
Crespi died i april 1982, not january 1980.

guest's profile picture
@guest
4 Nov 2024
In 1955, the explorer Thor Heyerdahl managed to erect a Moai in eighteen days, with the help of twelve natives and using only logs and stone ...

guest's profile picture
@guest
4 Nov 2024
For what unknown reason did our distant ancestors dot much of the surface of the then-known lands with those large stones? Why are such cons ...

guest's profile picture
@guest
4 Nov 2024
The real pyramid mania exploded in 1830. A certain John Taylor, who had never visited them but relied on some measurements made by Colonel H ...

guest's profile picture
@guest
4 Nov 2024
Even with all the modern technologies available to us, structures like the Great Pyramid of Cheops could only be built today with immense di ...

lostcivilizations's profile picture
Lost Civilizations (@lostcivilizations)
2 Nov 2024
In Sardinia, there is a legend known as the Legend of Tirrenide. Thousands of years ago, there was a continent called Tirrenide. It was a l ...

guest's profile picture
@guest
2 Nov 2024
What is certain is that the first Greek geographer to clearly place the Pillars of Hercules at Gibraltar was Eratosthenes (who lived between ...

guest's profile picture
@guest
1 Nov 2024
Disquieting thc drinks has been quite the journey. As someone keen on unpretentious remedies, delving into the in every respect of hemp has ...

guest's profile picture
@guest
29 Oct 2024
hi Good day I am writing to inform you of recent developments that may impact our ongoing operations. This morning, global news outlets hav ...
Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT