Sending keyboard input to a program from command-line

后端 未结 4 1319
轻奢々
轻奢々 2021-02-01 23:44

How do you send keyboard input to a program?

That is, under a Linux GUI, is there a good manual (programmable) way, or tool, of simulating keyboard input on a running pr

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-02 00:35

    I've built a Ruby DSL around xdotool to simplify the focusing of windows and simulation of keyboard input. Here's an example, riffing on your original request:

    Mani.new(window_manager: :xmonad) do
      window :hello, launch: 'urxvt' do
        run 'echo "hello\n"'
      end
    
      window :firefox, launch: 'firefox', delay: 1.5 do
        type '{{ctrl+t}}'
      end
    end
    

提交回复
热议问题