naelstrof / maim

maim (make image) takes screenshots of your desktop. It has options to take only a region, and relies on slop to query for regions. maim is supposed to be an improved scrot.
Other
2.15k stars 78 forks source link

-i, --window doesn't handle hex values properly #234

Closed peterwu closed 3 years ago

peterwu commented 3 years ago
maim -i $(xprop -root _NET_ACTIVE_WINDOW | cut -d " " -f 5) ~/maim.png

crashes with the error message:

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  3 (X_GetWindowAttributes)
  Resource id in failed request:  0x0
  Serial number of failed request:  21
  Current serial number in output stream:  22

Notice that xprop -root _NET_ACTIVE_WINDOW | cut -d " " -f 5 yields a hex value of the active window id. e.g. 0x1600004. If I convert the hex to a decimal like below, then the program works.

maim -i $(($(xprop -root _NET_ACTIVE_WINDOW | cut -d " " -f 5))) ~/maim.png

In this case, 0x1600004 (16) = 23068676 (10), and maim is happy with the latter but crashes with the former.

FWIW:

$maim --version
v5.7.4