Tech Tips

by Staff
Create a Debian Repository for Your System

If you have a Debian-based system, once you've got everything installed, you can create a Debian repository from it and use that repository for installing additional similarly configured systems, or you can use it as a source for a re-install in the event that your system somehow becomes corrupted.

To do this, install the package dpkg-dev. You can install it with apt-get from the command line, or you can install it using a GUI package manager, such as Synaptic.

Now, create a directory—for example, my_repo. This will be the root of your repository. Under this, create a directory named binary. Next, copy all the .deb files from /var/cache/apt/archives/ into the binary directory. Then, go to the my_repo directory, and run the command:

$ dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gz

This creates your packages list. After that, save the whole my_repo directory onto another system. Then, change the /etc/apt/sources.list file, and add the path of the my_repo:

deb file:///home/boss/my_repo binary/

Now, reload the repository list and check your new repository.

—Kousik Maiti

Auto-Typing and Mouse Movements

Sometimes you may need to type the same thing repeatedly, whether it's filling out a form or typing a common word or phrase over and over again. There is a simple program for Linux called xte that allows you to control virtual key presses and mouse gestures that are sent to a program. xte is part of the xautomation package. It should be available through your package manager. For Debian-based systems, you can run:

$ sudo aptitude install xautomation

Once the package is downloaded and installed, you can use xte from the command line, like so:

$ xte 'sleep 5' 'str hello world'

This command waits five seconds and then types the string “hello world” into whatever application has focus. You not only can send strings, but you also can send key presses. So, let's say you want to send the key press for Enter, after you send the string “hello world”. Simply do the following:

$ xte 'sleep 5' 'str hello world' 'key Return'

There are a number of keys that can be sent using xte. Some modifier keys include Shift_L, Shift_R, Ctrl_L and Ctrl_R. As you can see, xte not only can send a Ctrl key press, but it also can distinguish between left and right Ctrl key presses. This is important, because some programs have different functions for the left and right Ctrl keys.

When typing the command for these key presses, keep in mind that the commands are case-sensitive. For instance, key Return will work, but key return will not. Use the xte --help command to get a full list of useful keys that you can send.

You can use xte for many useful things. Let's say you type your name, or maybe the name of your company, a lot throughout the day. You easily can create a script with xte that will send the string of information and then link that script to a set of shortcut keys for your desktop environment. So, instead of typing out “Johnson, Joseph and Jack's Law Office”, you simply can press Ctrl-Alt-N, and the script will type it for you.

I also use xte for was controlling Compiz on the touchscreen in my car. Without a mouse or keyboard, I was unable to use some of Compiz's useful features, such as scaling. So, after setting scaling to be controlled by moving the cursor to the top-right corner of the screen, I added an icon to the GNOME toolbar that ran a script that did the following:

$ xte 'sleep 1' 'mousemove 9999 0'

The first number (9999) is the X-axis value, and the second (0) is the Y-axis value. This command waits one second, which allows me to lift my finger from the touchscreen before the cursor moves, and then relocates the mouse cursor to the far right of the screen and up to the very top. Now, in combination with my Compiz settings, I can press the icon on my toolbar and get a nice view of all my open windows. I click the one I want, and I'm off and running. This makes touchscreen usage much more convenient and raises the cool factor a bit.

xte has many options I haven't touched on here (such as mouse clicks and holding a key or a mouse press for a given amount of time). I hope it has sparked an interest in you to give it a try and play with some. It just may be the tool you need to get a job done.

—Kristofer Occhipinti

Three Steps to Find Your Total Download Bandwidth Usage

I have been working on bandwidth-monitoring of late, and I find the following three steps handy to find my download byte count. These steps use iptables, which is available with almost all distributions. It most likely already will be installed on your system (it is the basic firewall in Linux).

Steps one and two set up the monitoring, and step three allows you to view your download byte count. The first two steps need to be done only once (at boot time, if you want this available all the time). You need to run all the steps as root.

Step 1: create a chain:

$ iptables -N input_accounting

This creates an iptables chain named input_accounting.

Step 2: add a rule:

$ iptables -I INPUT -j input_accounting

This causes all incoming packets to “pass through” your newly created chain.

Step 3: start checking your bandwidth:

$ iptables -L -v | \
		grep input_accounting | \
		grep anywhere | \
       	awk '{ printf("%s\n", $2) }'

This should output your download byte count—for example, “500K”.

—Tanmay Mande

Load Disqus comments