diff --git a/remoteoffice.sh b/remoteoffice.sh index 7054993..7553ed9 100755 --- a/remoteoffice.sh +++ b/remoteoffice.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -x + # VPN NMCONN="49088a1e-18c2-48aa-a664-f212eb83a727" # RDP @@ -8,18 +10,22 @@ DRIVE="work,${HOME}/Documents/Work" DOMAIN="$(pass show Work/AD-LOGIN | awk '/domain:/ {print $2}')" USER="$(pass show Work/AD-LOGIN | awk '/user:/ {print $2}')" REMOTE="$(pass show Work/AD-LOGIN | awk '/remote:/ {print $2}')" +PASSWORD="$(pass show Work/AD-LOGIN | head -1)" rdp() { # resolve REMOTE to IPv4 before connecting in order to avoid IPv6 usage REMOTE=$(dig ${REMOTE} A +short) # alternative to "dynamic-resolution" is "smart-sizing" + if [ -z ${PASSWORD} ]; then + PASWORD=$(zenity --entry --title="Password" \ + --text="Enter your _password:" --hide-text) + fi xfreerdp /network:lan /gdi:hw +glyph-cache +fonts +aero \ /bpp:32 /size:${DEF_RESOLUTION} /dynamic-resolution \ /audio-mode:0 /sound:sys:pulse /microphone:sys:pulse \ /kbd:German /drive:${DRIVE} \ +auto-reconnect /auto-reconnect-max-retries:5 \ - /d:${DOMAIN} /u:${USER} /v:${REMOTE} /p:$(zenity --entry \ - --title="Password" --text="Enter your _password:" --hide-text) + /d:${DOMAIN} /u:${USER} /v:${REMOTE} /p:${PASSWORD} zenity --question --title="Disconnect?" \ --text="RDP connection closed. Do you want to close the VPN connection too?" && \ nmcli con down ${NMCONN} @@ -29,7 +35,10 @@ rdp() { if [ $(nmcli con show ${NMCONN} | awk '/GENERAL.STATE/ {print $2}') == "activated" ]; then rdp else - nmcli --ask con up ${NMCONN} & + nmcli --ask con up ${NMCONN} + while [ $(nmcli con show ${NMCONN} | awk '/GENERAL.STATE/ {print $2}') != "activated" ]; do + sleep 1 + done rdp fi diff --git a/unlock_adb_device.sh b/unlock_adb_device.sh new file mode 100755 index 0000000..2f7544b --- /dev/null +++ b/unlock_adb_device.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +#RESOLUTION="1280x720" +RESOLUTION="1920x1080" +VIDEODEV="/dev/video10" + +function unlock { + ### Activates the screen and unlocks the phone + # Reads the current screen state eturns any combination of ON/OFF and + # LOCKED/UNLOCKED (i.e. OFF_LOCKED). + # Works only on NFC enabled phones but alternative methods exist. + IFS='_' read -ra screenstate <<< $(adb shell dumpsys nfc | awk -F'=' \ + '/mScreenState/ {print $2}') + # Emulate Power-Button press if screen is OFF. + [[ ${screenstate[0]} == "OFF" ]] && adb shell input keyevent 26 && \ + echo Screen activated + # Emulate Menu-button press if phone is locked. Requires the phone to + # unlock without PIN or password. + [[ ${screenstate[1]} == "LOCKED" ]] && adb shell input keyevent 82 && \ + echo Device unlocked +} + +function blank { + ### Blanks the screen after X seconds + sleep ${1} + IFS='_' read -ra screenstate <<< $(adb shell dumpsys nfc | awk -F'=' \ + '/mScreenState/ {print $2}') + [[ ${screenstate[0]} == "ON" ]] && adb shell input keyevent 26 && \ + echo Screen deactivated +} + +# Unlock phone +unlock + diff --git a/webcam.sh b/webcam.sh index 6793b30..e455091 100755 --- a/webcam.sh +++ b/webcam.sh @@ -1,5 +1,9 @@ #!/bin/bash +#RESOLUTION="1280x720" +RESOLUTION="1920x1080" +VIDEODEV="/dev/video10" + function unlock { ### Activates the screen and unlocks the phone # Reads the current screen state eturns any combination of ON/OFF and @@ -60,8 +64,7 @@ echo "| SCREEN WILL BLANK IN ${x} SECONDS. CONNECT WITHIN THIS LIMIT! |" echo "| |" echo "+-------------------------------------------------------------+" echo "" -/usr/bin/droidcam -v -dev=/dev/video10 -size=1280x720 adb 4747 > /dev/null -#/usr/bin/droidcam -v -dev=/dev/video10 -size=1920x1080 adb 4747 > /dev/null +/usr/bin/droidcam -v -dev=${VIDEODEV} -size=${RESOLUTION} adb 4747 > /dev/null # Cleanup when droidcam binary exited end