Intel's Ronler Acres Plant

Silicon Forest
If the type is too small, Ctrl+ is your friend

Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Saturday, February 6, 2021

Adjust Linux Mint Mouse Speed

I just noticed that portions of this post were dropped by Feedly, which I think is some kind of RSS feed thing, so if that's how this comes to you, you may want to go to the original post. Parts of this post are done using Courier font to differentiate my comments from actual Terminal I/O (input/output).

For this bit of tediousness, xinput is your friend.

Open a terminal window. Enter this command:
        xinput --help

This will produce a long list of arguments that can be used with xinput. This is the one you want:

        xinput list [--short || --long || --name-only || --id-only] [...]

xinput list will produce of a devices:
⎡ Virtual core pointer                 id=2 [master pointer (3)]
    ↳ Virtual core XTEST pointer      id=4 [slave pointer (2)]
    ↳ SONiX USB Keyboard              id=10 [slave pointer (2)]
    ↳ PixArt USB Optical Mouse        id=11 [slave pointer (2)]
⎣ Virtual core keyboard                id=3 [master keyboard (2)]
     ↳ Virtual core XTEST keyboard     id=5 [slave keyboard (3)]
     ↳ Power Button                    id=6 [slave keyboard (3)]
     ↳ Video Bus                       id=7 [slave keyboard (3)]
     ↳ Power Button                    id=8 [slave keyboard (3)]
     ↳ SONiX USB Keyboard              id=9 [slave keyboard (3)]

Note that the mouse id is 11. Now we can learn about the mouse with

    xinput list-props 11

It comes back with a list. Velocity Scaling is the one we want.

        Device Accel Velocity Scaling (259): 10.000000

Note the number associated with the property, in this case 259. Use this to change the scaling factor:

    xinput set-prop 11 259 1



This is probably not a good fix in that it will need to be reapplied each time I reboot, but it's good enough for now.

I got some clues from the Linux Mint Forums, but there was a good deal of blather there as well.

Sunday, December 20, 2020

Security / password problems

I've been running into password problems over the last few months. First, the Chrome browser forgot all my passwords. Then I got an email attempting to squeeze me for some money. I ignored it except it bothered me that he had my favorite password, the one I had been using for all those media sites that require a login. Lastly, Google required a new password.

I'm using the Linux Mint Operating System and I haven't had any trouble with viruses or security for years, so this was a little disturbing. Turns out the Vimeo downloader extension may have been the cause. Google automagically reached out and disabled it in my browser a couple of days ago.

Monday, February 17, 2020

Linux Time Zone Problems

Linux Mint Timezone Dialog Box
More pictures to go with my Linux Forum questions.



Stupid Linux


Cleaning out cupboards in preparation for moving, which might happen in a month or two or maybe not at all, the future is cloudy, I cannot see. Anyway, cleaning out cupboards I came across a small hard drive in a case with a USB connector, so I thought to try it out, see if it's any good. Seems to be working so I load a new version of Linux on it and go charging on.

Funny how little stuff I need off of the old hard drive. Copied my dominos program from the old drive to the new one. I can read from the original hard drive installed in this PC, but I can't write to it. Try to compile the program and it trips over assert.h. Okay, the default installation is weak, so I go mucking about and end up with broken packages that cannot be fixed. Fortunately, there is the Linux Mint Forum and someone will surely rescue me shortly.

I'm posting this because I didn't want to copy the text from the error message, so I thought I would just include a screen shot with my inquiry, but the image needs to be on the net somewhere, and for some reason Google Photos couldn't provide a link, but Blogger could, so here we are.

Tuesday, February 11, 2020

Curses

Unicode Logo
I have been working a little program to solve the domino puzzle Stu posted last week. Why push dominos around for minutes when I can spend hours writing a program to solve it in milliseconds? Yeah, well, we all have our faults.

So I've got the program pretty much working, but I thought it might be nice to display the results graphically. Yes, html is glorious, put I don't want to open that can of worms. If I could just find the codes for the old IBM PC box drawing characters, I could cobble something together that would be adequate.

