Udev rules for discharging battery

Hi there,
I'm trying to define a udev rule that triggers a script of mine at a certain level of battery charge (e.G. five percent). Unfortunately nothing happens (cross-checked the x-bit and typos already)
low-battery.rules:
KERNEL=="BAT0", ATTR{status}=="Discharging", ATTR{capacity}=="5", RUN+="/usr/local/bin/backlight"
That's the part of udevadm I took as a ref point for the rules file:
looking at device '/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0':
    KERNEL=="BAT0"
    SUBSYSTEM=="power_supply"
    DRIVER==""
    ATTR{type}=="Battery"
    ATTR{alarm}=="0"
    ATTR{charge_full_design}=="2261000"
    ATTR{current_now}=="2945000"
    ATTR{charge_now}=="1244000"
    ATTR{charge_full}=="2261000"
    ATTR{capacity}=="55"
    ATTR{status}=="Charging"
    ATTR{voltage_now}=="11549000"
    ATTR{model_name}=="Primary"
    ATTR{manufacturer}=="Hewlett-Packard"
    ATTR{technology}=="Li-ion"
    ATTR{cycle_count}=="0"
    ATTR{voltage_min_design}=="10800000"
    ATTR{serial_number}=="26362 2013/05/10"
    ATTR{present}=="1"

I don't think that most computers send events when the battery percentage changes.  I think it might be better to simply run a cron job that checks for battery level and reacts accordingly (or a systemd.timer).

