标签: input

Bash 脚本不读取输入

我有一个假设在后台运行命令的脚本,它就是这样做的。问题是当脚本遇到读取命令时,它不会暂停并接受输入。这里是:

printf "Where is yo music?: "
read musicPath

cd $musicPath
ls | while read currentSong;do
  seconds=`mdls "$currentSong"|sed -n '20p'|awk '{print $3}'|cut -d. -f1`
  hours=$((seconds / 3600))
  seconds=$((seconds % 3600))
  minutes=$((seconds / 60))
  seconds=$((seconds % 60))
  echo "Song: $currentSong"
  echo "Length: $hours:$minutes:$seconds"
  afplay "$currentSong"&
  printf "yes (y), no (n), or maybe (m): "
  read choice
  case $choice in
    y)
      mkdir ../Yes
      mv "$currentSong" ../Yes
    ;;
    n)
      mkdir ../No
      mv "$currentSong" ../No
    ;;
    m)
      mkdir ../Maybe
      mv "$currentSong" ../
    ;;
    *) …
Run Code Online (Sandbox Code Playgroud)

shell bash input shell-script

8
推荐指数
1
解决办法
2296
查看次数

通过网络共享键盘作为单独的设备?

我正在尝试实现类似的东西:https : //superuser.com/questions/67659/linux-share-keyboard-over-network

不同之处在于我需要远程键盘与本地键盘分开使用。链接中描述的方法似乎将事件通过管道传输到现有设备文件中。我需要远程键盘在运行时显示为物理(从属)设备xinput list

为什么我需要这个?我想玩一个两人游戏,但我没有外部 USB 键盘,所以我想将远程计算机的按键通过管道传输到一个假设备(这样我可以为每个玩家分配一个设备)。

linux networking keyboard input multiseat

8
推荐指数
1
解决办法
3664
查看次数

如何响应在后台运行的 shell 脚本中的提示?

我正在编写在 HP-UX 服务器上安装软件的脚本。脚本启动后,它会提示我输入安装路径。我需要将路径传递给脚本,以便它可以继续运行。脚本中只有 1 个地方存在这种需求。

脚本中的提示是:按 ENTER 获取默认路径或输入安装软件的路径:

我不想使用默认路径,所以我必须输入一个新路径。但是这个脚本会在后台运行,我需要提供路径。我不确定脚本形式的确切响应。

input shell-script background-process

8
推荐指数
2
解决办法
4万
查看次数

运行 xorg 和 evdev 时的条码扫描器输入

当我在文本控制台(CTRL+ALT+F1 或不运行 X)中扫描条形码时,我得到了正确的输入,但是当我尝试使用在 X 上运行的应用程序时,我没有得到正确的条形码。

扫描仪配置为返回后跟“n”的条形码。在 XI 下只得到“n”,而不是前面的条形码。

我跑了 xev 看看发生了什么。以下是输出的摘录:

> KeyPress event, serial 35, synthetic NO, window 0x6800001,
>     state 0x10, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
> KeyRelease event, serial 35, synthetic NO, window 0x6800001,
>     state 0x18, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
> KeyPress event, serial 35, synthetic NO, window 0x6800001,
>     state 0x10, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
> KeyRelease event, serial 35, synthetic NO, window 0x6800001,
>     state 0x18, …
Run Code Online (Sandbox Code Playgroud)

linux xorg input

7
推荐指数
1
解决办法
1388
查看次数

从命令行获取原始输入(忽略 shell 元字符)

有没有办法stdin在扩展之前或shell对其进行任何操作之前读取原始文本?假设我想运行一个脚本,用户输入一个字符串然后打印出来,我怎样才能得到以下行为:

$ sh test.sh
Please enter a string:
***<><><||&&*&$PATH

You entered:
***<><><||&&*&$PATH
Run Code Online (Sandbox Code Playgroud)

''即使用户没有,有没有办法用所有元字符隐式包围文本或转义所有元字符?

bash input

7
推荐指数
1
解决办法
9943
查看次数

当我在 xorg.conf.d 目录中添加 50-synaptics.conf 文件时 X Server 不会加载

我正在使用 Fedora 18。我正在尝试配置我的突触触摸板,我需要在 Awesome Window Manager 中点击和水平滚动。

