Browse Source

Update ctl scripts and formatting

master
Riyyi 4 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 #!/bin/sh
# Dependencies:
# castnow-git
# mkvtoolnix-cli
# jq
FILE_NAME="$1" FILE_NAME="$1"
TRACKS="$(mkvmerge -J "$FILE_NAME" | jq -c ' TRACKS="$(mkvmerge -J "$FILE_NAME" | jq -c '

101
.scripts/inputctl.sh

@ -1,5 +1,8 @@
#!/bin/sh #!/bin/sh
# Control the input devices
# Depends: xinput, setxkbmap
help() { help() {
B=$(tput bold) B=$(tput bold)
U=$(tput smul) U=$(tput smul)
@ -7,36 +10,27 @@ help() {
cat << EOF cat << EOF
${B}NAME${N} ${B}NAME${N}
inputctl.sh - input manager inputctl.sh - control the input devices
${B}SYNOPSIS${N} ${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}OPTIONS${N}
${B}-h${N} ${B}-h${N} Display usage message and exit.
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}-s${N} [${U}ARG${N}] ${B}-d${N} ${U}STATE${N}
Perform action on touchscreen. Set touchpad state, possible values: toggle, on/off, 1/0.
${B}ARGS${N} ${B}-k${N} ${U}STATE${N}
toggle Set keyboard state, possible values: toggle, on/off, 1/0.
Toggle input device / keyboard customizations.
on ${B}-s${N} ${U}STATE${N}
Enable input device / keyboard customizations. Set touchscreen state, possible values: toggle, on/off, 1/0.
off
Disable input device / keyboard customizations.
EOF EOF
} }
setxkbmap -option caps:swapescape
# Exit if no option is provided # Exit if no option is provided
[ "$#" -eq 0 ] && help && exit 1 [ "$#" -eq 0 ] && help && exit 1
@ -50,16 +44,21 @@ while getopts ':h?d:k:s:' opt; do
case $opt in case $opt in
h) h)
help help
exit 1 exit 0
;; ;;
d) d)
dev="SYNA3602:00 0911:5288 Touchpad" OPTION="d"
ARG="$OPTARG"
DEV="SYNA3602:00 0911:5288 Touchpad"
;; ;;
k) k)
dev="Keyboard" OPTION="k"
ARG="$OPTARG"
;; ;;
s) s)
dev="pointer:04F3200A:00 04F3:2373" OPTION="s"
ARG="$OPTARG"
DEV="pointer:04F3200A:00 04F3:2373"
;; ;;
:) :)
echo "$SCRIPT: option requires an argument '$OPTARG'" echo "$SCRIPT: option requires an argument '$OPTARG'"
@ -75,8 +74,27 @@ while getopts ':h?d:k:s:' opt; do
done done
toggle_device() { toggle_device() {
STATUS=$(xinput --list-props "$dev" | awk '/Device Enabled/ { print $4 }') STATUS=$(xinput --list-props "$2" | awk '/Device Enabled/ { print $4 }')
[ "$STATUS" -eq 1 ] && xinput --disable "$dev" || xinput --enable "$dev" [ "$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() { keyboard() {
@ -105,23 +123,18 @@ keyboard() {
fi fi
} }
# Command handling # Option execution
[ $OPTIND -ge 2 ] && shift $((OPTIND - 2)) # if [ "$DEV" = "Keyboard" ]; then
if [ "$dev" = "Keyboard" ]; then # keyboard "$ARG"
keyboard "$1" # else
else case "$OPTION" in
case "$1" in d | s)
toggle) device "$ARG" "$DEV"
toggle_device ;;
;; k)
on) keyboard "$ARG"
xinput --enable "$dev" ;;
;; esac
off)
xinput --disable "$dev"
;;
esac
fi
# Useful input diagnostics packages: # Useful input diagnostics packages:
# - xinput # - xinput
@ -130,5 +143,3 @@ fi
# #
# - setxkbmap -query # - setxkbmap -query
# - xmodmap -pke # - 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 EOF
} }
# If no option is provided # Exit if no option is provided
[ "$#" -eq 0 ] && help && exit 1 [ "$#" -eq 0 ] && help && exit 1
# Set required X variables
export DISPLAY=:0
export XAUTHORITY="$XDG_DATA_HOME/xorg/Xauthority"
update() { update() {
sleep 4 sleep 4
@ -61,7 +65,7 @@ auto() {
xrandr --addmode "$4" "$1x$2_$3.00" xrandr --addmode "$4" "$1x$2_$3.00"
fi fi
# Get all connected monitor # Get all connected monitors
CONNECTED="$(xrandr -q | awk '/ connected/{print $1}')" CONNECTED="$(xrandr -q | awk '/ connected/{print $1}')"
# Disable all other monitors # Disable all other monitors
@ -72,11 +76,13 @@ auto() {
update update
} }
[ $OPTIND -ge 2 ] && shift $((OPTIND - 2))
case "$1" in case "$1" in
a*) a*)
auto "$@" auto "$@"
;; ;;
*) *)
help help
exit 1
;; ;;
esac esac

34
.scripts/netctl.sh

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

Loading…
Cancel
Save