Browse Source

Updates

master
haemka 3 years ago
parent
commit
ee4916d973
3 changed files with 51 additions and 5 deletions
  1. +12
    -3
      remoteoffice.sh
  2. +34
    -0
      unlock_adb_device.sh
  3. +5
    -2
      webcam.sh

+ 12
- 3
remoteoffice.sh View File

@@ -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


+ 34
- 0
unlock_adb_device.sh View File

@@ -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


+ 5
- 2
webcam.sh View File

@@ -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


Loading…
Cancel
Save