Author Archives: Gen2ly

Sleep Button in KDE 4 Workaround

If you noticed that pushing the sleep button does nothing in KDE 4 (as of this writing <=4.3.3), this is because of a bug in KDEs’ power management tool Powerdevil. It appears that in most cases Powerdevil does not recognize the Xorg servers’ XF86Sleep key. To fix this, you may be able to rebind the sleep key in the KDE control panel.

Add a New Input Action

Open System Settings then Input Actions. Then add a new Global Shortcut:

Name it ‘Sleep’ or whatever you like. Add a Comment if you wish and in the Trigger tab select your hotkey. Try setting the sleep key first. For me, setting the hotkey to the sleep key didn’t work because I believe that Powerdevil already has it bound. There have been others though that look to have sucessfully done so.

Note: If someone knows of a way to decouple the Powerdevil sleep key please let me know.

I bound mine to Scroll Lock (hope I don’t need it anytime soon) then in the Action tab entere the dbus command to suspend to ram:

qdbus org.kde.kded /modules/powerdevil suspend 2

If this doesn’t work, try ‘suspend 1’. If you would like to suspend to disk:

qdbus org.kde.kded /modules/powerdevil suspend 4

One More KDE 4 Gmail Checker

Not so far back, I was attempting to cope without a mail notification program on my KDE 4 destkop and not doing so well about it. There are plenty mail notification applets available on Linux most are for Gnome though and they pulled in alot of dependencies (mail-notification , gnubiff, checkgmail-notify-osd). For KDE a couple plasmoids exist (gx-mail-notify, emailnotify). I like both of these, particularly gx-mail-notify (the later though I found to be buggy). I also thought about kbiff from KDE 3 but it doesn’t look like it’s going to be updated to KDE 4. I’d been using KCheckGmail but somehow, someway, it broke recently. Yeah, I tried replacing the plasmarcs and recreating KCheckGmails’ configuration file but got nothing. Besides re-building all my KDE configurations again (~/.kde4) (which I’m not going to do [but does work when I created a new user]) I was up the creek. Luckily though I stumbled upon KGmailNotifier when I was on KDE apps. Marcel has taken KGmailNotifier just recently and updated it to KDE 4. The first thing I noticed is that KGmailNotifier doesn’t use the KDE 4 notification system and instead uses it’s own built-in popup. The effect is nice and has a nice display though I found that sometimes it will miss a mouse click. Beside that is a nice application. Both KCheckGmail and KGmailNotifier offer about the same functionality so I could go either way. For now I’m happy that I got my mail notifications back. Thanks for your work marcel.

plasmabac – When plasma solidifys.

Plasma being a new technology for KDE it can still, at times, behave like a bad child. Alot of you may have noticed that plasma from time to time will have the tendency to cause the desktop to freeze or crash. This usually happens with widgets that have bugs in them or if there are errors in the plasma configuration files. Instead of losing all my plasma configurations anytime plasma goes rogue, I’ve made it a routine to back them up regularly. I decided to build a script that can backup the current plasma configs and then automate it to run once a week. The script will both backup and restore:

plasmabac b
plasmabac r

When you choose to restore, it will give you a list of saved plasma configs by date:

plasmabac r
 0) plasmarcs-2009-10-13.tar.gz
 1) plasmarcs-2009-10-18.tar.gz
 2) plasmarcs-2009-10-23.tar.gz
 3) plasmarcs-2009-10-24.tar.gz
 4) plasmarcs-2009-10-25.tar.gz
 5) plasmarcs-2009-10-29.tar.gz
 6) plasmarcs-2009-11-01.tar.gz
 7) plasmarcs-2009-11-02.tar.gz
Choose the plasma configuration to restore: 

To backup on a weekly basis, add it to the cron jobs:

  57  00  *   *   0       ~/.bin/root/backup/plasmabac b    # w - plsm cnfgs
# |   |   |   |   |   user
# |   |   |   |   weekday (0-6) (Sunday=0)
# |   |   |   month (1-12)
# |   |   day (0-31)
# |   hour (0-23)
# minute (0-59)

The script will automaticaly delete configurations older than two months to prevent overflow.

Enjoy :)

# plasmabac - backup and restore local plasma config


# Use filename as program name

# Text color variables
txtbld=$(tput bold)       # bold
txtund=$(tput sgr 0 1)    # underline
bldblu='\e[1;34m'         # blue
bldred='\e[1;31m'         # red
bldwht='\e[1;37m'         # white
txtrst='\e[0m'            # text reset

