bash 如何使用其他用户的显示器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10080484/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 01:59:32  来源:igfitidea点击:

How can I use another user's display

bashssh

提问by geermc4

I'm using xdotool in a SSH connection logged in as root , I'm setting DISPLAY=":0.0" which is what echo $DISPLAYreturns on the logged user says. But i get a error unless i su to the other user

我在以 root 身份登录的 SSH 连接中使用 xdotool,我正在设置 DISPLAY=":0.0" 这是echo $DISPLAY登录用户返回的内容。但是我收到一个错误,除非我向其他用户发出警告

root@sb:~# export DISPLAY=":0.0"
root@sb:~# xdotool getactivewindow
No protocol specified
No protocol specified
Error: Can't open display: (null)
Segmentation fault (core dumped)


geerm@sb:~$ export DISPLAY=":0.0"
geerm@sb:~$ xdotool getactivewindow
41943046

Is ths even possible? If so, what do i need to change to use the logged in user's session ?

这甚至可能吗?如果是这样,我需要更改什么才能使用登录用户的会话?

采纳答案by zigdon

By default, most X servers disallow other users displaying to each other's screens. If you want to disable this protection, you might be able to using xhost.

默认情况下,大多数 X 服务器不允许其他用户在彼此的屏幕上显示。如果您想禁用此保护,您可以使用xhost

回答by pizza

Try:

尝试:

export DISPLAY=his_xserver_ip:0.0

and probably you need to add the IP allowed to connect to his xserver to his xhosts thru xhost +ip_to_connnect_from

并且可能您需要通过 xhost +ip_to_connnect_from 将允许连接到他的 xserver 的 IP 添加到他的 xhosts

http://www.xfree86.org/current/X.7.html

http://www.xfree86.org/current/X.7.html