| @@ -6,24 +6,26 @@ set -x | |||||
| NMCONN="49088a1e-18c2-48aa-a664-f212eb83a727" | NMCONN="49088a1e-18c2-48aa-a664-f212eb83a727" | ||||
| # RDP | # RDP | ||||
| DEF_RESOLUTION="1920x1080" | DEF_RESOLUTION="1920x1080" | ||||
| DRIVE="work,${HOME}/Documents/Work" | |||||
| DRIVE="`xdg-user-dir DOCUMENTS`/Work" | |||||
| DOMAIN="$(pass show Work/AD-LOGIN | awk '/domain:/ {print $2}')" | DOMAIN="$(pass show Work/AD-LOGIN | awk '/domain:/ {print $2}')" | ||||
| USER="$(pass show Work/AD-LOGIN | awk '/user:/ {print $2}')" | USER="$(pass show Work/AD-LOGIN | awk '/user:/ {print $2}')" | ||||
| REMOTE="$(pass show Work/AD-LOGIN | awk '/remote:/ {print $2}')" | REMOTE="$(pass show Work/AD-LOGIN | awk '/remote:/ {print $2}')" | ||||
| PASSWORD="$(pass show Work/AD-LOGIN | head -1)" | PASSWORD="$(pass show Work/AD-LOGIN | head -1)" | ||||
| [[ ! -d "${DRIVE}" ]] && mkdir -p ${DRIVE} | |||||
| rdp() { | rdp() { | ||||
| # resolve REMOTE to IPv4 before connecting in order to avoid IPv6 usage | # resolve REMOTE to IPv4 before connecting in order to avoid IPv6 usage | ||||
| REMOTE=$(dig ${REMOTE} A +short) | REMOTE=$(dig ${REMOTE} A +short) | ||||
| # alternative to "dynamic-resolution" is "smart-sizing" | |||||
| if [ -z ${PASSWORD} ]; then | if [ -z ${PASSWORD} ]; then | ||||
| PASWORD=$(zenity --entry --title="Password" \ | PASWORD=$(zenity --entry --title="Password" \ | ||||
| --text="Enter your _password:" --hide-text) | --text="Enter your _password:" --hide-text) | ||||
| fi | fi | ||||
| xfreerdp /network:lan /gdi:hw +glyph-cache +fonts +aero \ | |||||
| # alternative to "dynamic-resolution" is "smart-sizing" | |||||
| xfreerdp /network:lan /gdi:hw /rfx +glyph-cache +fonts +aero \ | |||||
| /bpp:32 /size:${DEF_RESOLUTION} /dynamic-resolution \ | /bpp:32 /size:${DEF_RESOLUTION} /dynamic-resolution \ | ||||
| /audio-mode:0 /sound:sys:pulse /microphone:sys:pulse \ | |||||
| /kbd:German /drive:${DRIVE} \ | |||||
| /audio-mode:2 /sound:sys:pulse /microphone:sys:pulse \ | |||||
| /kbd:German /drive:"`basename ${DRIVE}`,${DRIVE}" \ | |||||
| +auto-reconnect /auto-reconnect-max-retries:5 \ | +auto-reconnect /auto-reconnect-max-retries:5 \ | ||||
| /d:${DOMAIN} /u:${USER} /v:${REMOTE} /p:${PASSWORD} | /d:${DOMAIN} /u:${USER} /v:${REMOTE} /p:${PASSWORD} | ||||
| zenity --question --title="Disconnect?" \ | zenity --question --title="Disconnect?" \ | ||||
| @@ -39,6 +41,7 @@ else | |||||
| while [ $(nmcli con show ${NMCONN} | awk '/GENERAL.STATE/ {print $2}') != "activated" ]; do | while [ $(nmcli con show ${NMCONN} | awk '/GENERAL.STATE/ {print $2}') != "activated" ]; do | ||||
| sleep 1 | sleep 1 | ||||
| done | done | ||||
| sleep 3 | |||||
| rdp | rdp | ||||
| fi | fi | ||||
| @@ -1,10 +1,6 @@ | |||||
| #!/bin/bash | |||||
| #!/bin/sh | |||||
| #RESOLUTION="1280x720" | |||||
| RESOLUTION="1920x1080" | |||||
| VIDEODEV="/dev/video10" | |||||
| function unlock { | |||||
| unlock() { | |||||
| ### Activates the screen and unlocks the phone | ### Activates the screen and unlocks the phone | ||||
| # Reads the current screen state eturns any combination of ON/OFF and | # Reads the current screen state eturns any combination of ON/OFF and | ||||
| # LOCKED/UNLOCKED (i.e. OFF_LOCKED). | # LOCKED/UNLOCKED (i.e. OFF_LOCKED). | ||||
| @@ -12,23 +8,47 @@ function unlock { | |||||
| IFS='_' read -ra screenstate <<< $(adb shell dumpsys nfc | awk -F'=' \ | IFS='_' read -ra screenstate <<< $(adb shell dumpsys nfc | awk -F'=' \ | ||||
| '/mScreenState/ {print $2}') | '/mScreenState/ {print $2}') | ||||
| # Emulate Power-Button press if screen is OFF. | # Emulate Power-Button press if screen is OFF. | ||||
| [[ ${screenstate[0]} == "OFF" ]] && adb shell input keyevent 26 && \ | |||||
| [ "${screenstate[0]}" == "OFF" ] && adb shell input keyevent 26 && \ | |||||
| echo Screen activated | echo Screen activated | ||||
| # Emulate Menu-button press if phone is locked. Requires the phone to | # Emulate Menu-button press if phone is locked. Requires the phone to | ||||
| # unlock without PIN or password. | # unlock without PIN or password. | ||||
| [[ ${screenstate[1]} == "LOCKED" ]] && adb shell input keyevent 82 && \ | |||||
| [ "${screenstate[1]}" == "LOCKED" ] && adb shell input keyevent 82 && \ | |||||
| echo Device unlocked | echo Device unlocked | ||||
| } | } | ||||
| function blank { | |||||
| ### Blanks the screen after X seconds | |||||
| sleep ${1} | |||||
| blank() { | |||||
| ### Blanks the screen (optionally wait X seconds) | |||||
| [ -z "${1}" ] && sleep "${1}" | |||||
| IFS='_' read -ra screenstate <<< $(adb shell dumpsys nfc | awk -F'=' \ | IFS='_' read -ra screenstate <<< $(adb shell dumpsys nfc | awk -F'=' \ | ||||
| '/mScreenState/ {print $2}') | '/mScreenState/ {print $2}') | ||||
| [[ ${screenstate[0]} == "ON" ]] && adb shell input keyevent 26 && \ | |||||
| [ "${screenstate[0]}" == "ON" ] && adb shell input keyevent 26 && \ | |||||
| echo Screen deactivated | echo Screen deactivated | ||||
| } | } | ||||
| # Unlock phone | |||||
| unlock | |||||
| run() { | |||||
| # Unlock phone | |||||
| unlock | |||||
| # Start intent | |||||
| [ -z "${1}" ] && APP="com.dev47apps.obsdroidcam" || APP="${1}" | |||||
| adb shell am start -n "${APP}/.MainActivity" | |||||
| blank 5 | |||||
| } | |||||
| usage() { | |||||
| echo "Usage: ${0} [-u|b] [-r INTENT] | |||||
| -u unlock device (default if no option is given) | |||||
| -b blank device screen | |||||
| -r INTENT unlock device, run given intent and blank device screen | |||||
| -h this help" | |||||
| } | |||||
| while getopts ":ubr:h" opt; do | |||||
| case "${opt}" in | |||||
| u) unlock ;; | |||||
| b) blank ;; | |||||
| r) run "${OPTARG}" ;; | |||||
| h) usage ;; | |||||
| *) unlock ;; | |||||
| esac | |||||
| done | |||||