A Tip For “Unmet Dependencies” in Ubuntu

Just finished fixing some “unmet dependencies” that had removed some programs on my mother’s computer.

Interestingly, it wasn’t corruption like the Google results suspected. Well… not on our end. I ended up finding an interesting solution.

Install aptitude. Instead of apt-get’s “Can’t meet dependencies. We’ll just keep these uninstalled.”, you’ll get “Can’t meet dependencies. I propose we just keep these uninstalled. Ok?”

In our case, when I said “No, it’s not OK”, it then proposed downgrading half of KDE from the version provided by the maverick-security repo to the (insecure, I assume) version provided by the plain, ordinary maverick repo.

Now I finally know why some people prefer aptitude to apt-get. “Error?” is preferable to “error” any day.

Posted in Geek Stuff | Leave a comment

G15/LCDProc Hotplug

Another belated blog entry. This one for a little hack I did to get G15Daemon and LCDProc resetting nicely when, for whatever reason, I have to temporarily unplug my Logitech G15 keyboard.

If I ever find myself back on KDE 4, I’ll probably come up with some kind of amendment to these to also reset kded’s global keybindings since, last I checked, it got confused by g15daemon’s uinput proxy restarting.

Posted in Geek Stuff | 1 Comment

Modernizing XTerm’s Paste

If  you’ve ever tried to alter XTerm’s key/mouse bindings, you’ve probably noticed that the documentation is cryptic, pretty much only found in the manpage, and not supplemented by anything you’re likely to find on Google.

So, one day, when I decided I wanted yeahconsole to have some keybindings more similar to the modern ones I’d grown familiar with from Yakuake, I was in for quite a fight.

Here’s what I came up with should anyone else want them. (Sorry I couldn’t implement the Ctrl+Shift+X/C part too. I’m starting to doubt it’s actually possible without patching XTerm’s source)

If you want to modify or extend this, here’s a complete list of the resources I found useful in helping me to understand the darn thing: (Ordered roughly from most to least likely to help you)

If, while customizing, you find a better reference for the valid function mappings for Translations or if you figure out a way to implement Ctrl+Shift+X/C/V for cut/copy/paste, please let me know.

Update: If you insist on Ctrl+V pasting, urxvt is equivalent to xterm in every way you’re likely to care about and there’s a clipboard Perl extension for it.

Posted in Geek Stuff | 5 Comments

A Brief List of Ways to Make Xinerama and Games Get Along

As none of you certainly know, my system has a very odd video setup:

  • Because I hate bad window management misplacing things when the resolution changes, I’ve used xorg.conf to lock my desktop at 2560×1024
  • Because I’m using nVidia TwinView, XRandR tells applications that the entire desktop is one monitor but the window manager still gets the Xinerama hints it needs to interpret fullscreen and maximize as only half of that.
  • Games generally assume that you’ll want to play them fullscreen… sometimes not even offering an obvious way to enable windowed mode.
  • Since I got my new video card with HDMI for the second monitor, my right monitor is the first one, not my left one.

I think you can see where this might cause a problem. Games tend to exhibit one of the following behaviours:

  • Fullscreen across both displays, centered on the big physical gap between screens. (Not since my new video card)
  • Fullscreen on the right-hand monitor, center as if fullscreening across both displays. (Since my new video card)
  • Fullscreen on one monitor, letterbox to the aspect ratio of the desktop as a whole (YouTube and Cortex Command, I’m looking at you)
  • Windowed mode, but only offer 2560×1024 as a resolution unless you edit the config file manually because they naïvely use SDL’s list of fullscreen resolutions for windowed mode too.

This wouldn’t be a huge deal, since I tend to prefer windowed-mode play anyway, except that sometimes, the mouse is mapped wrong too, so you can see the “Options” button but can’t click it.