plasmarcs=($(find "$userdir"/.kde4/share/config -type f -name "plasma*"))
bkpplasmarcs=($(find "$backdir" -type f -name "plasma*" | sort))
date=$(date +%F)

# Display usage if full argument isn't given
if [[ -z "$@" ]]; then
  echo " $prog b|r - backup or restore plasma configurations"

# Check if the directory exists and user has access to it
if [[ -n $(ls "$backdir" 2>&1 | grep denied) ]]; then
  echo -e "$warn User doesn't have access to the backup directory"
  if [[ ! -d "$backdir" ]]; then
    mkdir "$backdir"
    echo -e "${bldblu}*${txtrst} KDE 4 plasma config backup directory doesn't exist.  Created."

# Delete backups older than two months
if [[ -n "$(find "$backdir" -mtime +60)" ]]; then
  find "$backdir" -mtime +60 -exec rm {} \;
  echo -e "$pass Configurations older than two months deleted"

case $1 in
  b | backup )  tar -czpf "$backdir"/plasmarcs-"$date".tar.gz ${plasmarcs[@]}
                echo -e "$pass Plasma configurations backed up. (${bldwht}$date${txtrst})"
  r | restore ) for((i=0;i<${#bkpplasmarcs[@]};i++)) ; do
                  echo -e " ${txtbld}${i}) ${bkpplasmarcs[$i]##*/}${txtrst}"
                echo -n "Choose the plasma configuration to restore: "
                read restore
                tar -xvf "$selection" -C /
                echo -e "$pass Restored plasma configs: ${txtbld}${bkpplasmarcs[$restore]##*/}${txtrst}"

Mplayer as default DVD player in KDE 4

I got a thing for MPlayer. There’s a good number of video players in Linux but the simplicity of MPlayer has always made it what I like to use. I like to use MPlayer without the GUI because once I learned the keybindings it makes for fast and bare-bones video player (to learn a little more about setting up MPlayer settings, look at this page). To be able have MPlayer as your default video player in KDE 4 you’ll have to do change mime associations and add MPlayer to the ‘Open with’ dialog.

Changing mime Associations

If you install MPlayer with a GUI, you can skip this step because it should install an icon and .desktop file (file for displaying in the Application menu and listing associated file types). If you install MPlayer without a GUI, likely it will not have one. Here’s a ‘mplayer.desktop’ file you can use:

[Desktop Entry]
GenericName=Multimedia player
Comment=Multimedia player
Comment[es]=Reproductor multimedia
Comment[fr]=Lecteur multimédia
Comment[it]=Lettore multimediale
Exec=mplayer %F

Place this file in the application menu folder:

mv mplayer.desktop ~/.local/share/applications/

And the icon that goes with it:

mplayer icon

mv mplayer.svg ~/.local/share/pixmaps

Open ‘System Settings’ (or whatever your distribution calls it), click on the Advanced tab and choose File Associations. Then select video in ‘Known types’. Go through videos you’d like MPlayer to open as default and place MPlayer at the top of the list then ‘Apply’. Note, you may have to wait a minute after doing the previous action before the mime types get registered. Now videos that you have saved on you hard drive can be clicked and loaded with MPlayer.

Mplayer in ‘Open with’ Dialog

Adding to Device Actions in System Settings

It may be faster and quicker to copy and paste the configuration file I post in the next step. I put this method up is case you want to learn how to add and configure special device actions.

Open ‘System Settings’ and go to the Advanced tab and click on Device Actions. ‘Add’ a new action named ‘MPlayer’. Add a new action like: ‘mplayer dvdnav://’. Most distributions compile MPlayer with DVD navigation now so this should work. Remove ‘The device must be of the type Storage Volume’ and ‘The devices property Storage.Volume.ignored must equal false’ properties. Select ‘All of the contained conditions must match’ then click ‘Add’.

  Requirement type: Contains Other Requirements
  Requirement type: Is A Requirement

Select ‘All of the contained conditions must match’ then ‘Add’:

  Requirement type: Is A Requirement
  Restriction type: Compare Value To
  Device type:      Storage Volume
  Value name:       Ignored
  Equals:           false

Add another to ‘All of the contained conditions must match’ and add this to recognize you DVD disk:

  Requirement type: Is A Requirement
  Restriction type: Compare Value To
  Device type:      Optical Disk
  Value name:       Avaliable Content
  Equals:           'Data|VideoDvd'

Save the configuration and you should see the ‘Open with’ dialog display MPlayer. For me this didn’t though and I ended up creating the configuration manually and only then did it show up after I rebooted. Rebooting should be necessary though and likely this step would have worked if I had just logged out and back in again. I had been playing with the configuration a bit before I learned how to do this and likely this is a bug in system settings. If this doesn’t work for you look at the alternative below.

Using a Pre-made Configuration

Use this pre-built configuration if you don’t want to do the above and put it in the right directory to have MPlayer appear in the ‘Open with’ dialog:

[Desktop Entry]
X-KDE-Solid-Predicate=[[ StorageVolume.ignored == false AND OpticalDisc.availableContent == 'Data|VideoDvd' ] OR [ StorageVolume.ignored == false AND OpticalDisc.availableContent == 'Data|VideoDvd' ]]

[Desktop Action open]
Name=Open with Video Player (Mplayer)
Exec=mplayer dvdnav://

Now move it to the right directory:

cp Mplayer.desktop ~/.kde4/share/apps/solid/actions/Mplayer.desktop

Again, you may have to login/logout before it becomes available (reboot worked for me but shouldn’t be necessary).

And you should be good. Enjoy MPlayer!

Command Line Calculator

I can usually type faster in the terminal than doing mouse click on a gui calculator, so I created this scipt to be able to do it quickly from the terminal. There are alot of command line calculators out there so use the one you are comfortable with but I like using bc because of the syntax. For example, you can type:

calc "6/(3*10)"

or something more complex:

calc "8^2*(10/2+(13.2032565*2030)/.349548)" 100

100 is optional, it will specify how many decimals you want to carry it out to (the default is 4).

Chromium test (two days without Firefox)

With Firefox becoming fully-fledged, I wasn’t on the look-out to try another browser. Firefox is a well-done application for all it has to do. I can’t say I’m a complete friend of Firefox as the two huge security exploits in the last year will always keep me a bit leary. IMHO, something so predominantly geared on the internet can’t have these types of ommisions. But like good friends we learn to forgive and move on, and Firefox seems to have patched our ways.

When people began doing the “OMG Chrome” thing, I held short, but not because Google has never betrayed my trust (as for as my knowledge goes). For such a influential and in-position company, this begets me a tremendous respect. As one former execuative of AIG said though, “We just got too big.” And it’s true, one bad grape taints the wine. Perhaps I’m just too paranoid, but I didn’t want to touch the thing until I knew that hax0rhig didn’t come tromping into my living room. Curiousity, however, creeped in short of my expectations and I have been taken quick glimpses of Chromium the last two months. And, in this time, Chromium has made some some good gains.

It’s a bit too early to make comparisons, Chromium may not even be considered beta yet by the developers. But lately a lot of pieces have come together to make Chromium closer to becoming an everyday browser. For example, it’s gotten proper font rendering, all the options work now, and (as far as I tested) it no longer hangs. I was interesting in seeing if Chromium could be used two days as my regular browser.

The first thing I’ll say (like everybody else) is that it is fast. Now having a 64bit Firefox with tracemonkey I can see what they mean when they say how much of an improvement faster javascript rendering makes. I did a sunspider test on the new Firefox and got 1600 score. Running the same test with Chromium got me a 1200 score. This may look like a pretty big difference but in reality I couldn’t really tell. On espn, gmail, wordpress dashboard, load times were about the same. Possibly because they are both really fast, and possibly Firefox’s Gecko rendering engine is a little faster with HTML than Webkit is. Not sure.

One of most apparent difficulties I had with Chromium was that it has no setting for minimum font size. I found alot of sites that still like to use pixel size font settings (oh, Arial 8, we love you), so that at times I’d get very large fonts while other fonts had me rocking forward to be able to read them. Not sure this will be fixed anytime soon either as (if I remember right) the news Windows version didn’t have this feature either. Though some fonts may have been small, overall they were a more clear to read. Firefox has some built-in font rendering which isn’t bad but somehow it conflicts with my fontconfig settings and the fonts look a little bit worse than they do in other applications.

Chromium also does good on screen real-estate. The address bar that can also do searchs is a great idea in keeping things simple. I found it’s history search to be not as good as Firefox’s at finding the most used addresses but possibly this is because it imported Firefox’s and didn’t have the statistics about how often they were used.

I think Google is going to have to look at layout though. Chrom(e|ium) uses a new tab to get easily to a new page if you don’t want to use the address bar (or don’t know the address). In the new tab are nice thumbnails of commonly used sites and a bookmark bar on top. But I often found myself wanting to get to a bookmark from an already opened page which required a couple extra steps. I’d also like to see the title bar come back. Currently the title only shows on the tab and a good portion of it can’t be read.

Firefox does better with it’s find search. Why Google didn’t implement the ‘/’ I haven’t figured out yet. Firefox’s extensions though may make it the most popular browser out there. I don’t use many of them myself (NoScript, theme, Dictionary) but realize they might be the main reason Firefox is getting more popular. Besides that though, I’d say these two browsers are about equivicable at least in functionality. I didn’t get to test every site I commonly visit but on a couple sites Chromium does shows that it doesn’t have quite as good of flawed HTML/CSS fixing as Firefox does. But for the most part browsing was comfortable and felt like it did in Firefox. I don’t plan on leaving Firefox (there’s really no reason to), but with as far as Chrome has come so far, it’s be interesting to see where Chrom(e|ium) is in a year or two.

Kwrite Setup

HeaderI love Kwrite. Basically when I do text things, I use vim for creation and Kwrite for editing. When it comes to moving large blocks of text and having to scroll quickly through a text file, a gui text editor is needed. Kwrite does good with syntax-highlighting and enables me to easily work on more than one text file at once. Although Kwrite is good by default, it takes a little setting up to get it to behave as expected. Here’s how I setup Kwrite.

Open up the configuration: Settings > Configure Editor


Turn on ‘Dynamic Word Wrap’. This allows words to be wrapped but doesn’t create a new line. This way you avoid having to scroll left and right to get to text.


Disable all borders. Line number isn’t really needed if you use the status bar (enabled by default), icon border I never really found a use for, and folding is nice but since Kwrite doesn’t remember this setting and going through file and collapsing everything, everytime, is more trouble than it’s worth.

Fonts and Colors

Kate’s built in color schema’s don’t have alot of options. I found someone who brought KDE 3.5 Kate’s color schema to Kwrite (I believe Kwrite is a trimmed down version of Kate). I wish I had the link, but I don’t so I’ll put it up here.

Additional Kwrite Color Schemas

You’ll need to put the files in ‘~/.kde4/share/config’ and change ownership of them. I’m not sure if the katepartscriptrc is needed but it’s not going to hurt to add it. Be sure to back up the originals first though. You can change the schema with the ‘Default schema for Kwrite’ dropbox.



For tabulators think about doing ‘Insert spaces instead of tabulators’. In some documents you’ll find people use a mix of space for tabs and tabs themselves which can make for some odd formatting depending if tab spacing is different. I also like to ‘Highlight tabulators’. For ‘Tab width’ I found that ‘2 characters’ works good for being able to scroll text easily and still have easily discerable indentations.

Static Word Wrap

Static word wrap I leave off. Static word wrap forces line breaks when you reach the end of the line. This is good if you are say writing a man page, but not so good if you are building a script.


In Misc I like to ‘Highlight trailing spaces’. Sometimes I’ll leave an empty space at the end of the line and have to edit something else. When I get back, it’s a nice reminder that I don’t have to enter a space again.

Intentation Tab

Indentation Actions

Having ‘Backspace key in leading blank space unindents’ checked is a good idea if you use spaces for tabs.

Auto Completion Tab

I’m not sure even how auto-completion in Kwrite even works. Supposedly you are able to Ctrl-Space when you see a popup and the word will be printed. It’s never worked for me though and I find the popups semi-distracting so I disable ‘Auto completion enabled’.


Automatic Cleanups on Load/Save

Though hardly necessary, it does make a nice clean document when you select ‘Remove trailing spaces’.

Advanced Tab – Backup on Save

Kwrite does the same thing as default Vim does and leaves a nice clutter of backup files all over your filesystem. Though it is nice enough to have a backup, I’m usually good enough to remember to backup important text files before I edit them. Uncheck ‘Local files’ to avoid a nice trail [A-Za-z0-9]~ files everywhere.

For the truly paranoid

HeaderI’ve been reinstalling my system as of late (been way too along a comin’) and I realized that I hadn’t set up a firewall yet. This, in turn, had me think how many ports were open. I was up too late and probably had too many cokes by then. I had given myself a dead simple root password so that I could finish the install and began getting that tightening, turning, wretching in the belly feeling. I couldn’t help thinking that, “This could be the time that some random joe comes along and finds a nice open gate”. Doesn’t make much sense now, but decided then to build a script that toggles a 20 character random password to relieved my paranoia. Here it is for anyone who can find use of it. Oh, and I did get my install done.

# randompass - toggle between random and known passwords for users

# User passwords to protect
users=(root todd akau)

# Program name from it's filename

# Text color variables
txtund=$(tput sgr 0 1)          # Underline
txtbld=$(tput bold)             # Bold
bldred=${txtbld}$(tput setaf 1) #  red
bldblu=${txtbld}$(tput setaf 4) #  blue
bldwht=${txtbld}$(tput setaf 7) #  white
txtrst=$(tput sgr0)             # Reset
info=${bldwht}*${txtrst}        #

# Check if users exist, if they don't remove from the users array
list="${users[@]/%/|}"    # Puts array to list, add pipe after each user
users=($(grep -Eo "^(${list// })\>" /etc/shadow)) # strip spaces, end of word

# Password generation
passgen=$(< /dev/urandom tr -dc A-Za-z0-9/.$ | head -c20 | xargs | cat)

# Variables for current passwords
for user in ${users[@]}; do
  eval "curpw$user=\$(grep \$user /etc/shadow | awk -F : '{print \$2}')"

# Save original passwords (first run)
for save in ${users[@]}; do
  if [ ! -f /root/pass$save ]; then
    grep $save /etc/shadow | awk -F : '{ print $2 }' > /root/pass$save
    echo "$pass Saved ${txtund}$save${txtrst} password"

case $1 in
  h ) echo " $prog <*u>- toggle random and known passwords. u - update known"
  u ) echo "$warn Be sure no random passwords are set before updating passwords!"
      echo -n "Update known passwords file(s)? "
      read update
      if [[ $update == [Yy] ]]; then
        for known in ${users[@]}; do
          grep $known /etc/shadow | awk -F : '{ print $2 }' > /root/pass$known
          echo "$pass Updated ${txtund}$known${txtrst} password"
        echo " Passwords not updated"
  * ) if [[ "$curpwroot" == "$(cat /root/passroot)" ]]; then
        for u in ${users[@]}; do
          usermod -p $passgen $u
          echo "$pass Generated password for ${txtund}$u${txtrst}."
        for u in ${users[@]}; do
          usermod -p $(cat /root/pass$u) $u
          echo "$pass Restored password for ${txtund}$u${txtrst}."