我创建了一个包含/etc/X11/xorg.conf.d/50-synaptics.conf以下内容的文件:

Section "InputDevice"
        Identifier "touchpad"
        Driver "synaptics"
        MatchIsTouchpad "on"
        Option "HorizEdgeScroll" "on"
EndSection
Run Code Online (Sandbox Code Playgroud)

但是当我启动系统时,它挂在不同的点上,我经常看到的一个是:

Failed to start Wait for Plymouth Boot Screen to Quit.
See 'systemctl status plymouth-quit-wait.service' for details.
Run Code Online (Sandbox Code Playgroud)

如果您想要日志文件或其他内容,请告诉我如何获取它。

linux fedora xorg input touchpad

7
推荐指数
1
解决办法
573
查看次数

Lubuntu 16.04 xsetwacom:“无法找到输出‘DVI-I-0’。”

我刚买了双显示器,我想限制我的 Wacom 平板电脑只能在一个显示器上绘图。不幸的是,xsetwacom 似乎无法识别 DVI 输入——即使它们在 xrandr 中被列为白天。有任何想法吗?

这是我的控制台输出:

andrewcarr@andrewcarr-desktop:~$ xrandr
Screen 0: minimum 8 x 8, current 3200 x 900, maximum 16384 x 16384
DVI-I-0 connected primary 1600x900+1600+0 (normal left inverted right x axis y axis) 443mm x 249mm
   1600x900      60.00*+
   1440x900      59.89  
   1280x1024     60.02  
   1280x720      60.00  
   1024x768      60.00  
   800x600       60.32  
   640x480       59.94  
DVI-I-1 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)
DVI-D-0 connected 1600x900+0+0 (normal left inverted …
Run Code Online (Sandbox Code Playgroud)

input xrandr lubuntu

7
推荐指数
1
解决办法
2769
查看次数

如何让 Linux 识别身份不明的触摸板?

联想 Yoga 720 有一个触摸板,显示在 lsusb 中,总线 ID 为 06cb:0081。06cb 是 Synaptics 的供应商 ID。除了试图让触摸板在 720 上工作的其他人之外,对该字符串的快速 Google 搜索不会带来任何结果。

这让我相信这是一个新设备。这台机器几个月前才问世,可能没有列在 libinput 或其他一些驱动程序用来匹配设备与其功能的任何设备 ID 表中。我认为通用鼠标模块会提供一些功能,但事实并非如此。

有什么地方可以告诉 Linux 将该总线 ID 与触摸板驱动程序相匹配吗?从我对此所做的阅读来看,似乎触摸板驱动程序通常是在内核级别之外通过 X 服务器完成的,并且通过使用 uinput 的 libinput 完成。

因此,如果有人有任何想法或建议,请分享。

其他一些细节:

与触摸板相关的唯一地方似乎是lsusb

 Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 13d3:5621 IMC Networks 
Bus 001 Device 004: ID 06cb:0081 Synaptics, Inc. 
Bus 001 Device 003: ID 0cf3:e300 Qualcomm Atheros Communications 
Bus 001 Device 007: ID 046d:c245 …
Run Code Online (Sandbox Code Playgroud)

laptop input x11 touchpad

7
推荐指数
1
解决办法
1656
查看次数

如何将命令通过管道传输到后台运行的进程?

这是我的循环程序,在后台运行并等待命令。

#include <iostream>

using namespace std;

char buffer[256];

int main(int argc, char *argv[])
{
    while(true){
     fgets(buffer, 255, stdin);
     buffer[255] = 0;
     if(buffer[0] != '\0'){
        cout << buffer;
        buffer[0] = '\0';
     } 
    }
 return 0;
}
Run Code Online (Sandbox Code Playgroud)

我运行它:

myLoop &
Run Code Online (Sandbox Code Playgroud)

现在,我如何通过管道向这个进程发送命令?

process pipe input

7
推荐指数
3
解决办法
1万
查看次数

CTRL+D 与 CTRL+C

是否真的可以说CTRL+D停止输入执行而CTRL+C停止输出显示(作为纯数据,不执行)?

keyboard-shortcuts input output

7
推荐指数
1
解决办法
6121
查看次数