So far, here are the workarounds I’ve found successful:

  1. Just let the stupid things muck with your resolution settings (I’d rather not game instead, but you may feel differently)
  2. Manually edit the config file to set windowed mode and a sane resolution. (Most commonly successful option for open-source games. Look for ~/.gamename, ~/.config/gamename, or possibly ~/.local/share/gamename)
  3. Check -h, -help, --help, -?, and any README files for an option to start windowed. Try -w, -windowed, and --windowed just in case. (eg. Braid)
  4. Try pressing Alt+Enter at the main menu screen (eg. World of Goo)
  5. Run it inside Xephyr (Currently only supports software rendering, but there’s a fork I haven’t tried yet which passes OpenGL through to the host for hardware rendering.)
  6. Run the Windows version inside Wine with a virtual desktop. (eg. Psychonauts, Space Rangers 2. Doesn’t work with all games because, for reasons I can’t fathom, some games do double-buffering normally (which Wine supports) and triple- or quadruple-buffering (which Wine doesn’t yet support) when you try to run them in a virtual desktop)
  7. If it’s something where having a bar down the center of the monitor is a small price to pay for seeing more  (like a strategy game), use export SDL_VIDEO_FULLSCREEN_HEAD=2 to put it on your top-left monitor so it’ll try to span all of them without realizing it. (eg. Revenge of the Titans. Thanks to MakeTechEasier.com for this.)

Once you’ve got that, you may want to simulate fullscreen on a single monitor. The simplest way to do that is to set the window to the same resolution as your monitor, use “Always on Top” to make it cover your panels (taskbar, etc.), and then hide the window border to make it fit the screen. There are two ways to do that:

  1. Right-click your window titlebar while the window’s loading, set Always on Top, and then either do it again to hide the window decoration or, if that’s no an option, bind something like WinKey+T to toggle WinDeco and press it. (Tested working in KDE and LXDE/OpenBox)
  2. If your window manager allows you to set per-application rules (again, tested working with KDE and LXDE/OpenBox), you can automate this. See your window manager’s documentation for details. (I also use this to make Minecraft start maximized)

One more tip: With games like Trine and Aquaria which capture the mouse, you can toggle the grab with Ctrl+G… useful in Trine for switching back and forth between the game and a walkthrough to get those last few experience vials that you literally can’t find without being told about them.

Update: One or both of these may also help with some games. (Thanks to the Torchlight README.linux for clueing me in)

export SDL_VIDEO_X11_XINERAMA=0
export SDL_VIDEO_X11_XRANDR=0
Posted in Geek Stuff | 1 Comment

Git Tricks for Clean Histories

As much as I love the concept of cheap branching and revision control, I’m a bit of a “code first, ask questions later” kind of guy. Most of my best ideas only come to me once I’m elbow-deep in code and they tend to arrive in bits small enough to make planning my branching and committing impossible.

For this reason, I get a lot of use out of git commands which help me to code first and then sort it out later. Here are my favorites:

IMPORTANT: None of these should be used on commits which have already been shared. Clean up your repository, then “git push”. Eagerness to push is one bad habit you’ll just have to break the hard way.

Temporarily get rid of uncommitted changes
git stash
[do your thing]
git stash pop
The manpage gives some examples for where this can be helpful. The most obvious is “boss interrupts you demanding a bugfix immediately”.
Use a GUI to stage and commit only certain lines
git gui

I use this to untangle unrelated changes into clean commits after the fact. The “git citool” alias makes it automatically close when you commit.

Add the staged changes to the last commit you made instead of a new one
git commit --amend

…or just use “git gui”.

Merge “oops” commits within the last 12 into what they should have been part of
git rebase -i HEAD~12

…and then move each “oops” commit below its parent and change “pick” to “fixup”.

Interactive rebase is a very powerful function which can also be used to apply arbitrary changes to any commit you haven’t yet shared. For details, check out the “reword”, “edit”, and “exec” commands in the instructions it displays.

Note: Rebase can sometimes get confused, but if you ever find yourself confused by its requests for clarification and just want to change your mind, simply use git rebase --abort

Move the last 8 commits to a new branch
git branch my_new_branch
git reset HEAD~8
git checkout my_new_branch

Use this when you you find yourself thinking “Dammit! This should be a feature branch.” It works by telling git to create a new branch with its HEAD here and then to move the current branch’s HEAD 8 commits into the past.

Move the last 8 commits to an existing branch
git stash
git checkout -b tmp
git rebase --onto right_branch HEAD~8
git checkout right_branch
git merge tmp
git branch -d tmp
git checkout wrong_branch
git reset --hard HEAD~8
git checkout right_branch
git stash pop

This complex string of commands is for when you make some commits, then realize you’re on the wrong branch. I wish I could offer something simpler, but moving a string of commits to a branch that could’ve diverged quite far is a complex task.

Basically, you stash away your uncommitted changes, use a temporary branch to rebase and merge the changes into the new branch, and then remove them from the old branch, and apply the uncommitted changes to the new branch.

Undo a merge and rebase instead after accidentally running “git pull” instead of “git fetch”
This is useful when you want to keep a nice, linear development history, you’ve developed something, you try to push it, it fails, and you respond with git pull rather than git fetch. (I tend to forget to pull before developing when switching machines)
The trick is to use git’s reflog feature (git’s Undo history). If your branch is named mybranch and the remote is origin/mybranchand `git pull` is the last thing that made changes, you can undo it like this:

git stash
git reset --merge mybranch@{1}
git rebase origin/mybranch
git stash pop

(You can omit the git stash lines if you don’t have any uncommitted changes)

This feature isn’t limited to undoing merges either. Use this command to see what else you can feed to git reset:

git reflog show
And so on…
Got a type of “oops” I missed? Tell me so I can update this post.

UPDATE: Justin Hileman has an excellent flowchart which you’ll probably also want to check out.

Posted in Geek Stuff | Leave a comment

Status Update

For the last while, I haven’t really posted anything on this blog. While I’d like to blame it on coursework or other projects, the truth is that there are many reasons.

Aside from “coursework and other projects”, I’ve also been preparing to switch this blog from WordPress to Jekyll to make it more compact, easier to theme, and more secure. (After all, it’s pretty hard to perform a worthwhile exploit on a site that’s nothing but static HTML and a some JS includes for Disqus, FriendFeed, and AddToAny… especially given some of the security policy extensions on the horizon for HTML)

However, being the perfectionist that I am, I tend to get stuck on sub-problems that, while I can reorder them, must all be done before I can make the switch. (Things like making absolutely certain that no links will break)

To make things simpler, I’ve been working from a known-good export of the blog’s contents and not updating the blog. (Though, as anyone who follows my Identi.ca/Twitter review/rating posts will know, I have continued to work away at the same activities as always)

Given that my switch to Jekyll wasn’t completed before my Christmas vacation, I may reconsider that decision. I have built up quite a backlog of topics to blog on and it’d probably be better for everyone if I just cleared that out and let the switch to Jekyll happen whenever I finally get everything right.

I do still have projects and coursework to do, so I won’t begin posting again right away, and knowing my history with time management, I can’t make any promises, but I’ll try.

Posted in Geek Stuff, Otaku Stuff, Site Updates | 2 Comments

A Quick And Dirty m0n0wall “Get WAN IP” API

Until recently, I’d been using WhatIsMyIP.com’s API to fill in the external IP field in my Conky readout, but a few days ago, they started a very silly thing where, for whatever reason, clients have to follow a 301 redirect to the URL they just asked for in order to get the IP. I decided that was excuse enough to write a more direct solution.

Since, recently, I’d learned that it’s possible to muck about in m0n0wall without pulling the CF card (despite the lack of proper SSH), I decided to take m0n0wall’s interfaces readout page, strip out everything that wasn’t necessary to get the WAN IPv4 address, and add an explode() call to separate the IP from the hostmask.

If you want it for your own m0n0wall box, here are the instructions:

  1. Grab api_wan_ipaddr4.php from my GitHub Gist.
  2. Go to exec.php on your m0n0wall box (http://192.168.1.1/exec.php with the default DHCP configuration)
  3. (optional) Type “status_interfaces.php” into the download box and use a tool like diff to verify that I haven’t added anything nefarious.
  4. Use the exec.php upload interface to upload api_wan_ipaddr4.php.
  5. Run these commands using the exec field:
    mv /tmp/api_wan_ipaddr4.php /usr/local/www
    chmod 755 api_wan_ipaddr4.php
  6. Load it in your browser (http://192.168.1.1/api_wan_ipaddr4.php with defaults) to confirm that it’s working.
  7. Use wget/curl/etc. with HTTP authentication to retrieve your external IP whenever you want. I use this command for my conky:

    curl -s --insecure --anyauth --netrc https://192.168.0.1/api_wan_ipaddr4.php

Posted in Geek Stuff | 5 Comments