So I went rooting around on the net, and because I am using Linux, whenever I asked for box drawing characters and Linux, I got ncurses, which stands for new curses, which is some kind or proto-windowing system for terminals. I go round and round with this for a while, but never get anywhere because none of the sample programs will compile because I don't have some unspecified library installed. I eventually realized that the C programming language, my text editor and Linux in general all work perfectly well with unicode characters and I don't have any need for ncurses at all.

I've probably been down this road before, but I'll be durned if I can remember where. In any case, I wrote a little program to turn unicode values into unicode character strings and uploaded it to github.

Stackexchange is useless. It is occupied by gnome-like creatures who know everything there is to know, but are incapable of answering a simple question.

Monday, February 12, 2018

Fast Forward

My computer display screen has been acting a little weird, so I consult with the cloud:


I've been hearing about 4K video for a while now. I ignored it when it first came out because, like any new technology,  it was expensive. (Just for a baseline, anything that costs more than a dollar and a half is expensive.) But now you can buy a 4K computer display at Costco for $300. That might be worthwhile, especially if this display is flaking out.

P.S. I tried copying the discussion from the forum, but Blogger has it's own rules about how to handle things and the copy-and-paste didn't work so well. So for my next trick I took a screen shot of the forum discussion, cropped it with Pix and inserted it here. I tried resizing it a couple of times by changing the height and width parameters in html, but I ended up with the original dimensions of the image. As the best compromise between being a readable size and fitting on the page. It looks like shit right now. It's all fuzzy like it was compressed and then expanded. Stupid Blogger, why can't you just render the image as it is? Maybe it will look better on the finished page, but I doubt it.

Wednesday, September 27, 2017

Me & Linux

I just spent an hour cleaning out old files on my Linux box.  Lately I had noticed that sometimes the web browser stalls while the hard disk is getting hammered. Looking in Files (the Linux file management program) I see that I have about 5 GB of space left. I have tried deleting some things, but it hasn't made a noticeable difference, I still had only about 5 GB of free space. I could have opened my Linux reference book and read up on the subject, but hey, we've got the internet, so I posted a question on the Linux Mint Forum and I quickly got several helpful responses, one of which included this bit of Linux weenie cryptography.
sudo du -chd1 / --exclude={proc,dev,sys,media,mnt,run,tmp,lost*,cdrom}
It's a command-line command, copy it (using normal browser controls)  and then paste it into a Terminal window (using special Terminal window controls) and I quickly have an overview of who's sucking up all the space. It's me, of course, and all the crap I have been dragging around with me every time I change computers. Changing directories (using the cd command) and repeated applications of
sudo du -chd1 .
(the dot means operate on the current directory) allows me to track down the biggest offender, which turned out to be about six levels down. Deleting a bunch of ancient crap makes me feel better, but it doesn't do anything for my bottom line, which still shows only 5 GB of disk space. (5 GB!?! Back in the day when I got started in this business we were lucky to have 10 MB.) Empty the trash, silly, and suddenly we have 30 GB of free space. That should be enough room to play with for a couple of months or so.

Now I'm looking at the forum and I realize my avatar is a blind snowman standing in front of a concrete wall. Not exactly putting my brand out there. We ought to do something about that, so I root around and find a copy of the image to upload, but the forum doesn't support uploading. They want a link to a photo that is already on the web. Well, I am the master of my internet browser, I should be able to deliver that, except I can't.

I try using the link to the avatar from this blog, but it goes nowhere. Stealing the link from the page source works, but the image is too big. I try uploading the photo to Google Drive, but it won't provide a link to the photo, but it will export it to Imgur, except it won't. So enough screwing around with these fancy web services that don't work, let's fall back to old reliable (sort of) Blogger, so that's how we come to have this post with the tiny little picture of me at the top.

Update 2 minutes later: using the link to the picture from this blog post worked!

Sunday, June 25, 2017

Paint It Black

My Linux Desktop
Linux pulled a fast one on me the other day, locked me out of my apps. It could be a bug, or it might be somebody's feature that I inadvertently activated with some random key combination. I started a discussion on the Linux Mint Forum to see if anyone knows what it could be. So far, nada.


