Results 1 to 5 of 5

Thread: Disable USB for session

  1. #1
    Join Date
    Jul 2012
    Beans
    688
    Distro
    Ubuntu 18.04 Bionic Beaver

    Disable USB for session

    Hi
    I want to disable my two CH devices:

    michael@michael-Ubuntu:~$ sudo lsusb
    Bus 001 Device 002: ID 8087:8008 Intel Corp.
    Bus 002 Device 002: ID 8087:8000 Intel Corp.
    Bus 003 Device 002: ID 046d:c52e Logitech, Inc.
    Bus 003 Device 003: ID 174c:2074 ASMedia Technology Inc.
    Bus 003 Device 004: ID 0b05:17d0 ASUSTek Computer, Inc.
    Bus 003 Device 005: ID 068e:00ff CH Products, Inc. Flight Sim Yoke
    Bus 004 Device 002: ID 174c:3074 ASMedia Technology Inc.
    Bus 003 Device 006: ID 068e:00f2 CH Products, Inc. Flight Sim Pedals
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    michael@michael-Ubuntu:~$


    as it interferes with Metro Last Light. Switch them back on after playing.
    Thanks

  2. #2
    Join Date
    Oct 2008
    Beans
    3,509

    Re: Disable USB for session

    Try this.
    It will disable my usb keyboard. May work for your devices.

    Get your usb id.....
    Code:
    xinput
    Then use...
    Code:
    xinput --disable x
    ...where x is your usb id.

    To enable....
    Code:
    xinput --enable x
    Last edited by stinkeye; November 19th, 2013 at 06:46 PM.

  3. #3
    Join Date
    Oct 2008
    Beans
    3,509

    Re: Disable USB for session

    Been playing around with this and came up with a toggle on/off script.
    The script will toggle my "Nostromo SpeedPad2" gaming keyboard on/off.
    Could adapt it for your device.

    eg this is my xinput...
    Code:
    glen@Raring:~$ xinput --list
    ⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
    ⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
    ⎜   ↳ DEXIN Tt eSPORTS BLACK Gaming mouse     	id=11	[slave  pointer  (2)]
    ⎜   ↳ DEXIN Tt eSPORTS BLACK Gaming mouse     	id=12	[slave  pointer  (2)]
    ⎜   ↳ Honey Bee  Nostromo SpeedPad2           	id=9	[slave  pointer  (2)]
    ⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
        ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
        ↳ Power Button                            	id=6	[slave  keyboard (3)]
        ↳ Power Button                            	id=7	[slave  keyboard (3)]
        ↳ Logitech Logitech USB Headset           	id=10	[slave  keyboard (3)]
        ↳ Ideazon Zboard                          	id=14	[slave  keyboard (3)]
        ↳ Ideazon Zboard                          	id=13	[slave  keyboard (3)]
        ↳ Honey Bee  Nostromo SpeedPad2           	id=8	[slave  keyboard (3)]
    ....and from that output derived this toggle script...
    Code:
    #!/bin/bash
    
    # Script to toggle a usb device on/off
    # This works to disable my Nostromo SpeedPad2 that I only use for gaming.
    # Need to adapt deviceid variable to use your device from the output of "xinput --list"
    
    deviceid=$(xinput --list | awk '/Virtual core keyboard/{y=1;next}y' | grep -m1 "Nostromo" | awk '{print $6}' | tr -d 'id=')
    devicestate=$(xinput --list-props $deviceid | awk '/Device Enabled/ {print $4}') # 0=disabled 1=enabled
    devicename=$(xinput --list --name-only $deviceid)
    
    if [ $devicestate = 0 ]; then
    	xinput --enable $deviceid
    	notify-send -i keyboard "Enabled" "$devicename"
    else
    	xinput --disable $deviceid
    	notify-send -i keyboard "Disabled" "$devicename"
    fi
    If you need help to make the script work for your device
    post the results from...
    Code:
    xinput --list
    Last edited by stinkeye; November 21st, 2013 at 10:11 AM.

  4. #4
    Join Date
    Jul 2012
    Beans
    688
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: Disable USB for session

    michael@michael-Ubuntu:~$ xinput --list
    ⎡ Virtual core pointer id=2 [master pointer (3)]
    ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
    ⎜ ↳ Logitech USB Receiver id=9 [slave pointer (2)]
    ⎣ Virtual core keyboard id=3 [master keyboard (2)]
    ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
    ↳ Power Button id=6 [slave keyboard (3)]
    ↳ Power Button id=7 [slave keyboard (3)]
    ↳ Logitech USB Receiver id=8 [slave keyboard (3)]
    ↳ Eee PC WMI hotkeys id=10 [slave keyboard (3)]
    michael@michael-Ubuntu:~$


    Hmm I don't see my 2 CH devices here. Thanks

  5. #5
    Join Date
    Oct 2008
    Beans
    3,509

    Re: Disable USB for session

    Quote Originally Posted by MikeCyber View Post
    michael@michael-Ubuntu:~$ xinput --list
    ⎡ Virtual core pointer id=2 [master pointer (3)]
    ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
    ⎜ ↳ Logitech USB Receiver id=9 [slave pointer (2)]
    ⎣ Virtual core keyboard id=3 [master keyboard (2)]
    ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
    ↳ Power Button id=6 [slave keyboard (3)]
    ↳ Power Button id=7 [slave keyboard (3)]
    ↳ Logitech USB Receiver id=8 [slave keyboard (3)]
    ↳ Eee PC WMI hotkeys id=10 [slave keyboard (3)]
    michael@michael-Ubuntu:~$


    Hmm I don't see my 2 CH devices here. Thanks
    Oh well, I thought they would show in xinput,
    and the script works so nicely with my gaming pad.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •