我一直很高兴将三星电视用作基于 Ubuntu 的神话电视系统的显示器,但在过去的几周里,它变得不可靠了。有时电视会连接到电脑,但电视通常会显示“无信号”。我尝试过各种组合打开电视等,偶尔屏幕显示几乎到登录屏幕,然后出现“无信号”。其他时候它以“无信号”开始,然后突然开始工作。我的电脑硬件是带有板载英特尔视频卡的 Zotac 电脑。它曾经运行良好,但没有发生任何硬件更改。我怀疑 Ubuntu 操作系统出于某种原因正在关闭 HDMI 输出。任何关于如何强制它启用端口或以其他方式查找故障的建议都将受到欢迎。
我有这个shellcheck
警告,我无法弄清楚:
In /mnt/e/bin/iconic line 540:
printf "FALSE|" >> "$IconsRaw" # Select field number 1
^-- SC2129: Consider using { cmd1; cmd2; } >> file instead of individual redirects.
我注意到我们这里的许多人都使用shellcheck来修复我们的 bash 脚本/shell 命令,所以我希望这个问题是关于主题的。
根据发布 bash 脚本相关部分的评论:
if [[ "$X" == "?" || "$Y" == "?" ]] ; then
: # Bad X or Y offset usually "Link to Name.ext~" (backup name)
else
let i++
printf "FALSE|" >> "$IconsRaw" # Select field number 1
printf "%s|" "$i" >> "$IconsRaw" # 2
printf "%s|" "${File##*/}" >> "$IconsRaw"
printf "%s|" "$Linkless" >> "$IconsRaw" # 4
printf "%s|" "$Date" >> "$IconsRaw" # 5
printf "%s|" "$X" >> "$IconsRaw" # 6
echo "$Y" >> "$IconsRaw" # 7
fi
解决方案
感谢接受的答案和评论,我了解到shellcheck
不仅可以捕获代码中的错误,还可以建议性能改进。在这种情况下,文件名被每个和$IconsRaw
多次打开和关闭。printf
echo
更高效的 bash 代码:
# X,Y screen coordinates invalid on backup files ending with "~"
! [[ "$X" == "?" || "$Y" == "?" ]] && { let i++; echo \
"FALSE|$i|${File##*/}|$Linkless|$Date|$X|$Y" >> "$IconsRaw"; }
我在互联网上到处搜索以找到解决此问题的方法,我已经尝试了所有方法,但仍然没有任何效果:外接显示器通过 HDMI 与我的笔记本电脑连接,这是 xrandr 输出:
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
eDP-1-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 381mm x 214mm
1920x1080 60.13*+ 60.01 59.97 59.96 59.93 48.07
1680x1050 59.95 59.88
1600x1024 60.17
1400x1050 59.98
1600x900 59.99 59.94 59.95 59.82
1280x1024 60.02
1440x900 59.89
1400x900 59.96 59.88
1280x960 60.00
1440x810 60.00 59.97
1368x768 59.88 59.85
1360x768 59.80 59.96
1280x800 59.99 59.97 59.81 59.91
1152x864 60.00
1280x720 60.00 59.99 59.86 59.74
1024x768 60.04 60.00
960x720 60.00
928x696 60.05
896x672 60.01
1024x576 59.95 59.96 59.90 59.82
960x600 59.93 60.00
960x540 59.96 59.99 59.63 59.82
800x600 60.00 60.32 56.25
840x525 60.01 59.88
864x486 59.92 59.57
800x512 60.17
700x525 59.98
800x450 59.95 59.82
640x512 60.02
720x450 59.89
700x450 59.96 59.88
640x480 60.00 59.94
720x405 59.51 58.99
684x384 59.88 59.85
680x384 59.80 59.96
640x400 59.88 59.98
576x432 60.06
640x360 59.86 59.83 59.84 59.32
512x384 60.00
512x288 60.00 59.92
480x270 59.63 59.82
400x300 60.32 56.34
432x243 59.92 59.57
320x240 60.05
360x202 59.51 59.13
320x180 59.84 59.32
DP-1-1 disconnected (normal left inverted right x axis y axis)
HDMI-1-1 disconnected (normal left inverted right x axis y axis)
当我输入xrandr --output HDMI-1-1
它没有输出时,但仍然没有任何反应。
谁能帮帮我,我很绝望。谢谢
我想在连接显示器时将我的 HDMI 显示器设置为笔记本电脑的唯一输出。现在,每次我在连接显示器的情况下打开笔记本电脑时,我都会手动更改它,但我想自动更改。
我读过您可以使用 xrandr 更改分辨率和显示器,但我无法做到。这样,我就可以在 bashrc 文件中编写命令来检查监视器是否已连接,如果是,则更改输出。关于如何做的任何建议?
今天我从 Ubuntu 18.04 LTS 升级到 18.10。更新运行时没有任何错误消息。更新后声音设置只显示“虚拟输出”。
$ pacmd list-cards
2 card(s) available.
index: 0
name: <alsa_card.pci-0000_01_00.1>
driver: <module-alsa-card.c>
owner module: 7
properties:
alsa.card = "2"
alsa.card_name = "HDA NVidia"
alsa.long_card_name = "HDA NVidia at 0xef080000 irq 17"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:01:00.1"
sysfs.path = "/devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card2"
device.bus = "pci"
device.vendor.id = "10de"
device.vendor.name = "NVIDIA Corporation"
device.product.id = "0e1b"
device.product.name = "GK107 HDMI Audio Controller"
device.string = "2"
device.description = "GK107 HDMI Audio Controller"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
profiles:
output:hdmi-stereo: Digital Stereo (HDMI) Output (priority 5900, available: no)
output:hdmi-surround: Digital Surround 5.1 (HDMI) Output (priority 800, available: no)
output:hdmi-surround71: Digital Surround 7.1 (HDMI) Output (priority 800, available: no)
output:hdmi-stereo-extra1: Digital Stereo (HDMI 2) Output (priority 5700, available: no)
output:hdmi-surround-extra1: Digital Surround 5.1 (HDMI 2) Output (priority 600, available: no)
output:hdmi-surround71-extra1: Digital Surround 7.1 (HDMI 2) Output (priority 600, available: no)
off: Off (priority 0, available: unknown)
active profile: <off>
ports:
hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: no)
properties:
device.icon_name = "video-display"
hdmi-output-1: HDMI / DisplayPort 2 (priority 5800, latency offset 0 usec, available: no)
properties:
device.icon_name = "video-display"
index: 1
name: <alsa_card.usb-Trust_Webcam_Trust_Webcam_Trust_Webcam-02>
driver: <module-alsa-card.c>
owner module: 8
properties:
alsa.card = "1"
alsa.card_name = "Trust Webcam"
alsa.long_card_name = "Trust Webcam Trust Webcam at usb-0000:00:14.0-3, high speed"
alsa.driver_name = "snd_usb_audio"
device.bus_path = "pci-0000:00:14.0-usb-0:3:1.2"
sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.2/sound/card1"
udev.id = "usb-Trust_Webcam_Trust_Webcam_Trust_Webcam-02"
device.bus = "usb"
device.vendor.id = "0c45"
device.vendor.name = "Microdia"
device.product.id = "6340"
device.product.name = "Camera"
device.serial = "Trust_Webcam_Trust_Webcam_Trust_Webcam"
device.form_factor = "webcam"
device.string = "1"
device.description = "Camera"
module-udev-detect.discovered = "1"
device.icon_name = "camera-web-usb"
profiles:
input:analog-mono: Analog Mono Input (priority 7, available: unknown)
off: Off (priority 0, available: unknown)
active profile: <input:analog-mono>
sources:
alsa_input.usb-Trust_Webcam_Trust_Webcam_Trust_Webcam-02.analog-mono/#0: Camera Analog Mono
ports:
analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown)
properties:
device.icon_name = "audio-input-microphone"
lspci
$ lspci | grep -i audio
00:1b.0 Audio device: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller (rev 05)
01:00.1 Audio device: NVIDIA Corporation GK107 HDMI Audio Controller (rev a1)
详细的lspci
$ sudo lspci -nnk | grep -A2 Audio
00:1b.0 Audio device [0403]: Intel Corporation 8 Series/C220 Series
Chipset High Definition Audio Controller [8086:8c20] (rev 05)
Subsystem: Hewlett-Packard Company 8 Series/C220 Series Chipset High Definition Audio Controller [103c:1905]
Kernel driver in use: snd_hda_intel
Kernel modules: snd_hda_intel
--
01:00.1 Audio device [0403]: NVIDIA Corporation GK107 HDMI Audio
Controller [10de:0e1b] (rev a1)
Subsystem: Hewlett-Packard Company GK107 HDMI Audio Controller [103c:094b]
Kernel driver in use: snd_hda_intel
Kernel modules: snd_hda_intel
我想在后台启动一个任务并将所有输出重定向到一个文件。为此,我这样做./main.py > /tmp/logsFile 2>&1 &
但我不工作我认为问题来自后台任务,当我这样做但不在后台时,它可以工作!在后台时的问题是文件已创建但为空,我的机器人总是在连接处返回内容,因此文件不应该为空!我在 i3 上有一个带有 Ubuntu 18.04 LTS 的 MSI CX62 6QD 249XFR
编辑:上面的命令适用于带有 echo 的基本 .sh 但不适用于 main.py
pacmd list-clients
显示应用程序,pacmd list-sinks
显示设备,GUI 工具pavucontrol
可以将应用程序分配给设备。
分配设备的命令是什么?
例如,脚本应该能够自动进行这样的设置:在客户端之间使用 grep for firefox,创建虚拟输入/输出设备,将 firefox 分配给它们,完成后销毁设备。
我想逐行列出nginx服务器的所有模块,所以我输入以下内容:
nginx -V | tr -- - '\n'
但它不会将模块排成一行。如果我这样做:
2>&1 nginx -V | tr -- - '\n'
有用。但为什么?