Tuesday, July 21, 2009

ftp - File Transfer Protocol


A few weeks ago I ran into a situation where I needed to use ftp to upload a file to the internet. Poking around I came across one site that sounded promising but turned out to be worse than useless. I was going to tell them what I thought, but you have to sign up. Yeah, that's just what I want a membership with a really stupid web site. Dummkopfs.

Their suggestions only work on sites that have implemented the necessary features, which means almost none. For any normal site you will need an ftp client program.

A little more searching turned up gftp & filezilla, both ftp client programs for Linux.

gftp installed, but would not run. That was all the effort it got from me. If it doesn't work the first time, I'm not going to spend any time on it.

Used filezilla instead. It installed and ran fine. They have versions for Windows, Linux & Mac.

Friday, March 27, 2009

The Crack Model Applied to Mapping Software

I went to an OS GIS (Open Source Geographical Information Systems) meeting this week at Open Sourcery. This is a group of people that work with digital mapping systems. Most of them were from either various Government agencies or PSU (Portland State University). There are some well established proprietary software products on the market, and there are some open source tools available as well.

Maps get used for so many purposes with so many different data bases that you almost need a unique solution for any particular application.

There is one mapping software company that is offering a free two year license to any Oregon agency. Obviously the plan is to get as many agencies as possible hooked on their software so when the two years are up they will come crawling back, begging for their next fix and willing to pay whatever the vendor wants. This is not necessarily a bad thing. The vendor is going to have to deliver a useful product, there is competition out there and one of the competitors is offering free software, i.e. open source.

The real question is whether the program will do what the agencies are trying to do, or is it everything so specialized that doing a custom build is the only way to get what you want?

Thursday, March 26, 2009

Nvidia Twinview & Linux


I finally got around to installing the Nvidia driver that supports two screens. This is the proprietary Nvidia driver, not the open source driver. It wasn't too much trouble and it seems to work pretty well. Downloading and installing the driver went very smoothly. The hiccups came with the configuration.

Update: Chewearn's blog was very helpful.

My hardware:
  • ViewSonic VA902b LCD flatpanel display, 1280 x 1024 resolution.
  • Princeton VF912 19" CRT with resolution out the ying-yang (data sheet).
  • Nvidia 7600 GT dual head video card.
nvidia-settings is the configuration program. I did not find it in any of the system menus after I installed the driver, but the instructions I found on the web named it. Later on, I wanted to run it again and I couldn't remember the name nvidia-configure? nvidia-configuration? I had to go look it up again. I still don't know where it is, but it is in the search path somewhere, so I can invoke it from a terminal window.

Both of my screens are roughly the same size, so I wanted to set the resolution to be the same on both. The first resolution drop down box in nivdia-settings has a list of maybe a dozen settings, but it does not have 1280 x 1024. It has several that are smaller, and one that is bigger. Bugger. Some fooling around and I click on the resolution box for the other screen and it has got a list of a about a gazillion settings. Whoa! And one of them IS for 1280 by 1024. Okay, so we will switch the cables on the ports on the card. But now the LCD screen complains the signal is NOT IN RANGE. Bah. Now what? 1280 by 1024 IS the correct resolution. Is there something else we can change? The second part of the resolution line contains the vertical refresh frequency. I end up setting it to 75Hz and that seems to work.

The instructions I found warn not to Save to X Configuration File, it will bugger your system. It means running nvidia-settings after each re-boot, but at least it works. The instructions were written a few months ago, and things change, so I thought I would try it and see if it works. Especially after I rebooted and then ran nvidia-settings again. I click on apply and everything disappears. I have to quick-lean-down-and-swap-the-cables-before-the-five-second-time-limit-expires-and-everything-reverts-to-the-way-it-was. It takes three or four tries before I manage. Okay, we certainly don't want to have to deal with this every time we reboot so let's see if writing to the config file works or not.