Knowledgeable Urban Terror setup

Update: My configuration might be busted. I have not played the new 4.2 elease. I gave up when the servers become too crowded.

This is a pretty fun game. Once I got to playing it a bit, I discovered I could help out my play ability by using my own keys.

Keeping ones fingers from crossing

Though the default layout of the Urban Terror key bindings is good, people who want more ergonomic usage will want to tailor their a configuration. In a game were quick decisions are relyed on, keeping the eyes on the screen and the hands expectant is tantamount.

The trick is to keep commonly used keys grouped together. The most important keys should be kept closest to the left fingers. The example configuration I provide has the key bindings grouped to commonly used utilities and should work for about any game type. However… since I find that I play capture the lag most the time the automated chat are for CTF (these “radio” commands are easy to trade in the configuration below).

The configuration… thanks

I’ve tested the most often used values and put them in it below. To be more direct I decided to be and instead of defining all the values, here, I put the file below as remarks.

The location of the configuration is the directory ~/.q3a/q3ut4/. A file here named autoexec.cfg will cause the values within to be adopted within the game.

Edits are best tested and can be easily done so in the games terminal. The terminal can be gotten to by pressing the backtick ```. For me, I begin by entering the resolution mode to turn off fullscreen. This allows me to easily type the configuration edits in the text editor while testing:

    r_mode 4
    r_fullscreen 0

Edits in the terminal are temporary — the configuration file autoexec.cfg will remain as it is. If a value in the configuration value is edited, the configuration can be reloaded by doing:

    exec autoexec.cfg

(Errors in the autoexec.cfg or any configuration file, will be displayed after typing this.)

My configuration listing below should have a quick… go-over; likely edits will be r_custom, cg_selectedPlayerName, mouse, sensitivity description, and quite likely two others.

// Urban Terror configuration
//, * marks default value

// # Hardware # //

// Graphic card
seta cg_drawFPS       "1"    // FPS (frames per second) display (0 off, *1 on)
seta r_colorbits      "0"    // color depth (0 desktop default, 16, 32*)
seta r_texturebits    "0"    // texture colors (0 desktop default, 16, 32*)
seta r_texturemode    "GL_LINEAR_MIPMAP_LINEAR" // *NEAREST bilin LINEAR triln)
seta com_maxfps       "125"  // max frames/second, 125 best
seta cg_sfxParticle   "1"    // particle effects (hit effects) (*0 off, 1 on)

// Monitor
seta r_fullscreen     "1"    // fullscreen mode (*0 off, 1 on)
seta r_mode           "-1"   // preset reso :
seta r_customwidth    "1920" // resolution custom width
seta r_customheight   "1080" // resolution custom height
seta r_displayrefresh "0"    // Refresh rate (0 desktop default, 60, 70...)
seta r_swapinterval   "0"    // vertical sync (0 off, turn on getting tearing)

// Gamma/Brightness
seta r_brightness     "1"    // (*1)
seta r_gamma          "1"    // (*1)

// Sound
seta s_driver         "alsa" // sound driver (linux: alsa, oss)

// Network -
seta cg_lagometer     "0"    // lag-o-meter display (0 off, *1 on)
seta cl_maxpackets    "42"   // packets sent per frame (*30-42) 42 is usually >
seta rate             "25000" // transfer dl threshold (25000 broadband, *3000)

// Mouse
seta sensitivity      "8"    // mouse speed (*5)
set m_filter          "1"    // smooth mouse by averaging input (*0 off, 1 on)

// # Player # //
seta cg_selectedPlayerName "Gen2ly"
seta raceblue         "2"    // player skin (1-4)
seta racered          "2"
seta cg_sfxTeamBands  "1"    // team bands (0 off, 1* on)
seta cg_rgb           "1 0.5 1" // player marker color (R G B Alpha)

// # General Settings # //
set cg_gunsize        "1"    // gunsize (*0 large, 1 small)
set cg_hitsound       "1"    // sound when hitting opponent (*0 off, 1 on)
// Tac goggle color (*0 gren,1 red,2 blu,3 yellw,4 cyan,5 purpl,6 pink,7 orange)
cg_nvg                "3"

// # HUD settings # //
seta cg_draw2d        "1"    // HUD on/off (1*)
seta cg_mapalpha      "0.5"  // map transparency (*0.7)
seta cg_maparrowscale "2"    // map player arrow size (*3.0)
seta cg_mappos        "1"    //map posit. (0 off, *1top-left, 2-9 counter-clock)
seta cg_mapsize       "150"  // map size (*150)
seta cg_hudweaponinfo "1"    // Weapon information (0 rounds/clips/mode,
                             // 1 - 0 + weapon, *2 - 1 + icon)
seta cg_drawcrosshair "4"    // crosshair type (1-11)
seta cg_crosshairsize "20"   // crosshair size (*5)
seta cg_crosshairrgb       "0 1 0 0.7" // crosshair color (RGB Alpha[must be 1])
seta cg_crosshairnamestype "3"        // crosshair name types (0-3*)
seta cg_crosshairnamessize "0.2"      // crosshair player name size
seta cg_crosshairfriendRGB "1 .5 0 1" // crosshair color teammates (RGB Alpha)
seta cg_scopefriendrgb     "1 .5 0 1" // crosshair color team scoped (RGBA)
set cg_chatTime            "8000"     // chat msgs display time (milliseconds)
seta cg_drawteamoverlayscores "3"     // team box (0 off, *1 both teams,
                                      // 2 1 + nme alive, 3 1 + all alive)
seta cg_showBulletHits "0"  // hit nfo by nme (0 off, 1 where/whom, *2 1+damage)

// # Keybindings # //
// - available keys

// Menus
bind b        "ui_selectgear" // gear menu
bind n        "ui_selectteam" // team menu
bind SHIFT    "ut_radio"      // radio menu
bind TAB      "+scores"       // scoreboard

// Movement
bind e        "+forward"      // move forward
bind d        "+back"         // move backward
bind s        "+moveleft"     // move left
bind f        "+moveright"    // move right
bind CAPSLOCK "+moveup"       // jump
bind r        "+button8"      // sprint

// Crouch Toggle
set sit       "+movedown; wait 15; set crouch vstr stand"
set stand     "-movedown; wait 15; set crouch vstr sit"
set crouch    "vstr stand" //set default
bind a        "vstr crouch"

// Weapons/Items
bind MOUSE1     "+attack"                  // fire
bind MOUSE2     "+button6"                 // bandage
bind MOUSE3     "+button7"                 // activate - open/close door,defuse
bind MWHEELDOWN "ut_zoomout"               // zoom out
bind MWHEELUP   "ut_zoomin"                // zoom in
bind t          "+button5"                 // reload
bind c          "+button3"                 // weapon mode (automatic, burst...)
bind g          "ut_weaptoggle primary"    // primary weapon
bind w          "ut_weaptoggle secondary"  // secondary weapon
bind v          "weapon 12; weapon 11"     // smoke grenade before hand grenade
bind q          "ut_weaptoggle sidearm"    // sidearm
bind x          "ut_weaptoggle knife"      // knife
bind z          "ut_weapdrop"              // drop weapon
bind 1          "ut_itemnext"              // next item
bind 2          "ut_itemdrop"              // drop item
bind 3          "ut_itemuse"               // use item

// fine grain sniper toggle (lessens mouse sensitivity)
set zoomtoggle1 "cg_zoomfov 15; sensitivity 10; set nextzoomtoggle vstr zoomtoggle2; ut_echo sniper view"
set zoomtoggle2 "cg_zoomfov 22.5; sensitivity 13; set nextzoomtoggle vstr zoomtoggle1; ut_echo regular view"
set nextzoomtoggle "vstr zoomtoggle1"
bind h "vstr nextzoomtoggle"

// Chat
bind y "messagemode"  // chat global
bind u "messagemode2" // chat team
bind i "messagemode3" // chat target (person behind crosshairs)
bind o "ut_radio"     // radio menu

// radio keys

bind F1 ut_radio 2 1            // Move in.
bind F2 ut_radio 3 9            // Holding here.
bind F3 ut_radio 3 3 [$health]  // I need a medic!
bind F4 ut_radio 4 3            // Base status?
bind F5 ut_radio 7 2            // I'm going for the flag.
bind F6 ut_radio 2 6            // Requesting backup.
bind F7 ut_radio 2 5            // Cover me.
bind F8 ut_radio 5 5            // Incoming!
bind F9 ut_radio 7 6            // Flag exiting left.
bind F10 ut_radio 7 8           // Flag exiting front.
bind F11 ut_radio 7 7           // Flag exiting right.
bind F12 ut_radio 1 5           // Base is secure.

bind 4 ut_radio 1 2             // Negative.
bind 5 ut_radio 1 1             // Affirmative.
bind 6 ut_radio 9 1             // Good job team.
bind 7 ut_radio 4 8             // Who's ya daddy?
bind 8 ut_radio 9 9             // Thanks.
bind 9 ut_radio 6 6 Hi          // Hi (High)
bind 0 ut_radio 6 7 Hello       // lo (Hello)

// System controls
bind - "vote no"                                  // vote no
bind = "vote yes"                                 // vote yes
bind HOME "screenshot; ut_echo screenshot taken"  // take screenshot
bind END "toggle cg_drawFPS"                      // fps display toggle
bind INS "toggle cg_lagometer"                    // lag-o-meter toggle

seta record_demo        "vstr record_demo_start"  // record toggle
seta record_demo_start  "set record_demo vstr record_demo_stop; stoprecord; recorddemo; wait 15; ut_echo recording started"
seta record_demo_stop   "set record_demo vstr record_demo_start; stoprecord; wait 15; ut_echo recording stopped"
bind PGUP "vstr record_demo"

HTML Entities from the Command Line

While doing HTML work I tend to do my work with text editors. For this, I use Arachnophilia a Java HTML editor with easy, editable, customizable tags (Review here).

Arachnophilia has support to convert characters to HTML entities but isn’t easy to get to (HTML > More Functions > Char to Entity. There are various web sites that do but if willing to use the terminal they can be quickly gotten there as well. Thanks to script by Darren this can be done easily. It requires script Perls’ HTML::Entities module to do so (for help installing Perl modules look at this page). You’ll probably need redirect the script to point to the Perl program proper:

whereis perl

More than likely its in /usr/bin/perl. After fixing that run the script. This will put you in a sub-shell that you can copy and paste characters to be encoded:

You can also convert a whole file. This will print to standard output (terminal text):

htmlentities filename

Or convert a file by doing:

htmlentities  < file > convertedfile

movietime – Stop Powersaving to Watch a Movie

Getting down to watching you favorite movie on your computer? Start the movie, sit down, grab your snack and ten or so minutes later the screen goes blank. This happens in Linux because the desktop has built-in defaults for display power management (DPMS) and screensaving. Timeout settings can vary from distribution to distribution but they all got them. Here’s a basic script that can toggle DPMS and screensaving on and off.

Xorg Server Settings

You can set the values of blank, standby, suspend, and off in the the xorg server configuration file. The defaults are: 15, 20, 30, and 40 minutes. Personally I like to set these to better match how I use my computer:

Section "Monitor"
  Identifier  "Monitor0"
  Option      "DPMS"    "true"  # display power management on (true/false)

Section "ServerFlags"
  Option "BlankTime"    "13"    # LED still on, no + (0 disables)
  Option "StandbyTime"  "15"    # turns off LED
  Option "SuspendTime"  "0"     # turns off LED, and most power
  Option "OffTime"      "50"    # turns off all power

BlankTime is just a cheap screensaver and only real use for me is to tell me that I forgot to disable dpms while watching a movie. Doing this saves me a few seconds that StandbyTime requires to turn on the display again. SuspendTime and StandbyTime are nearly the same thing so I don’t bother setting SuspendTime.


Here’s movietime. Movietime should work with just about any type of desktop environment (at least any system with dbus installed which really all of them do). If you aren’t familiar with having your own scripts and how to run them, take a look at this page).

# movietime - disables power savings to watch movies.

# Movietime options
#  Resume time - resume normal display pm and suspend after set time.
# 0 = disabled, time in minutes
if [ $resumetime = 0 ]; then 
  resumetime=1440 # Re-enable resume after a full day

# Check that values for 'resumetime' are numbers
if [ $(echo $resumetime | sed 's/^[-+0-9][0-9]*//' | wc -c) != 1 ]; then
  echo "$warn variable 'resumetime' is not a number.  Exiting."

# Name of suspend script

# Program name from it's filename.

# Text color variables
txtund=$(tput sgr 0 1)          # Underline
txtbld=$(tput bold)             # Bold
bldblu=${txtbld}$(tput setaf 4) #  blue
bldwht=${txtbld}$(tput setaf 7) #  white
bldred=${txtbld}$(tput setaf 1) #  red
txtrst=$(tput sgr0)             # Reset
info=${bldwht}*${txtrst}        # Feedback

# Check that Xorg server is running
if [[ -z $(ps aux | grep /usr/bin/X) ]]; then
  echo "$warn The Xorg server is not running."

# Check if user is regular user
if [ $(whoami) == "root" ]; then
  echo "$warn You are the root user, must be a regular user."

# Current DPMS times (in minutes)
dispdpms=$(xset -q | grep "DPMS is" | awk '{ printf $3 }') # Enab. or Disb.
dispstand=$(xset -q | grep "^  Standby: " | awk '{ printf $2/60 }')
dispsusp=$(xset -q | grep "^  Standby: " | awk '{ printf $4/60 }')
dispoff=$(xset -q | grep "^  Standby: " | awk '{ printf $6/60 }')
dispblank=$(xset -q | grep "^  timeout:  " | awk '{ printf $2/60 }')

# Resume time in hours
resumetimehr=$(echo "scale=1;${resumetime}/60" | bc)

# Display help
case $1 in
  -h | --help | h | help )
    # Help message.
    echo "  $prog disables screen blanking and screensaver to allow viewing a video.  Running the program again will enable them.  If the 'resumetime' variable is set after that time $prog will resume normal powersaving values." | fmt -c -w 76

    # Display current values of power management and movietime.
    suspinhtest=$(ps aux | grep -v grep | grep $suspinhscript)
    suspinhval=$([ -n "$suspinhtest" ] && echo "Disabled" || echo "Desktop settings")
    # DPMS disabled information
    echo "   ${txtbld}Current settings ${txtrst}(in minutes, 0 = disabled):"
    if [[ "$dispdpms" == "Disabled" ]]; then
      echo "   DPMS:         $dispdpms"
      echo "   Suspend:      $suspinhval"

    # DPMS enabled information
    if [[ "$dispdpms" == "Enabled" ]]; then
      echo "   DPMS:         $dispdpms"
      echo "   DPMS times:   Blank: ${dispblank}; Standby: ${dispstand}; Suspend: ${dispsusp}; Offtime: ${dispoff}"
      echo "   Suspend:      $suspinhval"
    echo "   ${txtbld}$prog settings${txtrst}:"
    echo "   Resume after: $resumetimehr hours"
  [a-g,i-z,A-G,I-Z,0-9,-]* )
    echo " Use '-h' for help"

# Suspend inhibit script (must be run as seperate process)
suspinhibit () {
    echo '#!/bin/bash
    for time in $(seq 1 '$resumetime'); do
    # Simulate user activity every minute
    dbus-send --print-reply --type=method_call --dest=org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.SimulateUserActivity
    sleep 60

# Toggle powersaving
if [[ "$dispdpms" == "Enabled" ]] && [ -z "$suspinhtest" ]; then
  # Disable blanking, screen power saving
  xset s off; xset -dpms
  # Create script in tmp
  suspinhibit > "$suspinhscript"
  # Make script executable
  chmod u+x "$suspinhscript"
  # Run script
  nohup "$suspinhscript" &> /dev/null &
  echo "$pass $prog started, powersaving disabled."
  # Enable blanking, screen power saving
  xset s on; xset +dpms
  # Kill script
  if [ -n $suspinhtest ]; then
    echo "$info $prog stopped, powersaving enabled."
    kill -s 9 $(pgrep movietime-susp) &> /dev/null

Turn off all cellphones and enjoy the show!


Get every new post delivered to your Inbox.

Join 58 other followers