creating thumbnail image from a pdf with imagemagick

convert -thumbnail x640 -density 300 -background white -quality 85 -colorspace RGB -alpha remove -depth 8 path_to.pdf[0] thumbnail.jpg

Advertisements

Getting Window Properties when your Mouse is Unavailable

Or, floating the menu in xfce

I’m currently using XMonad in Xubuntu, which has been really lovely. However, I got very tired of the xfce4’s menu also being tiled. The XMonad.ManageHook package provides tools for dealing with your windows (floating, ignoring, whatever) provided you have some information about them, like the title.

-- signatures from XMonad.ManageHook

title :: Query String
-- Returns the window title.

doIgnore :: ManageHook
-- Map the window and remove it from the WindowSet.

We can get the window’s title by checking the value of _NET_WM_NAME(UTF8_STRING), which can be done through xprop. But using xprop to get the title of xfce4’s menu by clicking on the open menu doesn’t quite work out

$ xprop
xprop: error: Can't grab the mouse.

We need a way to get information about all the windows we have open. Enter xwininfo!

$ xwininfo -children -root
# lots of stuff here

Unfortunately at this point you have to manually scan the output for what you’re looking for, if you have no idea what it might be called.

At this point we can utilize xprop to get more info about our window, if we choose..

$ xprop -name "Whisker Menu"

…but in this instance there was no need. The following snippet added to your ManageHook, will ignore the xfce4 whisker menu.

title =? "Whisker Menu" --> doIgnore

XMonad + XFCE

After 5 years or so, I have switched from Arch Linux to Xubuntu. Whether or not this change is permanent remains to be seen. I do miss pacman quite a bit.

Currently running XMonad as my window manager. I’m using xmonad-log-applet to send info (xmonad layout, focused window title, etc) to xfce4-panel.

Here’s a relatively bare-bones xmonad.hs that makes XMonad in XFCE4 a little more comfortable. Actually the most important part here is replace; without it, I was running into all kinds of funky issues with xfce4-panel.

A Palindrome Encounter

On May 24, 2016 I looked at the time in the evening and it was 5:45. Ah, a palindrome! I thought. (Looking at it as a number/sequence of digits rather than a sequence of characters.) The next time I looked at the time it was 6:56. Also, you’ll notice, a palindrome.

A connection between these two palindromes: the absolute difference between the unique digits of both these palindromes is 1 (|5-4|=|6-5|). One just so happens to be the unique digit(s) making up the palindrome 11, which is also the sum of the unique digits of the latter palindrome (6+5). The sum of the unique digits of the first palindrome is 9 (5+4), which is also a palindrome, if trivial.

Ahhhh, life!

p.s. I remembered the date as being May 24 because, where I live, we write that date as 5/24 (month/day). Perhaps it would have been fitting to have this observation on 5/25, thereby bagging another palindrome. However, May 24th is one day away from May 25, which is even more fitting. (In that same sense, May 26th would have pleased me too.)

p.p.s. I suppose this breaks down a little if you live your life on a 24hr clock… which seems to be quite common.

the cat is not away

In a true test of my ability to navigate via keystrokes, my mouse has disappeared. (Not the physical one, but the pixelated one.)

It’s going great so far. Until, you know, I encounter a flash video…

Chrome/Chromium is sound-greedy

I was having an issue where chromium (and chrome) would… grab onto my sound device? Basically it would not play sound if another application (eg firefox) was. When chromium was able to play sound, then these other applications could not.

Installing the pulseaudio-alsa package on Archlinux fixed this. It did require a restart.

emacs: Indirect Buffers

Say you have buffers A and B both visiting the same file. Sure, you can view different parts of this file in A and B, but once you narrow in one buffer, the same section is narrowed in the other.

When this is not the behaviour you want (when would you actually want this behaviour, is the real question imho), use indirect buffers!

An indirect buffer shares the text of some other buffer, which is called the base buffer of the indirect buffer. In some ways it is a buffer analogue of a symbolic link between files.

[…]

The text of the indirect buffer is always identical to the text of its base buffer; changes made by editing either one are visible immediately in the other. But in all other respects, the indirect buffer and its base buffer are completely separate. They can have different names, different values of point, different narrowing, different markers, different major modes, and different local variables.

Handy-dandy key chord C-x 4 c (clone-indirect-buffer-other-window): analogous to C-x 4 f, this binding creates an indirect buffer of the current buffer in another window. (Remember that c by remembering clone.)

Adding tap0 on ArchLinux

MirageOS networking examples tend to use ifconfig for this. On ArchLinux, ifconfig is (allegedly) deprecated, and we tend to use ip for things.

# ip tuntap add tap0 mode tap
# ip addr add 10.0.0.2/255.255.255.0 dev tap0
$ ping 10.0.0.2 # browse to http://10.0.0.2 if applicable

Logging opam install Errors

$ echo y | opam install mirage >> iopage.err 2>&1
  • echo y because opam wants confirmation that you really want to install
  • 2>&1 redirects both stdout and stderr to iopage.err

Though what I’d really like is to be able to redirect stdout/err to a file and still have them output to the terminal.