Browse Source

Update ctl scripts and formatting

master
Riyyi 5 years ago
parent
commit
c435567d34
  1. 5
      .scripts/cast.sh
  2. 101
      .scripts/inputctl.sh
  3. 10
      .scripts/monctl.sh
  4. 34
      .scripts/netctl.sh

5
.scripts/cast.sh

@ -1,5 +1,10 @@
#!/bin/sh
# Dependencies:
# castnow-git
# mkvtoolnix-cli
# jq
FILE_NAME="$1"
TRACKS="$(mkvmerge -J "$FILE_NAME" | jq -c '

101
.scripts/inputctl.sh

@ -1,5 +1,8 @@
#!/bin/sh
# Control the input devices
# Depends: xinput, setxkbmap
help() {
B=$(tput bold)
U=$(tput smul)
@ -7,36 +10,27 @@ help() {
cat << EOF
${B}NAME${N}
inputctl.sh - input manager
inputctl.sh - control the input devices
${B}SYNOPSIS${N}
${B}inputctl.sh${N} [${U}OPTION${N}] [${U}ARG${N}]
${B}inputctl.sh${N} ${U}OPTION${N} [${U}ARG${N}]
${B}OPTIONS${N}
${B}-h${N}
Display usage message and exit.
${B}-d${N} [${U}ARG${N}]
Perform action on touchpad.
${B}-k${N} [${U}ARG${N}]
Perform action on keyboard.
${B}-h${N} Display usage message and exit.
${B}-s${N} [${U}ARG${N}]
Perform action on touchscreen.
${B}-d${N} ${U}STATE${N}
Set touchpad state, possible values: toggle, on/off, 1/0.
${B}ARGS${N}
toggle
Toggle input device / keyboard customizations.
${B}-k${N} ${U}STATE${N}
Set keyboard state, possible values: toggle, on/off, 1/0.
on
Enable input device / keyboard customizations.
off
Disable input device / keyboard customizations.
${B}-s${N} ${U}STATE${N}
Set touchscreen state, possible values: toggle, on/off, 1/0.
EOF
}
setxkbmap -option caps:swapescape
# Exit if no option is provided
[ "$#" -eq 0 ] && help && exit 1
@ -50,16 +44,21 @@ while getopts ':h?d:k:s:' opt; do
case $opt in
h)
help
exit 1
exit 0
;;
d)
dev="SYNA3602:00 0911:5288 Touchpad"
OPTION="d"
ARG="$OPTARG"
DEV="SYNA3602:00 0911:5288 Touchpad"
;;
k)
dev="Keyboard"
OPTION="k"
ARG="$OPTARG"
;;
s)
dev="pointer:04F3200A:00 04F3:2373"
OPTION="s"
ARG="$OPTARG"
DEV="pointer:04F3200A:00 04F3:2373"
;;
:)
echo "$SCRIPT: option requires an argument '$OPTARG'"
@ -75,8 +74,27 @@ while getopts ':h?d:k:s:' opt; do
done
toggle_device() {
STATUS=$(xinput --list-props "$dev" | awk '/Device Enabled/ { print $4 }')
[ "$STATUS" -eq 1 ] && xinput --disable "$dev" || xinput --enable "$dev"
STATUS=$(xinput --list-props "$2" | awk '/Device Enabled/ { print $4 }')
[ "$STATUS" -eq 1 ] && xinput --disable "$2" || xinput --enable "$2"
}
device() {
case "$1" in
1 | on)
xinput --enable "$2"
;;
0 | off)
xinput --disable "$2"
;;
t*)
toggle_device "$2"
;;
*)
echo "$SCRIPT: invalid argument '$1'"
echo "Try '$SCRIPT -h' for more information."
exit 1
;;
esac
}
keyboard() {
@ -105,23 +123,18 @@ keyboard() {
fi
}
# Command handling
[ $OPTIND -ge 2 ] && shift $((OPTIND - 2))
if [ "$dev" = "Keyboard" ]; then
keyboard "$1"
else
case "$1" in
toggle)
toggle_device
;;
on)
xinput --enable "$dev"
;;
off)
xinput --disable "$dev"
;;
esac
fi
# Option execution
# if [ "$DEV" = "Keyboard" ]; then
# keyboard "$ARG"
# else
case "$OPTION" in
d | s)
device "$ARG" "$DEV"
;;
k)
keyboard "$ARG"
;;
esac
# Useful input diagnostics packages:
# - xinput
@ -130,5 +143,3 @@ fi
#
# - setxkbmap -query
# - xmodmap -pke
#
# Kernel 5.1.4 works properly on my hardware with the i2c_hid module

10
.scripts/monctl.sh

@ -31,9 +31,13 @@ ${B}ARGS${N}
EOF
}
# If no option is provided
# Exit if no option is provided
[ "$#" -eq 0 ] && help && exit 1
# Set required X variables
export DISPLAY=:0
export XAUTHORITY="$XDG_DATA_HOME/xorg/Xauthority"
update() {
sleep 4
@ -61,7 +65,7 @@ auto() {
xrandr --addmode "$4" "$1x$2_$3.00"
fi
# Get all connected monitor
# Get all connected monitors
CONNECTED="$(xrandr -q | awk '/ connected/{print $1}')"
# Disable all other monitors
@ -72,11 +76,13 @@ auto() {
update
}
[ $OPTIND -ge 2 ] && shift $((OPTIND - 2))
case "$1" in
a*)
auto "$@"
;;
*)
help
exit 1
;;
esac

34
.scripts/netctl.sh

@ -17,23 +17,16 @@ ${B}NAME${N}
netctl.sh - control the network interfaces
${B}SYNOPSIS${N}
${B}netctl.sh${N} [${U}OPTION${N}] [${U}COMMAND${N}]
${B}netctl.sh${N} ${U}OPTION${N} [${U}ARG${N}]
${B}OPTIONS${N}
${B}-h${N} Display usage message and exit.
${B}-e${N} [${U}STATE${N}]
Perform action on ethernet.
${B}-e${N} ${U}STATE${N}
Set ethernet ${U}STATE${N}, possible values: on/off, 1/0.
${B}-w${N} [${U}STATE${N}]
Perform action on wireless.
${B}COMMANDS${N}
1, on
Enable selected option.
0, off
Disable selected option.
${B}-w${N} ${U}STATE${N}
Set wireless ${U}STATE${N}, possible values: on/off, 1/0.
EOF
}
@ -50,10 +43,12 @@ while getopts ':h?e:w:' opt; do
exit 0
;;
e)
dev="ethernet"
DEV="ethernet"
ARG="$OPTARG"
;;
w)
dev="wireless"
DEV="wireless"
ARG="$OPTARG"
;;
:)
echo "$SCRIPT: option requires an argument '$OPTARG'"
@ -85,17 +80,16 @@ wireless() {
fi
}
# Command handling
[ $OPTIND -ge 2 ] && shift $((OPTIND - 2))
case "$1" in
# Arg handling
case "$ARG" in
1 | on)
[ "$dev" = "ethernet" ] && ethernet 1 || wireless 1
[ "$DEV" = "ethernet" ] && ethernet 1 || wireless 1
;;
0 | off)
[ "$dev" = "ethernet" ] && ethernet 0 || wireless 0
[ "$DEV" = "ethernet" ] && ethernet 0 || wireless 0
;;
*)
echo "$SCRIPT: invalid command '$1'"
echo "$SCRIPT: invalid argument '$ARG'"
echo "Try '$SCRIPT -h' for more information."
exit 1
;;

Loading…
Cancel
Save