The first time doesn't, but that really isn't surprising, I was not master-of-my-universe (sudo, or super user do). Invoking the program with the sudo prefix (sudo nvidia-settings) fixed that, and rebooting worked fine. So far. This is what the setup looks like in the dark. Aren't all the LED's pretty?

I have encountered some minor bugs, but basically things are working okay. The main reason I wanted this was for working with Eclipse (a software development tool) it wants to put up all these panes, and there just isn't enough room on one screen. The way Twinview works here is kind of interesting. If you click on the maximize button, the program window will fill one screen. So how do you get it to fill two screens? Do I have go back and make a major configuration change? No, simply unmaximize the window, and then stretch to fill both screens. Kind of backwards, but it works.

As far as bugs I have noticed two things:
  1. Title bars on windows sometimes disappear. Somethings they just go white, sometimes they vanish completely and the window title is appears in some kind mutated kaleidoscope font. When they go white, the window control buttons still work. The tool tips still pop up when you are over them.
  2. I was running Firefox yesterday and I opened a bunch of windows and the screen I was working on started fading to gray. I would click something and it would come back, but then it would go to gray immediately. Things went downhill from there.
One thing I have noticed that is kind of cute, is that when you close a window instead of just disappearing, it does this vanishing act, kind of like what you see on Mac's. Makes me realize I have not come anywhere close to making full use of this video card.

Update November 2016 replaced missing pictures.

Sunday, March 1, 2009

Fun With Numbers

I have been fooling around with a program to compute the Ackermann function. I say fooling because I haven't really put any serious analysis into it. I have just been trying different things to see what happens.

One thing I did was install the GMP library on my Linux box. I changed my program to use the functions provided by this library instead of just performing regular arithmetic. Being as the results of the Ackermann function can run into thousands of digits, I was going to need something. I thought about writing one myself, and that might have been fun, but let's try and focus, shall we?

I am beginning to think that a simple minded implementation of Ackermann is not going to work. I may be wrong, but I suspect that there might not be enough virtual memory on the planet to accommodate a simple minded solution.

Say the answer (to a particular evaluation) runs to 10,000 digits. Two to the 10th power (2^10) is 1024, or roughly one thousand, or three decimal digits. 10,000 digits is roughly 1000^3333, or 2^33330. A trillion is roughly 2^40. So say we can get by with 16 bytes (2^4) of stack space for each call. So if the depth of our recursion is proportional to the number of digits in the answer, then we will need 2^33334 bytes of stack. A terabyte is 2^40. 2^33334 / 2^40 = 2^33,294.

Notice that neither the number of bytes of stack per call nor the number of bytes in a terrabyte make any real impact on the original number.

Of course it may be that the amount of stack space required is NOT proportional to the size of the result, in which case it might be possible to arrive at a solution.

But then there is the time involved. Even at the fastest clock speed incrementing a number from zero till it has 10,000 digits is going to take a long time. Strikes me now that the amount of time required is going to be similar to the amount of space we computed above. In other words, we won't have an answer before our Sun burns out, or goes Nova.

So how do we compute the value of the Ackermann function? Someone was put together a simple mathematical expression that purports to compute the value of the Ackermann function. So one fairly simple test I could do would be to implement that expression and see it if delivers the same result as reported elsewhere.

But how do know if that is the correct answer? That is going to require analysis of the original definition to see it does in fact correspond to the expression in question. That is going to require thinking.

Of course the real question, is why am I even fooling with this? Same reason I do the Jumble (most) every morning: I need a little mental exercise everyday. Keeps me from getting bored. Also I am acquiring L33T Linux skills by mucking about with GMP and Eclipse.

Monday, February 16, 2009

Stack Size

Last week Stu put up a post that included a mention of Ackermann's function. It looked very simple, and being inclined to avoid doing any real work, I thought I would write up a little program to exercise it. The program was very simple, but the results were a little disappointing, if not unexpected. Stu warned that the results quickly exceed the bounds of the native 32-bit arithmetic of your typical Pentium processor.

My immediate problem with the program was not the arithmetic, but the stack. Ackermann's function is recursive, which means it calls itself, and as simple minded as it is, it has calls to itself nested within calls to itself. Kind of like wheels within wheels. So the problem is that it runs out of stack space and crashes which means it doesn't deliver any results at all.

