Pārlūkot izejas kodu

Updated remoteoffice.sh and unlock_adb_device.sh

master
hmk pirms 2 gadiem
vecāks
revīzija
79b1ef9892
2 mainītis faili ar 42 papildinājumiem un 19 dzēšanām
  1. +8
    -5
      remoteoffice.sh
  2. +34
    -14
      unlock_adb_device.sh

+ 8
- 5
remoteoffice.sh Parādīt failu

@@ -6,24 +6,26 @@ set -x
NMCONN="49088a1e-18c2-48aa-a664-f212eb83a727"
# RDP
DEF_RESOLUTION="1920x1080"
DRIVE="work,${HOME}/Documents/Work"
DRIVE="`xdg-user-dir 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)"

[[ ! -d "${DRIVE}" ]] && mkdir -p ${DRIVE}

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 \
# alternative to "dynamic-resolution" is "smart-sizing"
xfreerdp /network:lan /gdi:hw /rfx +glyph-cache +fonts +aero \
/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 \
/d:${DOMAIN} /u:${USER} /v:${REMOTE} /p:${PASSWORD}
zenity --question --title="Disconnect?" \
@@ -39,6 +41,7 @@ else
while [ $(nmcli con show ${NMCONN} | awk '/GENERAL.STATE/ {print $2}') != "activated" ]; do
sleep 1
done
sleep 3
rdp
fi


+ 34
- 14
unlock_adb_device.sh Parādīt failu

@@ -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
# Reads the current screen state eturns any combination of ON/OFF and
# LOCKED/UNLOCKED (i.e. OFF_LOCKED).
@@ -12,23 +8,47 @@ function unlock {
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 && \
[ "${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 && \
[ "${screenstate[1]}" == "LOCKED" ] && adb shell input keyevent 82 && \
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'=' \
'/mScreenState/ {print $2}')
[[ ${screenstate[0]} == "ON" ]] && adb shell input keyevent 26 && \
[ "${screenstate[0]}" == "ON" ] && adb shell input keyevent 26 && \
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

Notiek ielāde…
Atcelt
Saglabāt