Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Tuesday, February 15, 2011

Counter Strike on Archlinux

Well, got a few shots of Vodka, and now I'm very sleepy, so forgive my sloppy writing. FYI, I'm not a regular drinker, and drinking spirits is prohibited in my religion.

The old good Counter Strike, it's outdated but it's awesome since it could run on cheaper, outdated graphic cards, including the built-in Intel graphics card on my Acer Aspire 2920 laptop without any problems. Haven't tried Point Blank or newer FPS...

So it happened that my friends in the student association played CS, and I was invited to join too. I downloaded an illegal copy from a local server, then tried to install it on wine.

The installation went fine, but then, when I run the binary, what I got is Half-Life instead of Counter Strike. A little bit of googling gave me the command flag '-game cstrike' as the argument needed to run Counter Strike from hl.exe.

It works fine, I'll explain it later.

There are several problems, however.

First, if you tried to join a multiplayer in the middle of a round, the app seemed to freeze, but that was not the case. Just call the in-game menu, and exit from it, then it'll be fine.

Second, you can't invoke 'wine start $Path_to_executable/hl.exe -game cstrike'. Unless you're in the installation directory, the app will crash before it load, returning some error messages. You must call 'wine hl.exe -game cstrike' from the installation directory.

Third, Counter Strike (or Half-Life) runs in SDTV 4:3 aspect ratio, instead of widescreen in a normal Windows environment. I guess it's just a matter of application settings.

Anything else just works out of the box, you could play it seamlessly, without any lagging or other problems, even in multiplayer mode (there are network connection errors sometimes that crashed the app, but it's very rare).

FYI, I'm not a good CS player, out of 5 times being killed, I only manage to kill once... :p

There are other Windows games I've tried with wine, too...

Ragnarok Online, works fine, only if there were not-so-many other human players around. If you happened to be on a party, be prepared for a horrible lag, almost making it unplayable (my processor is 1.8GB core2duo, and an onboard weak Intel graphics card, I dunno if it worked well on better hardware).

Some japanese visual novels. At least Symphonic Rain worked out of the box, including its VOS-like mini game session. Alas, another VN (I forgot the title) crashed when playing in-game character dialog (I think it also holds true for most VNs). Fate/Stay Night failed as it couldn't recognize the mounted image as a real original CD needed to run it (or maybe I just couldn't make it work).

Hmm... I doubt that Wine would make it for high-end games, such as Unreal Tournament.

Sunday, February 13, 2011

Flac to Ogg Converter (Bash Shell Script)

My recently gathered collections of anime and Japanese musics are mostly FLACs. If you haven't heard of it, it's a free and open source encoding for storing the exact data from a WAV audio file (this is the one you get directly from ripping an audio CD - CMIIW, the data dump from an audio CD) at half of its original size. This means, you can get the equal quality of an audio CD track with only half of the original space.

Of course, if you have FLAC files, it doesn't mean you could enjoy a crispy bright playback of an audio CD. There are several more factors, they are, your sound card, your amplifiers and speakers. As for me, with only on board sound card and a Sony Ericsson standard Walkman phone headset, it's meaningless to play FLAC tracks on my laptop. It just a waste of precious harddisk space. But nonetheless, I still spare them for keepsake, in case someday I could afford a better audio system.

So, the solution for a time being is to burn my FLAC collections onto DVDs, then ripping them into OGG format. This tutorial on Archlinux Wiki provides the basic script, I made some slight modification to it so that the final result would be OGG instead of MP3. This script will work on any UNIX system with bash shell on it (including Cygwin).