I have been using Microsoft's (boo! hiss!) Visual C++ (Version 6.0 last copyright 1998, a very good product) for quite a while so I whipped up the first version of the program there, and when it ran out of stack space I was able to find the command to increase it (/stack:number).

But stack space is the least of the problems with this program. The other problem is the ridiculously large numbers it produces. So now we are operating in the realm of fantasy, and Windows, as wonderful as it is, is not going to cut it. So off to Linux we go. Besides, I had installed the Eclipse software development program on my Linux box, and I needed to learn how to use it. This looks like a prime opportunity.

After a bunch of fiddling around with Eclipse and my program, I finally get it to compile and run. All is well. Now, how do you set the stack size for this program? Help is no help at all. A bunch of Googling turns up ulimit, a program you can run from a terminal window to set a bunch of different memory allocation limits. So I set ulimit to some gloriously large number like a billion and let my program run overnight. It did nothing. It did not run out of stack space, which is something, but it also failed to complete the computation of A(4,0). Bah.

So I'm playing around with ulimit this morning and I learn a few things. After the first time you set the stack size, you can only reduce it. You can enlarge it only the first time you run ulimit. ulimit works in units of 1KB, so the default setting of 8192 is equivalent to 8 megabytes. Anything above 4 million or so (2 to the 21st power, which translates to 4 gigabytes, the most memory that can be handled by a 32-bit processor) causes the stack size to be unlimited. 7 or below will keep my program from running. The shell (or CLI (Command Line Interpreter) if you prefer) immediately reports back killed.

Friday, February 6, 2009

Portland Linux/Unix Group Meeting

Hal Polmeranz of Deer Run Associates in Eugene came up to give his presentation:

Intro to Digital Forensics
(aka Groveling Through File Systems)

This comes under the heading of what to do if your computer systems has been compromised. The typical concern is some unauthorized person gaining access to your computer system and wreaking havoc.

The fact that we are talking about it at all means that there are security holes in Linux systems. They may not be as plentiful or as well known as the ones in computer systems running Microsoft Windows, but they are there. On the other hand, he is only one in his shop of twenty odd people that works on Linux systems. All the others work on Windows systems.

While your interest no doubt lies with your computer system, where security becomes important is at the commercial internet web server farms, where there may be dozens or even hundreds of computer systems, all connected to the web, all containing data that needs to be protected from corruption and/or unauthorized access.

"Unauthorized access" can be done for any number of reasons. One of the most common is spammers trying to co-opt computers to send out more spam (unsolicited e-mail). Others may be industrial spies or just common criminals looking for useful information, disgruntled former employees looking for revenge, vandals looking to trash something, or just pranksters getting their kicks by getting past your security.

Hal started out with generalized blandishments about about not changing the state of the compromised system. Basically this means pulling the plug. The problem is that what is going on in RAM in the computer is happening much too fast for a person to follow. While you might be catch sight of some unauthorized process in the act, most attacks will write something to the disk. And anything you do while the computer is still running is going to cause data to be written to the disk, possibly overwriting evidence of tampering. Even an orderly shut-down will write some data to the disk. Pull the plug and then make a copy of disk using another machine. Do not boot from the disk from the compromised machine.

One trick that can make your life a little easier is if you have empty space on your disk that is larger than the whole compromised disk. You can copy an image of the entire disk into a file. You can then mount it as though it was a real disk. This saves you from having to buy and connect another disk to your system, though with the rapidly increasing size of disks it may a toss up as to which disk is going to be bigger, yours or the suspect target disk.

Once you have made a copy of the disk from the compromised system, then the real computer geek work begins. In case you haven't noticed, computer disks are big these days. You can buy a terabyte of storage for under a $100. So just looking around for some useful information is going to have the results of buying a lottery ticket: a waste of time. To that end there are some tools (computer programs) that can be used to locate files that have been tampered with. In order to use the tools, it helps to have some understanding about how the data is arranged, or in programmer's parlance, structured.

