Skip to main content

Lebih Mudah Dengan Shell Script

Ada banyak kepentingan dalam bekerja dengan komputer. Yang pasti, bagi sebagian besar orang termasuk saya, sulit untuk bekerja di depan komputer tanpa di iringi oleh musik. Lalu apa masalahnya?

Masalahnya adalah, seringkali kita dalam posisi bekerja dengan aplikasi yang berat semisal GIMP dan Inkscape, sementara aplikasi pemutar musik kita juga lumayan berat, katakanlah Amarok. Menghemat memory sangat penting di sini. Alternatifnya, kita bisa menggunakan aplikasi pemutar musik command-line seperti mpg321 atau Moc. Sangat hemat sekali memory. Dari hasil cek saya lihat di 'gnome-system-monitor', saya dapati aplikasi mpg321 hanya 'memakan' memory sekitar 600-an kilobyte saja! Sangat hemat sekali!


Permasalahan utamanya, dalam banyak konteks dan keperluan, bekerja dengan modus teks terasa tidak praktis, termasuk menggunakan mpg321. Katakanlah kita ingin memainkan musik di direktori :

mpg321 /home/anu/Music/bla/bla/anu/entah\ berantah/dll/ dan/lain\ lain/*.mp3 *.MP3


Repot kan? Lalu bagaimana? Gampang! Buat saja shell script! Struktur shell script mirip dengan struktur html. Misal, sebagai contoh, saya punya koleksi musik di direktori “/home/alwan/Music/Gary\ Moore/Ballad\ And\ Blues\ 1982/-\ 1994/”, shell script untuk menjalankan mpg321 adalah sebagai berikut :

!/bin/sh
mpg321 /home/alwan/Music/Gary\ Moore/Ballad\ And\ Blues\ 1982/-\ 1994/*.MP3

(lebih nyaman bagi saya menggunakan Gedit daripada Vi untuk menulis script)


Simpan dengan nama terserah kita, misal saja “gary_moore”. Terakhir, kita hanya perlu membuatnya executable dengan men-chmod ke u+x.


$ chmod u+x gary_moore (tanpa autentifikasi root)


Jadilah sekarang kita punya shell script memainkan musik menggunakan mpg321. Untuk menjalankannya kita tinggal men-double klik, lalu pilih “Run in Terminal” atau “Run”, dan aplikasi mp321 memainkan koleksi musik kita dengan cara yang sangat simpel dan praktis!


Shell script bisa juga di gunakan untuk perintah lain yang kita butuhkan, dengan memanfaatkan utilitas dasar di sistem linux, atau aplikasi yang ada di sistem kita. Sebagai contoh, saya membuat Shell script untuk membuka dan menutup DVD-ROM. Dengan memanfaatkan utiliti dasar eject, skrip-nya sangat simpel sekali.

Skrip 'buka_dvd'
!/bin/sh
eject

Skrip 'tutup_dvd'
!/bin/sh
eject -t


Menarik bukan? Selamat ber-Linux! ^_^



Comments

Sumodirjo said…
ajarin skripting dong mas :) BTW, gak pake bash?
Alwan Rosyidi said…
mas sumodirjo ada2 saja... semestina saya yang di ajari owgh... ^_^
milano94 said…
mp3blaster.. maknyooosss :)

Popular posts from this blog

Q4OS 4.6 "Gemini" Review: A Real Hidden Gem

Distro hopping is a fun adventure. It's a pure joy you can only find in GNU/Linux world. It's a nature you want to escape from what I call 'comfort ecosystem'. You need to play, trying something new even for a few little differences. For a long time I've been using Ubuntu family as my daily driver. The main reason is probably just same as any other Ubuntu user: it's reliable. You can't go wrong with Ubuntu. It works almost in any device, even for the newest one. It is the ultimate Linux distro you can rely on. However, sometimes, you will feel bored. The temptation to flirt with other new distro is unbearable. There are a lot of hot new Linux distros waiting to try.  A Real Hidden Gem I've known this distro for a quite long time. At first, it offered Trinity Desktop as the main desktop, which brings me the sweet memories about KDE3. It is simply fast, stable, almost without any issue, and it is based on Debian. I install it on my old machine and I love t

How To Install Mac OS X Lion Theme On Lubuntu / LXDE

Lubuntu 12.04 with Mac OS X Lion Theme, xcompmgr & cairo-dock [click to enlarge] Mac OS X is the special one in the Desktop market. So many people admire it because of its beauty, safety (yes, it is an UNIX) and its profesional image as “an OS for profesional modern art designer”. Yeah, Mac OS X has beautiful look and I do like its look-n-feel. And so, there are so many theme patcher to make our Microsoft Windows or Linux OS become Mac OS X in the appearance. In Linux Desktop, there are some project specialized in designing theme transformation pack to make our Linux desktop to be looked like Mac OS X. The most popular project probably is Mac4Lin. But, all of those projects was designed only for GNOME or sometimes support XFCE and how about LXDE? Our Star in the current lightweight Linux desktop? (Yes, LXDE is the most light-but-complete Linux desktop for now). Until now, there is no project that officially support LXDE. Basically, LXDE uses gtk (now still stay w

Howto Connect To Windows Share Network (Connect To Server) Easily in PCManFM

In Nautilus 3.4, Nemo, or Caja, there is a very useful menu called "Connect to Server". This menu allow us to connect to a Windows Share network via Samba. If you are using another desktop environment such as LXDE, there aren't such menu, and we need to install third party tool called Gigolo . But apparently, PCManFM (the default file manager of LXDE) already has such function. We could connect to a Windows Share network in PCManFM easily. Here are the simple steps : 1. Open PCManFM and go to adress bar, and type this command : smb://username@server/folder example : smb://staff@192.168.1.69/document then press Enter 2. Once you will be asked to input the Windows Share Network password (if exists), select Remember Forever option. 3. You are connected to Windows Share Network ;)