First, you need to provide all the dependencies. You will need these binaries (refer to your distro guide on how to install them).
flac oggenc
Then, copy the following script to your text editor, save it as anything you feel like (the convention is not to give any extension to the filename, as this is an executable , and normally executables don't have any extension). In this example, I save it as flac2ogg.
#!/bin/bash

for a in *.flac

do
OUTF=`echo "$a" | sed s/\.flac$/.ogg/g`

ARTIST=`metaflac "$a" --show-tag=ARTIST | sed s/.*=//g`
TITLE=`metaflac "$a" --show-tag=TITLE | sed s/.*=//g`
ALBUM=`metaflac "$a" --show-tag=ALBUM | sed s/.*=//g`
GENRE=`metaflac "$a" --show-tag=GENRE | sed s/.*=//g`
TRACKNUMBER=`metaflac "$a" --show-tag=TRACKNUMBER | sed s/.*=//g`
DATE=`metaflac "$a" --show-tag=DATE | sed s/.*=//g`

echo "$a"

flac -c -d "$a" | oggenc -q 8 -a "$ARTIST" -G "$GENRE" -t "$TITLE" -d "$DATE" -n "$TRACKNUMBER" -l "$ALBUM" - -o "$OUTF"

done
The next step, as a superuser, make it executable.
$ sudo chmod 0775 flac2ogg
Still as a superuser, copy it to the local binary directory, /usr/local/bin.
$ sudo cp flac2ogg /usr/local/bin
The final step, as a normal user, add /usr/local/bin into PATH environment variable. To make it handy, we will need to modify the .bashrc file so that/usr/local/bin is always in PATH every time you log in. Now you can call the script from anywhere.
$ export PATH=$PATH:/usr/local/bin
Add the same line above to your .bashrc.

To use it, navigate to a directory (in a terminal, of course) where you place your FLAC files you want to convert. Simply type the script name, the terminal will show the encoding progress. The final OGG files will have the name and tags from the original FLAC files.

Now you can manually remove the unused FLAC files.
rm -v *.flac
Adding this line will get your script to automatically remove the original FLAC right after it has been encoded to OGG. Put it before the very last line (before done).
...
rm -v "$a"
done

PS:

The blogger editor fails so hard, either in HTML or WYSIWYG mode. Srsly, they need to fix it up. It always complains errors when I add images, and it also messing up the 'quote' command. I wonder why they always said blogger is better than wordpress.

Edit:
PHAIL. It cannot change the font into fixed-width font (Courier). blogger.com sucks.

Sunday, January 2, 2011

Mobi USB Modem, An Archer's Adventure

Foreword
Before knowing anything about bittorrent, or following the latest anime series, I think the internet connection from my campus is more than enough.

Yeah, you just pay $12.5 per month, and you got sonic-fast speed (at least, compared to net cafes in Indonesia), 2 MBps attainable from a good server with download manager (such as, sourceforge.net).

But, $12.5 a month comes with many restrictions. Most obvious, the proxy server only allows connections through port 80 and 443. That means, no IRCs, no torrents. Then, several sites, such as filesharing sites, rapidleech, and even 4chan are also blocked.

For the last couple of months, I managed to circumvent the squid's barricade using tor, and after running proxy daemons on my laptop, I could get the bittorrent running, as well as surfing on porn sites.... :p.

After a while, I decided to stop abusing tor for my own fun. I need to have a good internet connection with a reasonable price. And, after suddenly found out that $325 had been transferred to my account by an unknown angel on the new year, I made up my mind to get a CDMA USB modem.

Some Available Choices
Here in Indonesia, the most popular internet connections are ADSL from Speedy, and then several GSM mobile broadband services. The CDMA services are also getting more and more popular, and it's getting very good reviews, compared to horrible stories around GSM services.

So, I randomly selected a Pantech USB modem bundled with mobi broadband plan.

The Long, Winding Path To The Net
Now I'm ready to get started.

I unpacked the modem, read some instructions there. The installation CD shipped with the package is almost useless for me, since I'm running a vanilla-flavored Linux distro with a minimalist-window-manager-for-geeks.

First attempts with KDE's kppp, rp-pppoe and raw pppd ended up with failure. The user's guide said something about registering my number, by texting a registration message to the registration center, using the modem's connection manager. Unfortunately, my OS didn't allow me to do so, and from my experiences, the modem vendors were not very happy about giving customer support for those who run Linux.

I guess, it was because my number had not been registered yet.

So I dashed down to campus, immediately searched for a friend, and borrowed his Windows box. I sent the registration text to no avail, even after retrying that at least five times.

Nevertheless, I stubbornly tried to connect, using sheer brute force to modify the chat script. This is the first problem, pppd chat script.

The pppd specifies that a chat script for dialling the ISP to be made. Heck, I don't know anything about the login strings, and to add up the mess, there's no way you could 'talk to the modem interactively', I meant, sending strings to the modem and see how the modem would react.

kppp and rp-pppoe also failed. Anyway, kppp is only my temporary resort, and I would discard it as soon as I learned how to connect without a GUI. Yes, I will sometime leave my box running, downloading torrent, and it would be much more efficient for the system if I just run some torrent client without having to load the Xorg server. I could just spawn the client on screen, detaching it, and logging out from my box.

Googling out, I found an application, wvdial. It allows the user to connect via pppd without 'being forced to write the chat script'. From it, I learned that my mistake was not only on the chat script. I pointed the wrong device!!

dmesg output told that the device (modem) I've inserted is registered on ttyUSB0, but it was something other. The real address for the modem is on ttyACM0, as shown on dmesg output several lines above the very last line.

Next attempts were successful, except that, I could not get connected, surely because my number hadn't been registered.

The first day ended up without any success, but I've figured out how to use my modem without any help from GUI-based applications or distro-specific network management tools (which I really hate).

The next day (today), I went to the customer service center on BEC Mall, asking for activation. The customer support there said that they are on some sort of system migration, and several things don't work out correctly, such as registration via text messaage. After having activated my number, I filled $2.5 to my prepaid credit, with the preloaded credit and initial refill bonus, I have $4.2 in my prepaid credit. Before leaving the customer service center, I tried out the modem using wvdial, and... voila!!! I works!!!!

キタワァ*・゜゚・*:.。..。.:*・゜(n‘∀‘)η゚・*:.。. .。.:*・゜゚・* !!!!!

And... finally, I got myself connected. At first I was afraid about the network coverage from my room, but it turned out to be excellent, at least for browsing (I haven't tried downloading large files).

Here are some images:


not bad

Speed test result from my area

New mobi USB modem package



Wvdial in action

Final Words

Yeah, it's no problem if you don't have Winsh*t or MacOS on your box, you'll be alright. Just make sure that you have a great amount of curiosity and patient, you'll get anything work.