Computers store all data on disks as binary. A disk contains basically just a long string of ones and zeros. How you interpret that binary data determines whether you can retrieve any useful information. Binary data can be interpreted as words or numbers or code or, for our purposes, as pointers to other places on the disk. Yes, pointers are just numbers, but the are special numbers because they are key to making sense of all the rest of the data on the disk.

Most of Hal's presentation, and the most interesting part, was about the various tools and techniques used to figure out what had happened. What was changed? What was deleted? What was added? Any one of these things, if done at the right place could cause irreparable harm. This is why computer security has gotten to be such a big issue.

It was a pretty dry, technical discussion until a couple of hiccups triggered an avalanche of laughter. The hilarity threatened to snowball out of control, but somehow we got our selves under control. Geeks, I think, may in general be would a little too tight. Just a knick in our armor and we come unglued.

All this was like a trip down memory lane for me. Fifteen or twenty years ago I wrote a a couple of tools for recovering data from damaged disks. It wasn't a security issue then. Something had corrupted the data on a customer's disk, and I went in to try and recover it for them. Failure to make back up copies of their important data was the root cause of the problem, but it gave me an interesting technical challenge. In both cases (I think there were only two) I was able to retrieve some data, though in one case it left the customer with about a hundred unnamed files they were going to have to sort through to find their lost information.

The meeting was held at FAB 86-01 on the PSU campus. Out here in Hillsboro, a Fab is a monstrous factory where computer chips are fabricated. Downtown at PSU, FAB refers to the "Fourth Avenue Building". The meeting was actually next door in the "City Development Center" which has this sign in front:


Update January 2017 replaced missing image.

Monday, November 24, 2008

No sound Epox motherboard Ubuntu 8.10


I've been fooling around with my Linux box trying to get the sound working. As a practical matter it's basically a waste of time. I could go down to the local computer shop, buy a new sound board for $10, plug it in and it would probably work. But learning the in's and out's of Linux might be a useful skill, so I have taken to investigating the problem, and this means being assimilated into the Linux culture. If I keep it down to an hour or two a day, it is not too bad. I learn a little bit, I make a little progress, I get disgusted with the convoluted way this, that or the other was implemented. Then I stop for the day, and let the disgust dissipate, and the next day I am ready to try a little more. What I wouldn't give for a design document that explains how this all supposed to work. There probably is one somewhere in the thousands (3,715 to be exact) of files in the ASLA subsystem, but I'll be durned if I know where it is. Meanwhile I am sorting it out by stepping through the code for aplay with gdb (Gnu Debugger).

Most of the code looks like it is involved in setting things up, opening the file, figuring out what format it is, what device is going to get this data. Then at some point it flips a switch, something magic happens, and sound comes out of the speakers. Or, as in my case, not.

Tuesday, October 7, 2008

Windows is Wonderful Part 9487

I set up a Windows Hotmail account for all my Linux related stuff. When I got serious about fixing the problems with my Linux box, I visited a bunch of forums, and they all want you to register, and they all want an email address. No telling how much junk mail this is going to generate, so I set up a new email account to deal with them. I already had a three other email accounts, and hotmail is the only one I hadn't tried so I thought I'd give it a go. The oddness of using a Windows program to cope with Linux didn't even occur to me, or maybe it just appealed to my perverse sense of humor.


But now every time I go to check this account, and it tells me I need to upgrade my browser. I'm sorry, my browser has already been upgraded, but there is no way of telling it that, and there isn't even a check box to tell it not to show me this warning again. I suppose that's what I get for trying to use a Microsoft do-hickey on Linux.

Update December 2016 replaced missing image.

Linux Screen Resolution, Part 2

I finally returned to the screen resolution problem on my Linux box today. I was able to boost the resolution up to the max of 1600 x 1200, which is so good that this text I am writing in Google Blogger is almost too small to be legible. I did this by adding three lines to the "Screen" Section of /etc/X11/xorg.conf:
SubSection "Display"
Modes "1600x1200" "1280x1024" "1152x864" "1024x768" "800x600" "640x480"
EndSubSection
All is still not right however. CTRL-ALT-"Keyboard Minus Key" and CTRL-ALT-"Keyboard Plus Key" will cycle through these six available resolutions, but the menu bar at the top of the screen is only available on the first one (1600x1200). I should be able to get the resolution I want by editing this file and putting the resolution I want at the head of the list. We shall see.

