a
This commit is contained in:
commit
5b7f65ba34
8
Makefile
Normal file
8
Makefile
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
include config.mk
|
||||||
|
|
||||||
|
all:
|
||||||
|
@echo Run \'make install\'.
|
||||||
|
|
||||||
|
install:
|
||||||
|
install src/tsw $(PREFIX)/bin
|
||||||
|
install src/tsw.conf $(HOME)/.config
|
12
README
Normal file
12
README
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
+ tsw
|
||||||
|
|
||||||
|
A small bash script to switch between tablet mode and laptop mode
|
||||||
|
|
||||||
|
+ Installation
|
||||||
|
|
||||||
|
Run 'make install' as root
|
||||||
|
|
||||||
|
+ Usage
|
||||||
|
|
||||||
|
tsw relies totally on user intervention to run. For example, I use i3blocks on my setup, and I have
|
||||||
|
two different blocks that switch between laptop mode and tablet mode.
|
64
src/tsw
Executable file
64
src/tsw
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# tsw - tablet switcher
|
||||||
|
|
||||||
|
# Load tsw configuration file
|
||||||
|
if [ ! -f "$HOME/.config/tsw.conf" ]; then
|
||||||
|
printf "no configuration file exists, tsw will not run without it\n"
|
||||||
|
printf "please ensure $HOME/.config/tsw.conf exists and is readable\n"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
source $HOME/.config/tsw.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
LOGFILE="/tmp/tsw.log"
|
||||||
|
|
||||||
|
ENABLE=$(xinput enable)
|
||||||
|
DISABLE=$(xinput disable)
|
||||||
|
|
||||||
|
laptop_mode() {
|
||||||
|
ERROR_COUNT=0
|
||||||
|
$ENABLE $KEYBOARD_DEVICE
|
||||||
|
if [ "$?" != 0 ]; then
|
||||||
|
echo "error enabling keyboard device" > $LOGFILE
|
||||||
|
echo "most likely the specified device ID does not exist" > $LOGFILE
|
||||||
|
ERROR_COUNT=$((ERROR_COUNT+1))
|
||||||
|
fi
|
||||||
|
$ENABLE $TRACKPAD_DEVICE
|
||||||
|
if [ "$?" != 0 ]; then
|
||||||
|
echo "error enabling keyboard device" > $LOGFILE
|
||||||
|
echo "most likely the specified device ID does not exist" > $LOGFILE
|
||||||
|
ERROR_COUNT=$((ERROR_COUNT+1))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
tablet_mode() {
|
||||||
|
ERROR_COUNT=0
|
||||||
|
$DISABLE $KEYBOARD_DEVICE
|
||||||
|
if [ "$?" != 0 ]; then
|
||||||
|
echo "error disabling keyboard device" > $LOGFILE
|
||||||
|
echo "most likely the specified device ID does not exist" > $LOGFILE
|
||||||
|
ERROR_COUNT=$((ERROR_COUNT+1))
|
||||||
|
fi
|
||||||
|
$DISABLE $TRACKPAD_DEVICE
|
||||||
|
if [ "$?" != 0 ]; then
|
||||||
|
echo "error disabling trackpad device" > $LOGFILE
|
||||||
|
echo "most likely the specified device ID does not exist" > $LOGFILE
|
||||||
|
ERROR_COUNT=$((ERROR_COUNT+1))
|
||||||
|
fi
|
||||||
|
echo "total errors enabling tablet mode: $ERROR_COUNT" > $LOGFILE
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
laptop)
|
||||||
|
laptop_mode "$@"
|
||||||
|
;;
|
||||||
|
tablet)
|
||||||
|
tablet_mode "$@"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
printf "usage: ${0} [laptop] [tablet\n]"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
||||||
|
printf "usage: ${0} [laptop] [tablet]\n"
|
||||||
|
exit 1
|
11
src/tsw.conf
Normal file
11
src/tsw.conf
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#
|
||||||
|
# tsw.conf
|
||||||
|
#
|
||||||
|
|
||||||
|
# Run 'xinput' to find device IDs
|
||||||
|
|
||||||
|
# Keyboard device ID
|
||||||
|
KEYBOARD_DEVICE="13"
|
||||||
|
|
||||||
|
# Trackpad device ID
|
||||||
|
TRACKPAD_DEVICE="12"
|
Loading…
Reference in New Issue
Block a user