2017-01-26 20:52:26 +00:00
# xinput, a tool for managing X11 input devices
set -l cmds version list get-feedbacks set-pointer set-mode set-ptr-feedback set-integer-feedback set-button-map query-state list-props set-int-prop set-float-prop set-prop watch-props delete-prop test test -xi2 create-master remove-master reattach float set-cp map-to-output enable disable
function __fish_xinput_devices
2019-05-05 10:53:09 +00:00
# Yeah, this includes a "↳" char
# There's either this or printing only name or id, not both
2020-06-29 04:02:13 +00:00
xinput list --short | string replace -r '^[\W↳]*(.*?)\s+id=([0-9]+).*$' '$2\t$1'
2020-06-30 03:09:20 +00:00
xinput list --short | string replace -r '^[\W↳]*(.*?)\s+id=([0-9]+).*$' '$1'
end
function __fish_xinput_device_props
set -l device $argv [ 1 ]
if test -n " $device "
xinput list-props $device | string replace -rf '\s+(.*?)\s+\((\d+)\).*' '$2\t$1'
xinput list-props $device | string replace -rf '\s+(.*?)\s+\((\d+)\).*' '$1'
end
end
function __fish_xinput_nth_token
set -l n $argv [ 1 ]
2024-01-22 06:42:45 +00:00
set -l tokens ( commandline -cx )
2020-06-30 03:09:20 +00:00
set -e tokens [ 1 ] # remove command name
# remove options
set -l tokens ( string replace -r --filter '^([^-].*)' '$1' -- $tokens )
if set -q tokens [ $n ]
echo $tokens [ $n ]
end
end
2017-01-26 20:52:26 +00:00
complete -c xinput -f -n " not __fish_seen_subcommand_from $cmds " -a " $cmds "
2022-02-09 08:46:07 +00:00
complete -c xinput -f -n "__fish_is_nth_token 2; and __fish_seen_subcommand_from list get-feedbacks set-pointer set-mode set-ptr-feedback set-integer-feedback set-button-map query-state list-props set-int-prop set-float-prop set-prop watch-props" -a "(__fish_xinput_devices)"
complete -c xinput -f -n "__fish_seen_subcommand_from list set-int-prop set-float-prop set-prop watch-props; and not __fish_is_nth_token 2" -xa "(__fish_xinput_device_props (__fish_xinput_nth_token 2))"