System/Preferences/Screen Resolution has it's own set of problems. Clicking on the Resolution box gives you a much larger drop down list now, but it still has the big white space above the highest resolution. That's minor. What's bad in my case is that the list of resolutions is extensive, it includes many that are NOT in the list in xorg.conf. This is a problem because resolutions that are not in the list DO NOT WORK with my monitor. Selecting one of these other resolutions cause the monitor to simply shut down.

Update: CTRL-ALT-Plus-or-Minus do not work with highest resolution moved to the end of the list. You get a black screen with a small white screen icon in upper right corner of the screen. The size of the icon changes each time you change the resolution using the special key combinations, but you can never get back to your desktop, you are stuck in la-la land. Rebooting does fix the problem.

I cut my maximum resolution to 1152x864 and it seems be a good compromise between what I can see/use and what I would like. I dropped the two higher resolutions from the list and now the magic key combinations work, though the menu bar at the top does not shrink to fit.

P.S. I got the list of valid resolutions from the Princeton data sheet.

Friday, October 3, 2008

embedded video playback linux ubuntu firefox


Something is not quite right with my Linux system. I am running the current release of Ubuntu (Horrible Harry or whatever it's called, AKA Version 8.04), just updated this morning. I can play videos on the YouTube website (youtube.com) using Firefox, but when I embed a clip in my blog, it does not play well. I get the big triangle to start with. Click on that and I get an image and the control/status bar just below it. Click play (either small triangle) and ... things go South. Something seems to get jammed up. Response to the keyboard and mouse gets very slow. Occasionally the image will change, but it is not like it is playing. It just jumps from one scene to another.

Everything works fine on my Windows box, so this may be more of Linux problem than a blogger problem. I posted this on several forums, and I figured shoot, I may as well post it on my blog as well, just so y'all will know what kind of pain and suffering I endure for my art.

P.S. I don't have any sound on the Linux box yet, but I suspect that may be a completely different problem.

Wednesday, September 10, 2008

Command Line Redirection

When you are using a text box to enter commands in a computer, be it Linux or a DOS box on Windows, the command may send some output to the screen. If it is generating a lot of output that you want to be able to study at your leisure, it would be nice to collect all this information in a file.

The standard trick for doing this is to redirect the output to a file using the greater than sign, like this:

dir > dir.lst

The dir command will list all the files in your current directory. This command, with the redirect symbol, it will put a list of all those files in a file called "dir.lst".

While I was fooling with Linux yesterday, this trick did not work. I was a little shocked and a little disappointed, but I was able to get by and get my work done anyway. Afterwords, I was doing a little poking around, examining the debris left from my mad thrashing, and I discovered something slightly unsettling. A great number of commands are defined like environment variables. Take a look at what set produces. Less than half of what comes back is standard environment variable definitions. The rest of it is page upon page of procedures written in some arcane script language. No wonder redirection doesn't work.

Portable Graphics

The first few days of working with Linux are always the roughest. There are innumerable little twists and tricks that you need to just accomplish the simplest things. But once you gotten through this initial trial, things become much easier.

I am feeling generous right now because I just finished successfully porting my gear program from Windows to Linux and then back. The number of changes I had to make on the return to Windows are few enough (2) that I am confident that this version will compile and run unchanged on the Linux system.

Geez, what a struggle it was to get here though. First there was just getting the screen resolution up to something usable. Okay, I've gotten a little spoiled. I remember when 640 by 480 was perfectly adequate, now I'm running 1280 by 1024 on my Windows machine. It makes the 1024 by 768 on the Linux box look a little feeble, but I've managed to adjust.

So I mail the source files to myself and download the zip file from my gmail account using Firefox on Linux. That part actually works. Start work on a makefile, try compiling. The graphics include files are not here! Search the disk and still no luck. So now we venture into the swamp of Linux forums on the internet, trying to figure out what is going on. Eventually I run into something called Mesa, which seems like it might be what I am looking for. They have a pretty good explanation of what is required, so I download their three files and unzip them.

Type "make" in the terminal window and I get infinity errors. There are so many I cannot find the beginning even if I scroll back to the top of the very large terminal buffer. WTF? Back to the swamp. Finally stumble across some instructions for building "Micropolis", whatever that is, but they seem to be having similar problems. Seems if you want to build Mesa, there are about half a dozen other software packages you need to install. You don't need just one, or two, or three, you need all eight of them. I am not sure about number seven. I installed it out of order and it didn't help, but when I finally installed the last one, Mesa built without complaint.

OK, great. Now I should be good to go. Well, actually, my program compiles, which is really a good thing, but it won't link. Can't find the libraries. Can't even find the math libraries, the ones that contain things like sin and cos, you know, basic trig functions. Now that's pretty chickens**t. More slogging through the swamp and I find some very good instructions for gcc (the Linux compiler and linker and general all around beast of burden for programmers) which tells me how to specify libraries.

It also helps that I am able to puzzle out enough makefile/shell syntax to write a fairly concise makefile, something I used to be able to do in my sleep. All this gets rid of the unresolved references to the math functions, but I am not making any progress on the graphics functions. The error listing is now small enough that it does not overflow the terminal buffer, so I can go back to the beginning and study it at leisure. I always want to start with the first error because often times that is one that triggers the avalanche. So if you can fix the first one, all the other errors might disappear.

That is not the case this time. All I see if hundreds of unresolved references to graphics functions. I try changing libraries. Maybe I am not using the right one. I try changing library paths. I write test scripts to verify that what I am doing with these environment variables is what I intended. No help. I'm looking at the error listing again and I see this one line that is different from the rest, not very different, just a little different. Looking closer, I see it popping up in a couple of other places. It is totally cryptic, it means absolutely nothing to me, but shoot, let's see what Google can do with it.

Surprise, surprise, it leads me right back to the web site about the gcc compiler. Seems if you feed C++ files to gcc, it will compile them, but the object files it creates will be unlinkable. In other words, they are trash. If you want to compile C++ code, you should use g++ instead of gcc. Criminently, what a bunch of gooberness. There is hardly any C++ code in my program, so I chop it out and recompile and the funny errors go away. However, I am still stuck with the unresolved references to the graphics functions. It's late, I'm tired, I give up and go to bed.

This morning I get up and it's got me bugged, so I go back and try some variations on the graphics libraries, and presto! Compile and link success! I am still left with the question as to what the other libraries are for, especially the ones with the same names in different directories.

But hey, it compiled! Will it run? Sure it will! Give it a try, boom, error, fail, die. What's wrong now? More wallowing in the swamp, no luck here. Let's try the debugger. No luck. Maybe we need to compile a debug version. More consulting the gcc manual, change the compiler control, recompile, debug, step through the program, it can't open the configuration file! Bam! Hand to forehead, of course it can't, I was so concerned about getting to the run stage, that I neglected to copy the input data file.

This is one of these cases where a development crutch let me skip good programming practice. Under Visual C, if it can't find the file, the Visual C debugger will tell you. On Linux, it just hands you a big fat zero, and if you mistake that zero for a file handle and try to use it, boom, down you go in a heap. So we add another test to ensure that the system hasn't handed us a big fat zero instead of a file handle. Stupid system.

Put a copy of the input file where our program should be able to find it, compile and run, and zowie! There it is on the screen, bigger than Dallas! Little bitty gears going round and round and round. This is very cool.

Okay, but we've made a bunch of changes, minor, but changes nonetheless, so we need to go back to the Windows system and see if it will recompile and run over there. It doesn't right off, but all I have to do is add a conditional include of windows.h and everything is copacetic. The condition should fail on Linux, so it shouldn't look for windows.h and everything should be copacetic over there too. It better be.

P.S. Don't use angle brackets in your blog text. It makes things disappear.