Resize the terminal with Python?

前端 未结 2 1312
野的像风
野的像风 2021-01-03 04:58

I couldn\'t find anything with a quick Google search, nor anything on here, saving for this. However, it doesn\'t do the trick. So how exactly do you resize the ter

2条回答
  •  既然无缘
    2021-01-03 05:46

    If you install xdotool, you can change the size of the terminal window with something like this:

    import subprocess
    import shlex
    
    id_cmd='xdotool getactivewindow'
    resize_cmd='xdotool windowsize --usehints {id} 100 30'
    
    proc=subprocess.Popen(shlex.split(id_cmd),stdout=subprocess.PIPE)
    windowid,err=proc.communicate()
    proc=subprocess.Popen(shlex.split(resize_cmd.format(id=windowid)))
    proc.communicate()
    

    PS. On Ubuntu xdotool is provided by a package of the same name.

提交回复
热议问题