woodruffw / x_do.cr

Crystal bindings for libxdo (xdotool)
https://woodruffw.github.io/x_do.cr/
MIT License
18 stars 1 forks source link

Fix null pointer in window.name #11

Closed phil294 closed 2 years ago

phil294 commented 2 years ago

Most X11 windows apparently have no name, and xdotool (done with version 2016, the previous / working one) returns a null pointer. x_do.cr however expects a string. This adds a null check so that window.name returns nil in that case instead of failing with Unhandled exception: Cannot create a string with a null pointer (ArgumentError).

Demo code:

require "x_do"

XDo.act do
    wins = search do
        window_name "" # all (regex)
    end
    puts wins.map &.name
end