admin管理员组文章数量:1252682
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 (作者:张华 发表于:2019-04-14)
买了一款Intel compute stick core m3, 具有HDMI接口输出音频, 但如何使用手机临时地作为显示器及键盘鼠标控制它呢?
屏幕共享 - vnc & teamviewer & anydesk
windows上有一款叫spacedesk的软件, 电脑和手机上都安装它之后, 在同一个局域网可以很方便地从手机控制电脑棒.
Ubuntu上可以使用vnc, teamviewer, anydesk.
- ubuntu上安装VNC
# https://medium/@aldo_mx/simplest-way-to-configure-vnc-server-in-xubuntu-16-04-lts-and-newer-6c0b3ae21fe5
sudo apt-get install vino
gsettings list-recursively org.gnome.Vino
# some clients like TightVNC for Windows do not work with encryption anymore
# because older protocols like SSLv3 and TLSv1 have been deprecated.
# dconf-editor - ORG > GNOME > DESKTOP > REMOTE ACCESS
gsettings set org.gnome.Vino require-encryption false
# activate at startup, or set "Settings -> Sharing -> screen Sharing" in ubuntu
sudo cp /usr/share/applications/vino-server.desktop /etc/xdg/autostart/vino-server.desktop
# #enable "Application Autostart -> Desktop Sharing(Gnome Desktop Sharing Server)"
xfce4-session-settings
/usr/lib/vino/vino-server --sm-disable
vncviewer 192.168.99.124:5900 #but too slow
需注意两点:一是要设置require-encryption=false, 二是手机上使用realvnc client时不应该登陆,因为没用realvnc server,而是用的vino server
但是vino太慢了,改成vnc4server又是花屏的.
sudo apt -y install vnc4server
vncpasswd #not use sudo
#vncserver -kill :0
#taken because of /tmp/.X11-unix/X0
sudo rm /tmp/.X11-unix/X0 && sudo rm /tmp/.X0-lock
vncserver -geometry 1280x800 -alwaysshared :0
所以最后使用xrdp
sudo apt -y install xrdp
cat /etc/xrdp/xrdp.ini
sudo systemctl status xrdp
sudo adduser xrdp ssl-cert
#sudo ufw allow from 192.168.99.0/24 to any port 3389
#sudo ufw allow 3389
use Remmina as rdp client
20230321更新 - 今天按上面的方法安装xrdp,但通过remmina却连不上。chatgpt说"如果您仍然无法连接,请确保目标 Ubuntu 主机已经启用了 Remote Desktop 功能。您可以在 Settings -> Sharing -> Screen Sharing 中启用该功能。另外,您还需要为远程用户设置密码,您可以在 Settings -> Users 中设置密码。",但试了也不行。后来重启机器之后才可以.
- 安装使用anydesk使用屏幕, 鼠标, 键盘. (但没法用本地摄像头)
wget https://download.anydesk/linux/anydesk_4.0.1-1_amd64.deb
sudo dpkg -i anydesk_4.0.1-1_amd64.deb
sudo apt --fix-broken install
sudo dpkg -i anydesk_4.0.1-1_amd64.deb
echo 'password' |sudo anydesk --set-password
sudo systemctl enable anydesk.service
最后, 设置anydesk, 设置允许随时连接查询, 并设置密码, 禁用掉声音传输.
但又遇到一个问题, 在笔记本上测试anydesk似乎没有问题. 但移到电脑棒上后, 电脑棒启动后经常无故死机. (无故死机的问题找到了, 一次是因为电源没插好接触不良, 另一次是应用了平时给手机充电的Type-A USB输出的充电器, 应该使用自带的APD亚源科技的Type-C输出口的充电器(输出则是5.2V 2.2A(Type-C对机身)、5V 0.9A(对两个Type-A),这个问题真难查). 但仍然遇到一个问题 (手机上的anydesk发起连接时报: 连接已终止,. 状态: result_invalid_state,暂不清楚原因)
- 切换为teamviewer, 也是遇到类似问题, 曾经成功过, 但之后手机上的teamviewer就一起报: teamviewer正在启动, 请稍候. (该问题原因已找到, 因为墙,用4G网络可以, 见: https://github/ywb94/openwrt-ssr/issues/31 及 https://zvv.me/z/1366.html )
还存在一个问题: **如果电脑棒不通过HDMI接口接一个显示器, 电脑棒重启之后通过远程桌面连接过去看到的是一屏黑色. 那是因为Linux服务器一般是不接显示器的,用ssh等文字界面连接管理即可, 可是有些软件需要GUI管理,若不接显示器,xwindows是默认无法启动的,从而导致vnc server连接失败, 可配置一块fake显示器解决:
# https://askubuntu/questions/453109/add-fake-display-when-no-monitor-is-plugged-in
sudo apt-get install xserver-xorg-video-dummy xfce4 chromium
sudo bash -c 'cat > /usr/share/X11/xorg.conf.d/xorg.conf' <<EOF
Section "Device"
Identifier "Configured Video Device"
Driver "dummy"
EndSection
Section "Monitor"
Identifier "Configured Monitor"
HorizSync 31.5-48.5
VertRefresh 50-70
EndSection
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1024x800"
EndSubSection
EndSection
EOF
sudo reboot
但是使用上述的软件模拟的显示器, 会造成即使接了真显示器, 还是用得虚拟的, 所以不方便啊. 网上有硬件的Dummy HDMI可用.
kdeconnect
kdeconnect可以用来在ubuntu与androd之间双向传输数据, 例如电脑使用手机的键盘鼠标, 电脑与手机相互传输数据, 手机上的短信通知发给电脑显示.
直接在电脑与手机上安装kdeconnect即可使用.
sudo apt install kdeconnect
但kdeconnectd进程 (/etc/xdg/autostart/kdeconnectd.desktop)在ubuntu未登录之前是不会启动的, 所以禁用掉电脑棒的密码登录设置它为自动登录即可.
gsconnect gshell extension
gsconnect与kdeconnect是类似的东西, 它不依赖kde的一些包, 但它依赖Gnome desk与chrome, 电脑棒启动后没有自动启动chrome的话用不了. 所以实际我用的还是kdeconnect, 但这里记录使用gsconnect的过程.
- 安装gnome-shell-extension与chrome-gnome-shell
gnome-shell --version
sudo apt install gnome-shell-extensions
sudo apt install chrome-gnome-shell
离个题, 例如想显示各个不同时区的team member的上班时间的话, 可以添加~/people.json将每个人的时区按下列格式添加进去即可.
vim ~/people.json
[
{
"name": "your name",
"github": "your lauchpd id",
"city": "Beijing",
"tz": "Asia/Shanghai"
}
]
- 访问这个网址https://extensions.gnome/extension/1319/gsconnect/ 方便地安装gsconnect即可 (注意: 如果出错, 多半是因为没有在chrome里访问 chrome://extensions/ 将GNOME Shell integration打开的原因).
- 手机上在play里搜索安装KDE Connect, 并打开它, 和gsconnect为pair配对.
- 还可以支持电脑上Nautilus来mount手机上的文件
sudo apt install python-nautilus gir1.2-nautilus-3.0 sshfs
# then send file to Android by first open the nautilus then right click one file "Send to Mobile Device -> Nokia"
附录 - 让vnc开机自动运行
刚开始打算把开vnc的脚本放到rc.local里,但不work, 因为运行vnc是需要home目录的
/usr/bin/vncserver -kill :4
/usr/bin/vncserver :4 -localhost no -geometry 1024x768
/usr/bin/ssh -o ConnectTimeout=5 -o ServerAliveInterval=50 -fNR 43301:localhost:5904 xxx-jump
sudo bash -c 'cat >/etc/systemd/system/rc-local.service' <<EOF
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
EOF
printf '%s\n' '#!/bin/bash' 'exit 0' | sudo tee -a /etc/rc.local
sudo chmod +x /etc/rc.local
sudo systemctl enable rc-local
sudo systemctl restart rc-local.service
sudo systemctl status rc-local.service
所以最后搞成下面的:
sudo bash -c 'cat >/etc/init.d/vncserver' <<EOF
#!/bin/sh -e
PATH="$PATH:/usr/X11R6/bin/"
# The Username:Group that will run VNC
export USER="zhhuabj"
#${RUNAS}
# The display that VNC will use
DISPLAY="4"
# Color depth (between 8 and 32)
DEPTH="16"
# The Desktop geometry to use.
#GEOMETRY="<WIDTH>x<HEIGHT>"
GEOMETRY="1024x768"
# The name that the VNC Desktop will have.
NAME="zhhuabj-vnc"
OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
. /lib/lsb/init-functions
case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;
stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
restart)
$0 stop
$0 start
;;
esac
exit 0
EOF
sudo chmod +x /etc/init.d/vncserver
sudo update-rc.d vncserver defaults
sudo /etc/init.d/vncserver start
vncserver
sudo apt install vnc4server xfce4 xfce4-goodies -y
vncpasswd
sudo bash -c 'cat > ~/.vnc/xstartup' << EOF
#!/bin/bash
startxfce4 &
EOF
sudo chmod +x ~/.vnc/xstartup
/usr/bin/vncserver -kill :1
/usr/bin/vncserver :1 -geometry 1024x768
sudo ufw allow from any to any port 5901 proto tcp
20200818更新
使用todesk - https://www.todesk/download.html
20230419更新 - rustdesk
可以使用rustdesk,下面是自定义国内rustdesk服务器的步骤:
# hhbr is relay service, while hbbs is registration service
wget https://github/rustdesk/rustdesk-server/releases/download/1.1.7-4/rustdesk-server-hbbr_1.1.7_amd64.deb
wget https://github/rustdesk/rustdesk-server/releases/download/1.1.7-4/rustdesk-server-hbbs_1.1.7_amd64.deb
sudo dpkg -i rustdesk-server-hbb*
sudo systemctl cat rustdesk-hbbs.service |grep WorkingDirectory
# secret key
cat /var/lib/rustdesk-server/id_ed25519.pub
# TCP(21115, 21116, 21117, 21118, 21119) UDP(21116)
20230518 更新
一直用xrdp好好的,忽然就不行了。后来debug后发现是gdm3的loop login老毛病又回来了。所以只好放弃xrdp.
用gnome自带的rdp(gnome-remote-desktop)吧,登录进去了,但是就一个桌面,看不到开始菜单。
从rdp换成vnc吧,还是花屏老毛病,放弃.
本来换成anydesk了的,但今天也是忽然点了之后一块白板。但是现在也没选择了,只能继续试anydesk, 发现重新安装一下白板消失了。 通过’sudo systemctl status anydesk '找到了之前白板的原因是因为需要安装libcanberra-gtk-module这个包.
另外, 下次再继续发生remote desktop的问题,那直接改用’ssh -X’了,记得添加’export XAUTHORITY=$HOME/.Xauthority’来支持snap应用
20230530 - 将iphone投屏到ubuntu
现在一些app总是只有手机版,没有电脑版,天天对着手机小屏幕容易坏眼睛,有必要将iphone投屏到ubuntu有种方式:
1, airdroid cast, iphone上安装airdroid cast, ubuntu从这个网页访问:https://webcast.airdroid/?lang=en#/ ,是基于浏览器,并且声音还在手机上。
2, UxPlay, ubuntu上安装如下,iphone上正常投屏连接即可。声音在ubuntu上.
sudo apt install libplist-dev libavahi-compat-libdnssd-dev -y
sudo apt install libgstreamermm-1.0-dev gstreamer1.0-plugins-bad gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-libav -y
git clone https://github/antimof/UxPlay.git
cd UxPlay
mkdir build & cd build
cmake ..
make
./uxplay
#注意将将XDG_RUNTIME_DIR与DISPLAY改成合适的值,在终端上通过echo $DISPLAY可找到合适的值
$ cat /etc/systemd/system/uxplay.service
[Unit]
Description=uxplay
Wants=network-online.target
After=network.target
[Service]
Type=simple
User=hua
Group=hua
Environment="XDG_RUNTIME_DIR=/run/user/1000" "DISPLAY=:1"
ExecStart=/bak/soft/UxPlay/build/uxplay
[Install]
WantedBy=multi-user.target
另外,android(<11)投屏到ubuntu可使用scrcpy (Audio disabled: it is not supported before Android 11), 使用’adb tcpip’时不需要root但每次开机得运行一遍。另外在android11以上是有无线调试功能的,结合shizuku很容易固定adb端口
#scrcpy: error while loading shared libraries: libavformat.so.58
sudo apt install ffmpeg libsdl2-2.0-0 adb wget gcc git pkg-config meson ninja-build libsdl2-dev libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev libswresample-dev libusb-1.0-0 libusb-1.0-0-dev -y
git clone https://github/Genymobile/scrcpy
cd scrcpy && ./install_release.sh
adb tcpip 5555
adb connect 192.168.2.123:5555
scrcpy --fullscreen --show-touches --bit-rate 2M --max-size 800 -s 192.168.2.212:5555
scrcpy --fullscreen --show-touches --bit-rate 2M -s 192.168.2.212:5555
#按esc键是返回, 另外如果adb显示offline那是要将usb调试处的usb连接从充电改为MTP传输
20240104 - 多屏幕协同
华为电脑和华为手机有多屏幕协同,非华为手机的多屏幕协同可以用虫洞(在box上因为屏幕大了没法点, 这个不行) - https://www.er.run/#download
非华为电脑的多屏协同可以参考: https://zhuanlan.zhihu/p/378347509
用scrcpy的话,因为box的版本是android7, 小于android11所以不支持传音频。
vysor, 在win, linux, browser中相互投屏,但不包括android
X11, linux间屏幕共享
airdroid cast, 局域网内投屏和声音免费,但远程控制和iphone的airplay服务收费
peazip - 替代winrar的解压软件
20241107 - 如果将三星s24投屏到ubuntu
首先用type-c转hdmi线应该可以对s24进行有线投屏,如果要无线投屏呢?
开发者模式中打开无线调试后再点无线调试后可找到端口和密码信息:
#开发者模式中的无线调试中找到端口和密码信息
adb pair 192.168.3.52:45687
adb connect 192.168.3.52:40761
adb shell
无线调试连接成功之后,运行下列scrcpy总是hang在那儿,不清楚什么原因:
#adb server version (41) doesn't match this client
sudo apt remove adb
wget https://dl.google/android/repository/platform-tools-latest-linux.zip
unzip platform-tools-latest-linux.zip -d ./android-sdk
export PATH=/bak/soft/android-sdk/platform-tools:$PATH
sudo snap remove scrcpy
sudo apt install ffmpeg libsdl2-2.0-0 adb wget gcc git pkg-config meson ninja-build libsdl2-dev libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev libswresample-dev libusb-1.0-0 libusb-1.0-0-dev -y
git clone https://github/Genymobile/scrcpy
cd scrcpy && ./install_release.sh
/usr/local/bin/scrcpy --fullscreen --show-touches --audio-bit-rate 2M
想到了Shizuku,但scrcpy并不能使用shizuku所以也失败了。shizuku是一个让你告别Root烦恼畅快使用系统API的软件!至于哪些app可以用shizuku呢?这里有一个列表显然scrcpy并不在之列 - https://github/timschneeb/awesome-shizuku?tab=readme-ov-file
Shizuku 与 Magisk 并不是互为替代的方式,后者对用户来说更硬核、要求更高,当然能实现的功能也更多,前者只是借用系统自带的调试功能完成提权并供第三方应用调用。如果两者搭配使用,Shizuku 也不必每次重启后重新授权、也减少了第三方应用滥用 root 权限的可能,是更完美的方案。
也试了在win11上安装airdroid cast,说接收端不在线 (在win11上安装无线显示器也是失败 - dism /Online /Add-Capability /CapabilityName:App.WirelessDisplay.Connect~~~~0.0.1.0 ),
考虑到这是三星手机,可用三星多屏联动(Samsung flow)来投屏。
20241108 - 三星Galaxy S24手机玩法
三星s24手机使用诀窍:
1, 手机运行p2p连接家里网络解决手机通知的问题
2, 语音助手Bixby, 用”嗨,三星小贝“唤醒
3, 有实时字幕功能 - 设置中的“辅助功能"->“听力增强”->语音转文字, 可通过语音唤醒 (还有一个叫"实时转写和声音通知"的app特好用
4, 其他文本处理的AI功能可用三星智慧(一直左划到最左页可找到)或Gemini
4, 同传可接打电话时同声中英翻译
5, 长按home键可以调用即圈即搜
6, 右手单手从右下角往左上划即调用google助理 - https://www.douyin/video/7359855989207665955
7, S互传可方便分享文件
8, Dex功能可将手机通过有线或无屏投屏并当电脑使用, 如手机投屏android电视可用无线,也可HDMI有限连显示器, 若想通过USB有线将三星手机投屏windows可在windows上安装Samsung DeX.
9, 若要无线投屏的话可用三星多屏联动(Samsung flow) - 微软应用商店安装即可
10, 同时录入人脸与指纹,将每次必须用指纹的设置去掉,这样更方便使用三星钱包中的各种NFC卡片
11, 出境可用三星畅连, 国内日常生活可用三星生活助手
20241114更新, 三星手机有一个非常重大的缺陷,它自带的三星日历会删除一些日历 (https://eumunity.samsung/t5/galaxy-s22-series/random-deletion-of-calender-schedules/td-p/8471133), 目前的workaround就是删除sansung calender app,并且设置不允许third party来读日历 (https://calendar.google/calendar/syncselect) . 更新:实际上日历不是三星日历删除的,而是华为手表关联的华为运动app删除的, 通过IS部门的google审计日志可确认。
版权声明:本文标题:手机作为显示器及键鼠控制电脑棒(by quqi99) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/biancheng/1740425726a2274795.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论