Similar Messages

  • UDEV rules for Xilinx FPGA devices

    I recently purchased a Digilent Nexys3 FPGA board with a Xilinx Spartan 5 FPGA on it. I finally got around to finding some time to using it, and setting up the development environment under Arch linux.
    After spending ages reading around about various problems and workarounds, I finally managed to get Xilinx ISE Webpack installed and working, as well as Digilent Adept software for downloading the designs to the development board. One issue still remains though. I am unable to download the designs to the FPGA as a normal user, but only as root.
    I'm pretty sure this is a udev rules problem. Digilent supplies a rules file (attached below) which is supposed to grant permissions to all users to access the FPGA devices over USB. I placed this rule file under /etc/udev/rules.d, but I am still unable to access the devices as normal user due to the following error:
    $ djtgcfg enum
    libusb couldn't open USB device /dev/bus/usb/001/003: Permission Denied.
    libusb requires write access to USB device nodes.
    $
    I believe that udev rules syntax changed since the last time I had a look at it, so maybe the supplied rules file still uses the old syntax? Any suggestions to fixing this rules file (attached below)?
    # 52-digilent-usb.rules -- UDEV rules for Digilent USB Devices #
    # Author: MTA #
    # Copyright 2010 Digilent Inc. #
    # File Description: #
    # This file contains the rules used by UDEV when creating entries for #
    # Digilent USB devices. In order for Digilent's shared libraries and #
    # applications to access these devices without root privalages it is #
    # necessary for UDEV to create entries for which all users have read #
    # and write permission. #
    # Usage: #
    # Copy this file to "/etc/udev/rules.d/" and execute #
    # "/sbin/udevcontrol reload_rules" as root. This only needs to be done #
    # immediately after installation. Each time you reboot your system the #
    # rules are automatically loaded by UDEV. #
    # Revision History: #
    # 04/15/2010(MTA): created #
    # 02/28/2011(MTA): modified to support FTDI based devices #
    # Create "/dev" entries for Digilent device's with read and write
    # permission granted to all users.
    SYSFS{idVendor}=="1443", MODE="666"
    ACTION=="add", SYSFS{idVendor}=="0403", SYSFS{manufacturer}=="Digilent", MODE="666", RUN+="/usr/local/sbin/dftdrvdtch %s{busnum} %s{devnum}"
    # The following rules (if present) cause UDEV to ignore all UEVENTS for
    # which the subsystem is "usb_endpoint" and the action is "add" or
    # "remove". These rules are necessary to work around what appears to be a
    # bug in the Kernel used by Red Hat Enterprise Linux 5/CentOS 5. The Kernel
    # sends UEVENTS to remove and then add entries for the endpoints of a USB
    # device in "/dev" each time a process releases an interface. This occurs
    # each time a data transaction occurs. When an FPGA is configured or flash
    # device is written a large number of transactions take place. If the
    # following lines are commented out then UDEV will be overloaded for a long
    # period of time while it tries to process the massive number of UEVENTS it
    # receives from the kernel. Please note that this work around only applies
    # to systems running RHEL5 or CentOS 5 and as a result the rules will only
    # be present on those systems.
    Thanks!
    -Igor
    Last edited by UQ-igor (2011-12-24 03:56:10)

    Try this
    Use ATTR or ATTRS.
    -SYSFS{idVendor}=="1443", MODE="666"
    -ACTION=="add", SYSFS{idVendor}=="0403", SYSFS{manufacturer}=="Digilent", MODE="666", RUN+="/usr/sbin/dftdrvdtch %s{busnum} %s{devnum}"
    +ATTRS{idVendor}=="1443", MODE="666"
    +ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{manufacturer}=="Digilent", MODE="666", RUN+="/usr/sbin/dftdrvdtch %s{busnum} %s{devnum}"
    +ATTR{idVendor}=="1443", MODE="666"
    +ACTION=="add", ATTR{idVendor}=="0403", ATTR{manufacturer}=="Digilent", MODE="666", RUN+="/usr/sbin/dftdrvdtch %s{busnum} %s{devnum}"

  • [SOLVED]system fails to boot since adding udev rules for automounting

    Hello
    I have recently been trying to use udev rules to automount, and putting together stuff from the wiki, forums and general googling around have produced the following set of rules:
    # automounts usb hdd and pendrives as usbhd-sdx; no messing around with
    # volume labels or other confusing stuff
    # matches all sdx devices except the internal hdd, sda
    KERNEL=="sd[b-z]", NAME="%k", SYMLINK+="usbhd-%k", GROUP="users", OPTIONS="last_rule"
    # imports filesystem information
    ACTION=="add", IMPORT{program}="/sbin/blkid -o udev -p %N"
    # creates mount points and sets up symlinks
    ACTION=="add", KERNEL=="sd[b-z][0-9]", SYMLINK+="usbhd-%k", GROUP="users", NAME="%k"
    ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mkdir -p /media/usbhd-%k"
    ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/ln -s /media/usbhd-%k /mnt/usbhd-%k"
    # global mount options
    ACTION=="add", ENV{mount_options}="relatime"
    # filesystem-specific mount options (777/666 dir/file perms for ntfs/vfat)
    ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},gid=100,dmask=000,fmask=111,utf8"
    # automount ntfs filesystem with ntfs-3g driver
    ACTION=="add", KERNEL=="sd[b-z][0-9]", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/mount -t ntfs-3g -o %E{mount_options} /dev/%k /media/usbhd-%k", OPTIONS="last_r$
    # automount all other file systems
    ACTION=="add", KERNEL=="sd[b-z][0-9]", ENV{ID_FS_TYPE}!="ntfs", RUN+="/bin/mount -t auto -o %E{mount_options} /dev/%k /media/usbhd-%k", OPTIONS="last_rule"
    # unmounts and removes the mount points
    ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rm -f /mnt/usbhd-%k"
    ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/umount -l /media/usbhd-%k"
    ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rmdir /media/usbhd-%k", OPTIONS="last_rule"
    This seemed to be working very well unitl I tried to boot this morning and the boot process stopped at "processing UDev events" with the following message:
    iTCO_wdt: Unexpected close, not stopping watchdog!
    It pauses at this point for 10-15 seconds and then reboots.
    Having searched a bit, I found the following similar post on the forums:  http://bbs.archlinux.org/viewtopic.php?pid=459375
    Which suggests that the problem might lie with this line:
    ACTION=="add", IMPORT{program}="/sbin/blkid -o udev -p %N"
    I have renamed the file so that it no longer has the udev .rules extension and now the system boots fine.  Does anyone have any suggestions as to why the above rules might be causing this behaviour and how I might go about fixing it?
    Thanks
    Last edited by useradded (2010-07-02 22:58:14)

    Hey falconindy
    That was the final kick up the logical a$$ that I needed to get some kind of grip on udev rules.  I now have a fully functional rule that applies only to /dev/sdxy and not to everything else as well, so no more boot trauma, THANK YOU.
    I will mark this thread as solved and post my new rule for the benefit of anyone who might read this.
    New rule (no boot problems):
    # automounts usb hdd and pendrives as label or as usbhd-sdxy if no label present
    # ensures the following is _only_ run for sdxy devices excluding internal hdd, sda
    KERNEL!="sd[b-z][0-9]", GOTO="personal_usb_automount_settings_end"
    # imports filesystem information
    # provides access to following variables:
    # ID_FS_UUID; ID_FS_UUID_ENC; ID_FS_VERSION; ID_FS_TYPE; ID_FS_VERSION; ID_FS_LABEL
    # accessible via ENV{variable}; $env{variable}|%E{variable}
    IMPORT{program}="/sbin/blkid -o udev -p %N"
    # Get a label if present, otherwise name usbhd-%k
    ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
    ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
    # creates mount points and sets up symlinks
    ACTION=="add", SYMLINK+="%E{dir_name}", GROUP="users", NAME="%k"
    ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}"
    ACTION=="add", RUN+="/bin/ln -s /media/%E{dir_name} /mnt/%E{dir_name}"
    # global mount options
    ACTION=="add", ENV{mount_options}="relatime"
    # filesystem-specific mount options (777/666 dir/file perms for ntfs/vfat)
    ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},gid=100,dmask=000,fmask=111,utf8"
    # automount ntfs filesystem with ntfs-3g driver
    ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/mount -t ntfs-3g -o %E{mount_options} /dev/%k /media/%E{dir_name}", OPTIONS="last_rule"
    # automount all other file systems
    ACTION=="add",ENV{ID_FS_TYPE}!="ntfs", RUN+="/bin/mount -t auto -o %E{mount_options} /dev/%k /media/%E{dir_name}", OPTIONS="last_rule"
    # unmounts and removes the mount points
    ACTION=="remove", RUN+="/bin/rm -f /mnt/%E{dir_name}"
    ACTION=="remove", RUN+="/bin/umount -l /media/%E{dir_name}"
    ACTION=="remove", RUN+="/bin/rmdir /media/%E{dir_name}", OPTIONS="last_rule"
    # exit
    LABEL=="personal_usb_automount_settings_end"
    Last edited by useradded (2010-07-02 22:59:20)

  • Configuring udev rules for Oracle 10g R2 Rac on OEL 5.5 U4 with Qnap

    I'm trying to setup a 10g RAC Cluster following the guide by Jeff Hunter on http://www.idevelopment.info/
    I have to admit, im no Linux admin, and have searched round the net for help with the following Issue.
    I'm trying to set my iSCSI targets to have persistent mappings using udev rules
    This is what I have done so far
    [root@racnode1 Server]# iscsiadm -m discovery -t sendtargets -p nas-priv | grep 192.168.2.196
    192.168.2.196:3260,1 iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote1.c59a2d
    192.168.2.196:3260,1 iqn.2004-04.com.qnap:ts-459:iscsi.racdbfra2.c59a2d
    192.168.2.196:3260,1 iqn.2004-04.com.qnap:ts-459:iscsi.racdbdata2.c59a2d
    192.168.2.196:3260,1 iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote2.c59a2d
    192.168.2.196:3260,1 iqn.2004-04.com.qnap:ts-459:iscsi.racdbcrs2.c59a2d
    192.168.2.196:3260,1 iqn.2004-04.com.qnap:ts-459:iscsi.racdbcrs1.c59a2d
    192.168.2.196:3260,1 iqn.2004-04.com.qnap:ts-459:iscsi.racdbdata1.c59a2d
    192.168.2.196:3260,1 iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote3.c59a2d
    192.168.2.196:3260,1 iqn.2004-04.com.qnap:ts-459:iscsi.racdbfra1.c59a2d
    -- Manually Log into iSCSI Targets
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote1.c59a2d -p 192.168.2.196 -l
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbfra2.c59a2d -p 192.168.2.196 -l
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbdata2.c59a2d -p 192.168.2.196 -l
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote2.c59a2d -p 192.168.2.196 -l
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbcrs2.c59a2d -p 192.168.2.196 -l
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbcrs1.c59a2d -p 192.168.2.196 -l
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbdata1.c59a2d -p 192.168.2.196 -l
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote3.c59a2d -p 192.168.2.196 -l
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbfra1.c59a2d -p 192.168.2.196 -l
    -- Make iSCSI Targets Automatically Login
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote1.c59a2d -p 192.168.2.196 --op update -n node.startup -v automatic
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbfra2.c59a2d -p 192.168.2.196 --op update -n node.startup -v automatic
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbdata2.c59a2d -p 192.168.2.196 --op update -n node.startup -v automatic
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote2.c59a2d -p 192.168.2.196 --op update -n node.startup -v automatic
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbcrs2.c59a2d -p 192.168.2.196 --op update -n node.startup -v automatic
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbcrs1.c59a2d -p 192.168.2.196 --op update -n node.startup -v automatic
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbdata1.c59a2d -p 192.168.2.196 --op update -n node.startup -v automatic
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote3.c59a2d -p 192.168.2.196 --op update -n node.startup -v automatic
    iscsiadm -m node -T iqn.2004-04.com.qnap:ts-459:iscsi.racdbfra1.c59a2d -p 192.168.2.196 --op update -n node.startup -v automatic
    -- Create Persistent Local SCSI Device Names
    - Identify Mappings
    [root@racnode1 ~]# (cd /dev/disk/by-path; ls -l qnap | awk '{FS=" "; print $9 " " $10 " " $11}')
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbcrs1.c59a2d-lun-0 -> ../../sdg
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbcrs2.c59a2d-lun-0 -> ../../sdf
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbdata1.c59a2d-lun-0 -> ../../sdi
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbdata2.c59a2d-lun-0 -> ../../sdd
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbfra1.c59a2d-lun-0 -> ../../sdj
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbfra2.c59a2d-lun-0 -> ../../sdc
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote1.c59a2d-lun-0 -> ../../sdb
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote2.c59a2d-lun-0 -> ../../sde
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote3.c59a2d-lun-0 -> ../../sdh
    - Create Rules File
    cat >> /etc/udev/rules.d/55-openiscsi.rules <<EOF
    # /etc/udev/rules.d/55-openiscsi.rules
    KERNEL=="sd*", BUS=="scsi", PROGRAM="/etc/udev/scripts/iscsidev.sh %b",SYMLINK+="iscsi/%c/part%n"
    EOF
    - Create Shell Script
    mkdir -p /etc/udev/scripts
    vi /etc/udev/scripts/iscsidev.sh
    #!/bin/sh
    # FILE: /etc/udev/scripts/iscsidev.sh
    BUS=${1}
    HOST=${BUS%%:*}
    [ -e /sys/class/iscsi_host ] || exit 1
    file="/sys/class/iscsi_host/host${HOST}/device/session*/iscsi_session*/targetname"
    target_name=$(cat ${file})
    # This is not an open-scsi drive
    if [ -z "${target_name}" ]; then
    exit 1
    fi
    # Check if QNAP drive
    check_qnap_target_name=${target_name%%:*}
    if [ $check_qnap_target_name = "iqn.2004-04.com.qnap" ]; then
    target_name=`echo "${target_name%.*}"`
    fi
    echo "${target_name##*.}"
    chmod 755 /etc/udev/scripts/iscsidev.sh
    service iscsi stop
    service iscsi start
    [root@racnode1 ~]# ls /dev/iscsi/*
    ls: /dev/iscsi/*: No such file or directory
    1.) For some reason I cannot get the mappings to work correctly, I have rebooted the server and tried a number of different changes in the rules script. But for the life of me I cannot get it work.
    I noticed when I rebooted the server that it failed to execute the iscsidev. When I manually run the shell script with a parameter it produces output
    Can anyone help me to get this up and running?
    2.) My QNAP Nas doesnt seem to publish iSCSI targets to only one NIC. I think this is down to the firmware/feature not being available. When I discover targets I get the following
    [root@racnode1 ~]# (cd /dev/disk/by-path; ls -l *qnap* | awk '{FS=" "; print $9 " " $10 " " $11}')
    ip-192.168.1.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbcrs1.c59a2d-lun-0 -> ../../sdh
    ip-192.168.1.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbcrs2.c59a2d-lun-0 -> ../../sdm
    ip-192.168.1.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbdata1.c59a2d-lun-0 -> ../../sdn
    ip-192.168.1.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbdata2.c59a2d-lun-0 -> ../../sde
    ip-192.168.1.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbfra1.c59a2d-lun-0 -> ../../sdr
    ip-192.168.1.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbfra2.c59a2d-lun-0 -> ../../sdd
    ip-192.168.1.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote1.c59a2d-lun-0 -> ../../sdb
    ip-192.168.1.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote2.c59a2d-lun-0 -> ../../sdk
    ip-192.168.1.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote3.c59a2d-lun-0 -> ../../sdp
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbcrs1.c59a2d-lun-0 -> ../../sdi
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbcrs2.c59a2d-lun-0 -> ../../sdg
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbdata1.c59a2d-lun-0 -> ../../sdo
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbdata2.c59a2d-lun-0 -> ../../sdj
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbfra1.c59a2d-lun-0 -> ../../sds
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbfra2.c59a2d-lun-0 -> ../../sdf
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote1.c59a2d-lun-0 -> ../../sdc
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote2.c59a2d-lun-0 -> ../../sdl
    ip-192.168.2.196:3260-iscsi-iqn.2004-04.com.qnap:ts-459:iscsi.racdbvote3.c59a2d-lun-0 -> ../../sdq
    It shows the same targets on both NIC's, I only need them on the private ip 192.168.2.196
    Edited by: user1728822 on 07-May-2011 15:53
    Edited by: user1728822 on 07-May-2011 16:08

    Hi,
    I'm facing the same issue.. If your issue is fixed..could you please let me know?
    I'm trying to configure 11g RAC with OPenfiler and got stuck here.
    Regards,
    Kumar

  • [solved] My udev rule for my Android phone doesn't work, not sure why

    I have the HTC G1 Android phone and I'm trying to get a udev rule working for it.  This is my rule ...
    /etc/udev/rules.d/50-android.rules
    SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0bb4", MODE="0666", NAME=="android"
    ... but when I connect my phone, /dev/android doesn't appear.  0bb4 is correct ...
    /sys/class/usb_device/usbdev5.2/device/idVendor
    0bb4
    ... so what's going on?
    Last edited by synthead (2008-11-28 15:19:09)

    There is, but I can already use it that way.  I'm learning how to code in java so I can develop applications for it.  There's a feature in the SDK where you can install and run your code on your Android device fairly seamlessly.  You literally hit "Run" and a few moments later, your phone's going to town.  But for this to work, permissions need to be set (0666).  But my udev rule does nothing and I dont understand why.
    This is where I got this information: http://code.google.com/android/intro/de … cehardware

  • Udev Rules for Monitors

    So I've got a bit of a fluid monitor setup.  Three different screens with three different configurations that are switched among rather often.  I wrote a script using xrandr to handle this, and it works very well when it gets called.  I thought it would be really nice to have it automated whenever I plugged in or unplugged a monitor, so I took a look with udevadm, and it spits out the same two events when I plug/unplug my VGA monitor.
    KERNEL[44363.562487] change /devices/pci0000:00/0000:00:02.0/drm/card1 (drm)
    UDEV [44363.572260] change /devices/pci0000:00/0000:00:02.0/drm/card1 (drm)
    udevadm --query=all --path=/devices/pci0000:00/0000:00:02.0/drm/card1 (drm)
    P: /devices/pci0000:00/0000:00:02.0/drm/card1
    N: dri/card1
    E: DEVNAME=/dev/dri/card1
    E: DEVPATH=/devices/pci0000:00/0000:00:02.0/drm/card1
    E: DEVTYPE=drm_minor
    E: MAJOR=226
    E: MINOR=1
    E: SUBSYSTEM=drm
    E: TAGS=:udev-acl:
    E: UDEV_LOG=3
    E: USEC_INITIALIZED=18414634
    Based on that information, I made a udev rule that I thought would do exactly what I wanted.
    KERNEL=="dri/card1", ACTION=="change", RUN+="/usr/bin/monfix"
    Unfortunately, nothing happens.
    I've never messed with udev before, and I learned a lot in this effort, but I seem to be doing something wrong here, and I can't quite figure out what it is.  Can someone point this out for me?

    Try this
    Use ATTR or ATTRS.
    -SYSFS{idVendor}=="1443", MODE="666"
    -ACTION=="add", SYSFS{idVendor}=="0403", SYSFS{manufacturer}=="Digilent", MODE="666", RUN+="/usr/sbin/dftdrvdtch %s{busnum} %s{devnum}"
    +ATTRS{idVendor}=="1443", MODE="666"
    +ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{manufacturer}=="Digilent", MODE="666", RUN+="/usr/sbin/dftdrvdtch %s{busnum} %s{devnum}"
    +ATTR{idVendor}=="1443", MODE="666"
    +ACTION=="add", ATTR{idVendor}=="0403", ATTR{manufacturer}=="Digilent", MODE="666", RUN+="/usr/sbin/dftdrvdtch %s{busnum} %s{devnum}"

  • [solved] udev-rules for bluetooth PCMCIA

    My plan:
    get my bluetooth-PCMCIA card to work:
    CONCEPTONIC CBT100C
    Problem:
    I have to issue the following command for it to work:
    #hciattach ttyS0 bcsp
    Therefor I wrote following udev-rule that doesn't work:
    ##/etc/udev/rules.d/05-bluez-pcmcia-support.rules
    SUBSYSTEMS=="pcmcia", ATTRS{prod_id2}=="Bluetooth Card", RUN+="/usr/sbin/hciattach ttyS0 bcsp"
    My Question:
    Could someone explain to me why this rule does not work?
    Info:
    #pccardctl info
    PRODID_1="PCMCIA"
    PRODID_2="Bluetooth Card"
    PRODID_3=""
    PRODID_4=""
    MANFID=0279,950b
    FUNCID=2
    after #hciattach ttyS0 bcsp
    #udevinfo -a -p /sys/devices/pci0000\:00/0000\:00\:1e.0/0000\:06\:09.0/0.0/tty/ttyS0/
    KERNEL=="ttyS0"
    SUBSYSTEM=="tty"
    DRIVER==""
    ATTR{dev}=="4:64"
    looking at parent device '/devices/pci0000:00/0000:00:1e.0/0000:06:09.0/0.0/tty':
    KERNELS=="tty"
    SUBSYSTEMS==""
    DRIVERS==""
    looking at parent device '/devices/pci0000:00/0000:00:1e.0/0000:06:09.0/0.0':
    KERNELS=="0.0"
    SUBSYSTEMS=="pcmcia"
    DRIVERS=="serial_cs"
    ATTRS{modalias}=="pcmcia:m0279c950Bf02fn00pfn00pa281F1C5Dpb7664FB1Dpc00000000pd00000000"
    ATTRS{prod_id2}=="Bluetooth Card"
    ATTRS{prod_id1}=="PCMCIA"
    ATTRS{card_id}=="0x950b"
    ATTRS{manf_id}=="0x0279"
    ATTRS{func_id}=="0x02"
    ATTRS{pm_state}=="on"
    ATTRS{function}=="0x00"
    looking at parent device '/devices/pci0000:00/0000:00:1e.0/0000:06:09.0':
    KERNELS=="0000:06:09.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="yenta_cardbus"
    ATTRS{msi_bus}=="1"
    ATTRS{broken_parity_status}=="0"
    ATTRS{enable}=="2"
    ATTRS{modalias}=="pci:v00001180d00000476sv0000144Dsd0000C01Ebc06sc07i00"
    ATTRS{local_cpus}=="f"
    ATTRS{irq}=="16"
    ATTRS{class}=="0x060700"
    ATTRS{subsystem_device}=="0xc01e"
    ATTRS{subsystem_vendor}=="0x144d"
    ATTRS{device}=="0x0476"
    ATTRS{vendor}=="0x1180"
    looking at parent device '/devices/pci0000:00/0000:00:1e.0':
    KERNELS=="0000:00:1e.0"
    SUBSYSTEMS=="pci"
    DRIVERS==""
    ATTRS{msi_bus}=="1"
    ATTRS{broken_parity_status}=="0"
    ATTRS{enable}=="1"
    ATTRS{modalias}=="pci:v00008086d00002448sv00000000sd00000000bc06sc04i01"
    ATTRS{local_cpus}=="f"
    ATTRS{irq}=="0"
    ATTRS{class}=="0x060401"
    ATTRS{subsystem_device}=="0x0000"
    ATTRS{subsystem_vendor}=="0x0000"
    ATTRS{device}=="0x2448"
    ATTRS{vendor}=="0x8086"
    looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""
    #dmesg
    pccard: PCMCIA card inserted into slot 0
    cs: memory probe 0xb4000000-0xb40fffff: excluding 0xb4000000-0xb400ffff
    pcmcia: registering new device pcmcia0.0
    ttyS0: detected caps 00000700 should be 00000100
    0.0: ttyS0 at I/O 0x400 (irq = 3) is a 16C950/954
    Last edited by mehldutt (2007-08-07 18:04:37)

    I called it
    05-bluez-pcmcia-support.rules
    I rebooted but still no success.
    I also tried this:
    ACTION=="add", SUBSYSTEMS=="pcmcia", ATTRS{prod_id2}=="Bluetooth Card", RUN+="aplay /usr/share/sounds/phone.wav"
    But still no success

  • Udev rules for dvd/cd automounting?

    This came up elsewhere and I got curious. In my long absence from caring about fstab, I mistakenly though that uncommenting the dvd and cd lines would get to an automount situation. I realize that this is incorrect. I started to study the udev rules that I got here in the forums for automounting removable devices and I'm wondering how to adapt it to cd and dvd drives. Any thoughts?
    -- Edit --
    It seems like this is what /etc/udev/rules.d/75-cd-aliases-generator.rules.optional is supposed to be doing, but it's not. I'm missing something.

    I think the initramfs brings up the internal hard drives before it starts udev, so the "add" event that makes it mount stuff is never called.
    If you want to automatically mount a filesystem on boot (especially if it's on a non-removable medium), you should add an entry for it to /etc/fstab instead of relying on udev to mount it.
    Here's the wiki article for fstab.  Should be all you need.
    Last edited by alexandrite (2010-07-23 04:55:10)

  • Udev rules for a modem

    The following udev rule was given to me last February to get a friends dial-up working:
    KERNEL=="ttyS[0-9]", NAME=="%k", MODE=="0660", GROUP=="tty", SYMLINK+="modem"
    I have just updated the system and I am aware that the udev rules have changed. It is not an area that I usually venture into. What is now needed to achieve a suitable device creation at boot-up to have the modem recognised?
    Thanks.

    Thanks byte. This got rid of the messages but didn't solve the connection problem    I have now reverted back to the orginal options file as this does match the old one. This is really strange. I created a separate partition and rsynced the original Arch install across and updated grub. I then updated one installation and left the other alone just in case I ran into problems. As it happened the upgrade went fine and both old and new installations run fine except the dial-up on neither works    I am now beginning to think it might be a problem with the ISP (uklinux.net), but their website does not suggest any status issues.
    I went back through the errors.log on the old installation and found that the:
    Dec 28 18:27:51 hollowood pppd[3498]: Cannot determine ethernet address for proxy ARP
    always occurs and does not stop the connection. I have checked the /etc/rc.conf as I had to make some changes in connecting and disconnecting to my network and have got rid of the other messages that way.  There are no other error messages and wvdial runs through the connection and disconnection process perfectly. Is there anything else I could have overlooked or could this be problems with the ISP?

  • [SOLVED] udev rules for U2F FIDO Plug-up key

    I just received a cheap U2F FIDO key (http://www.amazon.com/Plug-up-Internati … 00OGPO3ZS/) but couldn't use it under Chrome 38. I had to add the following rule to /etc/udev/rules.d/45-u2f.rules
    SUBSYSTEM=="hidraw", MODE="0666", ATTRS{idVendor}=="2581", ATTRS{idProduct}=="f1d0"
    and then issued a
    # sudo udevadm trigger
    Should work with other vendors assuming you change the idVendor and idProduct.
    Have fun!

    LukeHandle wrote:Was thinking about the same device, what are you thoughts on it so far? I was mostly concerned with the price and how that translated to the quality, or lack thereof.
    The device for which I sent a link for is cheap one and when you receive it actually looks cheap but does the job. Initially I thought I needed to install the FIDO U2F Chrome extension https://chrome.google.com/webstore/deta … ionmgcdmne but it works just fine without it assuming you are using Chrome or Chromium 38+ and the above udev rule on ArchLinux (not required on Windows and MAC OS).
    Use case is fairly limited so far since it can only be used on Google account. I tried to use this Plug-Up U2F dongle on Yubico U2F demo page http://demo.yubico.com/start/u2f/neo but it doesn't work and thus even with the FIDO U2F Chrome extension...Weird since I thought all U2F will all be compatible. Since the protocol is open I hope other use cases will arise such as more major supported websites, easy integration in existing frameworks such as Wordpress, Roundcube... but also alternative uses such as 2nd factor authentication for disk encryption (LUKS).

  • Udev rule for mobile phone

    Hi.
    I want to sync my phone with my laptop but the udev rule don't want to work.
    I did it like descriped here: http://libsyncml.opensync.org/wiki/obex-guide
    # lsusb
    Bus 004 Device 001: ID 0000:0000
    Bus 003 Device 005: ID 0fce:d042 Sony Ericsson Mobile Communications AB
    Bus 003 Device 001: ID 0000:0000
    Bus 002 Device 001: ID 0000:0000
    Bus 001 Device 001: ID 0000:0000
    # vi /etc/udev/rules.d/w810i.rules
    BUS=="usb", SYSFS{idVendor}=="0fce", SYSFS{idProduct}=="d042", MODE="0660", GROUP="users"
    # udevcontrol reload_rules
    But i can't connect as user to the mobile - as root it works as expected.
    Any ideas?
    Thanks, Andreas

    I'm pretty sure it's the same problem as described in comments of this bug report: http://bugs.archlinux.org/task/9935#comment26467
    As a workaround maybe you can substitute the idVendor attribute with another(s).

  • UDev rules not working for MidiSport 2x2 usb midi device

    I installed arch a couple of months ago and am loving it so far.  Any problems I've had so far have already been solved in the forums, but this one's really got me.  I have a MidiSport 2x2 that I want the firmware to be loaded on everytime I plug it in.  I installed (there's not an arch package) a package that is supposed to do just that.  (It's called midisport-firmware-1.2.tar.gz).  However, the package seems to be out of date (2006) and I even had to modify a couple places in the configure script to get it to work with current program revisions.  However, once installed, it does nothing.  It installed firmware files and udev rules for the device into a couple of directories.  When I run the command that is supposed to load the firmware, it works fine.  But for some reason, (I even checked the udev kernel log) it's like the event isn't even being triggered.  Here's part of the original file that came with the package that's supposed to load the firmware:
    # midisport-firmware.rules - udev rules for loading firmware into MidiSport devices
    # DEVPATH=="/*.0" selects interface 0 only
    # (some udev versions don't work with SYSFS{bInterfaceNumber})
    # MidiSport 2x2
    ACTION=="add", SUBSYSTEM=="usb", DEVPATH=="/*.0", ENV{PRODUCT}=="763/1001/*", RUN+="/sbin/fxload -s /usr/local/share/usb/maudio/MidiSportLoader.ihx -I /usr/local/share/usb/maudio/MidiSport2x2.ihx"
    # vim: ft=conf
    And here's what I modified it to in an attempt to make it work:
    # MidiSport 2x2
    ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0763", ATTR{idProduct}=="1001", RUN+="/sbin/fxload -D /dev/%k -s /usr/local/share/usb/maudio/MidiSportLoader.ihx -I /usr/local/share/usb/maudio/MidiSport2x2.ihx"
    I would really appreciate help from anyone who knows about this kind of thing, as I can't figure out what's going wrong.  If it's something wrong with the config, please let me know.  Actually, some HAL events popped up when I was testing this out.  Is it possible HAL is blocking  the udev event somehow?

    Hi,
    The firmware files must be put in /lib/firmware so they can be found by the kernel. Are they being put there?

  • Writing udev rules [SOLVED]

    Hi guys.
    I'm on a mission to run win7 on QEMU, and I also want to be able to use my USB-ports. Now, archwiki tells me to do this:
    $ qemu-system-i386 -usbdevice host:vendor_id:product_id disk_image
    You can find vendor_id and product_id of your device with lsusb command.
    Note: If you encounter permission errors when running QEMU, see Udev#Writing udev rules for information on how to set permissions of the device.
    I then made a file called 10-adm.rules both in, /etc/udev/rules.d and /usr/lib/udev/rules.d
    In it I wrote:
    KERNEL=="sdc[0-9]*",  GROUP="storage"
    My user with wich i lauch QEMU is in the group storage, and my usb always turns out as sdc*.
    But it still gives me the permission erros.
    Last edited by kimbo (2014-11-28 14:06:24)

    now I renamed the files to 99 instead of 10, and I even overkilled it with the GROUP:= instead of GROUP=
    tried:
    udevadm control --reload-rules
    udevadm trigger
    But it still doesnt work
    lsusb gives me:
    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 002 Device 004: ID 18a5:0302 Verbatim, Ltd Flash Drive
    Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 001 Device 002: ID 04f2:b23b Chicony Electronics Co., Ltd
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 004 Device 002: ID 04ca:3002 Lite-On Technology Corp.
    Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    And my qemu-launch-commad it:
    qemu-system-x86_64 -m 1G -enable-kvm -cpu host -usbdevice host:18a5:0302 win7
    oh, I dont really undestand what you by ' the group that /dev/sdc* ends up having'
    Last edited by kimbo (2014-11-13 23:04:47)

  • Udev rules not applied during bootup

    I don't know if this problem is associated with the lates kernel-upgrade to 2.6.21 but I didn't have it before.
    My problem:
    I have an external USB-harddrive that gets mounted everytime I boot because it is listed in my fstab. To avoid confusion with other external storages (such as USB-sticks etc.) I worte an udev rule for it:
    # Externe USB-Festplatte von TrekStor
    BUS=="usb", KERNEL=="sd?1" SYSFS{serial}=="307541703010",SYMLINK+="externe"
    As I've said this worked well before but now I get a message during the booting process saying that /dev/externe couldn't be found. But it actually IS recognised by udev. I just have to do a
    mount -a
    after the booting process and everything works again.
    Does anyone have an idea what the problem could be? It seems to me that all the devices listed in fstab get mounted before the udev rules are applied.

    Ok, I solved my problem: I'm not mounting my USB-HD through fstab anymore. I'm using udev-rules as described here.
    Still I'd be interesting to know what went wrong.
    Last edited by mata_svada (2007-05-21 05:11:06)

  • [SOLVED] automatic usb-backup with udev-rules + script

    I would like to have my usb-harddrive automatically start a backup as soon as it is plugged in.  And finally a bell is supposed to ring.
    I've created an udev-rule and a backup-script as shown below.
    However, instead of creating /dev/backup-drive first something strange is happening:
    The bell rings 3 times, followed by the backup, followed by a 4th ring.
    What's going on?
    Here's may udev-rule:
    ## /etc/udev/rules.d/95-backup.rules
    SUBSYSTEMS=="usb", ATTRS {serial}=="100", SYMLINK=="backup-drive", RUN+="/usr/local/bin/backup-thumb.sh"
    fstab:
    /dev/backup-drive    /media/backup   ext3     rw,user    0 0
    and my script:
    #!/bin/bash
    sleep 10
    rsync -vrtolgh --exclude '/.VirtualBox/' --delete /home/myhome /media/backup-drive
    aplay /usr/share/sounds/phone.wav
    Last edited by mehldutt (2007-07-03 20:28:27)

    The syntax of your udev rule is all wrong - for example after SYMLINK you should use "+=" or ":=". "==" is for comparing to some value.
    I think in rsync command line you want -H not -h (help) option. Also -v (verbose) is useless since you'll never see the output.
    Another thing which will prevent running rsync properly is /media/backup-drive while you use /media/backup in fstab.
    I suggest that you first try running rsync command from the command line "manually" and try if it works at all. After you'll make it work try the below suggestions.
    Another problem: what makes the backup drive mounted under /media/backup directory when you plug it into usb slot ? Are you doing it somehow "manually" in the 10 second period after plugging ? Do you use automounter of some kind ?
    If you intend to use ext3 as the backup drive filesystem you should also add sync command after rsync to make sure no data stays in RAM cache.
    I think you need to read udev manpage first.
    I can also advice you to read my udev rules for automounting usb devices (it's for any type of filesystem and any number of partitions):
    KERNEL=="sd[b-z]", NAME:="%k", SYMLINK+="usbhd-%k", GROUP:="users", OPTIONS="last_rule"
    ACTION=="add", KERNEL=="sd[b-z][0-9]", SYMLINK+="usbhd-%k", GROUP:="users", NAME:="%k"
    ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mkdir -p /media/usbhd-%k"
    ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/ln -s /media/usbhd-%k /mnt/usbhd-%k"
    ACTION=="add", KERNEL=="sd[b-z][0-9]", PROGRAM=="/lib/udev/vol_id -t %N", RESULT=="vfat", RUN+="/bin/mount -t vfat -o rw,noauto,flush,dirsync,noexec,nodev,noatime,dmask=000,fmask=111 /dev/%k /media/
    usbhd-%k", OPTIONS="last_rule"
    ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mount -t auto -o rw,noauto,async,dirsync,noexec,nodev,noatime /dev/%k /media/usbhd-%k", OPTIONS="last_rule"
    ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rm -f /mnt/usbhd-%k"
    ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/umount -l /media/usbhd-%k"
    ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rmdir /media/usbhd-%k", OPTIONS="last_rule"
    I think it could be simplified and modified for your backup device like this:
    SUBSYSTEMS=="usb", ATTRS(idVendor)=="XXXX", ATTRS(idProduct)=="YYYY", KERNEL=="sd[a-z]", NAME:="%k", SYMLINK:="backupdevice", OPTIONS="last_rule"
    SUBSYSTEMS=="usb", ATTRS(idVendor)=="XXXX", ATTRS(idProduct)=="YYYY", ACTION=="add", KERNEL=="sd[a-z]1", SYMLINK:="backuppartition", GROUP:="users", NAME:="%k"
    SUBSYSTEMS=="usb", ATTRS(idVendor)=="XXXX", ATTRS(idProduct)=="YYYY", ACTION=="add", KERNEL=="sd[a-z]1", RUN+="/bin/mount -t auto -o rw,noauto,async,dirsync,noexec,nodev,noatime /dev/%k /media/backup-drive"
    SUBSYSTEMS=="usb", ATTRS(idVendor)=="XXXX", ATTRS(idProduct)=="YYYY", ACTION=="add", KERNEL=="sd[a-z]1", RUN+="/usr/local/bin/backup-thumb.sh", OPTIONS="last_rule"
    SUBSYSTEMS=="usb", ATTRS(idVendor)=="XXXX", ATTRS(idProduct)=="YYYY", ACTION=="remove", KERNEL=="sd[a-z]1", RUN+="/bin/umount -l /media/backup-drive", OPTIONS="last_rule"
    assuming that you have a single partition backup drive formatted as ext3 (or at least it's the first partition).
    Also another assumption is that idVendor and idProduct are unique to your backup drive. If not you should add some extra ATTRS parameters that will ensure this combination is unique.
    The directory /media/backup-drive must already exist (remove your fstab line - it's not needed in this case because mount command is run directly from the udev rule).
    Replace all XXXX and YYYY with the values from lsusb for your backup device - plug it in, run lsusb and copy values which look like XXXX:YYYY near to the name of your backup device.
    Anyway, you can play with different options and try to modify it yourself. The automounting rules work for me very well for some time (including flush option). The backup rules you need to test yourself :-)
    Last edited by lanrat (2007-05-05 17:20:51)

Maybe you are looking for