2016-10-03

Close tmux window, not its child processes

This morning I wanted to open an old slideshow as a reference for a new document. The easiest way to pull up the PDF viewer was to create a new window in tmux; open evince; and close the tmux window. I was surprised by the following error:

# mike at ordi in ~/path/to/file [9:47:56]
$ evince old_slides.pdf&
[1] 23952

# mike at ordi in ~/path/to/file [9:48:22]
$ exit
zsh: you have running jobs.

There is a simple solution: disown.

# mike at ordi in ~/path/to/file [9:48:24]
$ disown

# mike at ordi in ~/path/to/file [9:50:24]
$ exit

This time there's no warning, and the PDF viewer survives when the tmux window is closed. Thanks to this post for the tip.

2015-09-23

ncurses output to file

Suppose you'd like to store the output of htop to a file. You can do it by taking a screenshot of a GNU Screen session:

$ screen  -d -m -S screenshot htop
$ sleep 1
$ screen -p 0 -S screenshot -X output
$ screen -p 0 -S screenshot -X quit

Now the screenshot lives in output.0 in the current directory.

Adapted from this post on Stack Overflow.

2014-09-03

Skype 4.3.0.37 on Ubuntu 10.04 LTS

I recently was forced to upgrade Skype on my work desktop, which is stuck on Ubuntu 10.04 LTS, in order to continue signing in. Version 4.0 is no longer supported. They only provide 32-bit builds of 4.3.0.37, so I had to jump through a couple hoops to get it running.

First, download the latest "Dynamic" build from the Skype website. Extract this tarball this in a location of your choosing. Link the resources to the right spot:

$ sudo mkdir /usr/share/skype
$ cd !$
$ sudo ln -s /path/to/skype-4.3.0.37/*/ .
$ cd /usr/bin
$ sudo ln -s /path/to/skype-4.3.0.37/skype

If you try to run skype at this point, it complains about missing libphonon4, even if you have it installed. You need a 32-bit version. This issue can be solved by following the directions in this bug report.

Happy Skyping!

2013-10-25

Screen scrollback revisited

In this post, I comment on entering copy mode in GNU screen in order to scroll back with the keyboard. But what if you just want to use the scroll wheel? I think what you're looking for is this line in your configuration file, ~/.screenrc:

# scrolling:
termcapinfo xterm ti@:te@

I also found this cryptic code in my configuration file; I can't tell if it's relevant or not:

# Scroll up
bindkey -d "^[[5S" eval copy "stuff 5\025"
bindkey -m "^[[5S" stuff 5\025

# Scroll down
bindkey -d "^[[5T" eval copy "stuff 5\004"
bindkey -m "^[[5T" stuff 5\004

# Scroll up more
bindkey -d "^[[25S" eval copy "stuff \025"
bindkey -m "^[[25S" stuff \025

# Scroll down more
bindkey -d "^[[25T" eval copy "stuff \004"
bindkey -m "^[[25T" stuff \004

Happy screening!

2013-08-23

Correct slide alignment with Beamer

Sometimes -- and I'm not sure exactly when or why -- I find that my slides pick up a vertical offset. Every slide except the first one is shifted downwards by a few pixels. This is frustrating if you have a background image that you would like to align exactly the same way on every slide. The fix, found here, turns out to be:

  • use a newer version of PGF (I think 2.0 or greater), or
  • insert the following in the preamble:
    \makeatletter \let\Hy@FixNotFirstPage=\relax \makeatother

The issue apparently has something to do with a strange interaction between the hyperref and pgf packages.

2012-09-28

Testing bunzip2 files quickly using hexdump

My work sometimes involves dealing with large amounts of data stored in .tar.bz2 files. Recently, we found that some of the files were corrupted. The files are large enough that a successful "bunzip2 -t" takes prohibitively long. As a shortcut, we can just check for the bzip magic numbers at the beginning of the file. The bzip2 format requires that each file starts with the string "BZh". Our files are stored in batches by calendar date (MMDD). I generate a log of the files' magic numbers like so:

(for d in ????;
do
  for f in $d/*bz2;
  do
    echo $f `head -1 $f | hexdump -c -n3 | grep '0000000' `;
  done;
done) > magic_numbers.txt

And then I can find the bad files like so:

grep -v 'B Z h' magic_numbers.txt

hexdump is a nice tool for manipulating binary files on the command line. This method of testing the files runs relatively fast.

2012-09-04

Enabling hibernate on Ubuntu 12.04 LTS

I recently decided I would prefer to have the option of using hibernate on my laptop running Ubuntu 12.04 LTS. Not only does hibernate need to be enabled manually on any system running that OS; I also had insufficient swap space, so I had to resize my partitions.

Now hibernate would work, but resume would not! It turns out the reason is that I elected to encrypt my $HOME folder during installation. This requires encrypted swap; when you reboot, the swap is encrypted with a fresh, random key each time.

By insisting on using the same key each time, which requires you to enter a password during boot, you enable the boot system to detect and reload the hibernate image. If you forget the password, you boot with no swap partition.

Detailed instructions are here. It worked for me!