@@ -0,0 +1,24 @@ | |||||
#!/usr/bin/env bash | |||||
# 0 = Normal/Balanced | |||||
# 1 = Boost | |||||
# 2 = Silent. | |||||
MODELIST=("Balanced" "Boost" "Silent") | |||||
INTERFACE="/sys/devices/platform/asus-nb-wmi/throttle_thermal_policy" | |||||
CURRENT_MODE=$(cat ${INTERFACE}) | |||||
MODE=${CURRENT_MODE} | |||||
if [[ ! ${1} ]]; then | |||||
[[ ${MODE} == 2 ]] && MODE=0 || let MODE+=1 | |||||
else | |||||
MODE=${1} | |||||
fi | |||||
echo ${MODE} > ${INTERFACE} | |||||
CHECK_MODE=$(cat ${INTERFACE}) | |||||
notify-send "Fan mode changed" "${MODELIST[${CURRENT_MODE}]} -> ${MODELIST[${CHECK_MODE}]}" | |||||
@@ -0,0 +1,14 @@ | |||||
#!/usr/bin/env bash | |||||
init () { | |||||
kill $(pidof redshift) | |||||
fanmode.sh 1 | |||||
} | |||||
deinit () { | |||||
exec redshift & | |||||
fanmode.sh 0 | |||||
} | |||||
init && /usr/bin/prime-run $@ && deinit | |||||
@@ -0,0 +1,33 @@ | |||||
#!/bin/sh | |||||
# VPN | |||||
NMCONN="49088a1e-18c2-48aa-a664-f212eb83a727" | |||||
# RDP | |||||
DEF_RESOLUTION="1920x1080" | |||||
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}')" | |||||
rdp() { | |||||
# alternative to "dynamic-resolution" is "smart-sizing" | |||||
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) | |||||
zenity --question --title="Disconnect?" \ | |||||
--text="RDP connection closed. Do you want to close the VPN connection too?" && \ | |||||
nmcli con down ${NMCONN} | |||||
} | |||||
if [ $(nmcli con show ${NMCONN} | awk '/GENERAL.STATE/ {print $2}') == "activated" ]; then | |||||
rdp | |||||
else | |||||
nmcli --ask con up ${NMCONN} & | |||||
rdp | |||||
fi | |||||
@@ -0,0 +1,95 @@ | |||||
#!/usr/bin/env bash | |||||
#============================================================================== | |||||
#title : sanemime.sh | |||||
#description : Resets MIMe configuration to sane defaults in case any shitty | |||||
# software broke it. | |||||
#author : hmk | |||||
#date : 20210620 | |||||
#version : 0.4 | |||||
#============================================================================== | |||||
cp ${HOME}/.config/mimeapps.list ${HOME}/.config/mimeapps.list.bak | |||||
BROWSER=/usr/share/applications/firefox.desktop | |||||
EMAIL=${HOME}/.local/share/applications/neomutt.desktop | |||||
#IMAGE_VIEWER=/usr/share/applications/feh.desktop | |||||
IMAGE_VIEWER=/usr/share/applications/sxiv.desktop | |||||
VIDEO_VIEWER=/usr/share/applications/mpv.desktop | |||||
PDF_VIEWER=/usr/share/applications/org.pwmt.zathura-pdf-mupdf.desktop | |||||
MSTEAMS=${HOME}/.local/share/applications/teams.desktop | |||||
TS3=${HOME}/.local/share/applications/teamspeak.desktop | |||||
ZOOM=${HOME}/.local/share/applications/zoom.desktop | |||||
# Set default browser | |||||
BROWSER_NAME=$(awk -F= '/^Name=/ {print $2;exit;}' ${BROWSER}) | |||||
IFS=';' read -ra types <<< $(awk -F= '/MimeType/ {print $2}' ${BROWSER}) | |||||
for type in ${types[@]}; do | |||||
echo "Setting ${type} to ${BROWSER_NAME}" | |||||
xdg-mime default $(basename ${BROWSER}) ${type} | |||||
done | |||||
# Set default E-Mail client | |||||
EMAIL_NAME=$(awk -F= '/^Name=/ {print $2;exit;}' ${EMAIL}) | |||||
IFS=';' read -ra types <<< $(awk -F= '/MimeType/ {print $2}' ${EMAIL}) | |||||
for type in ${types[@]}; do | |||||
echo "Setting ${type} to ${EMAIL_NAME}" | |||||
xdg-mime default $(basename ${EMAIL}) ${type} | |||||
done | |||||
# Set default image viewer | |||||
IMAGE_VIEWER_NAME=$(awk -F= '/^Name=/ {print $2;exit;}' ${IMAGE_VIEWER}) | |||||
IFS=';' read -ra types <<< $(awk -F= '/MimeType/ {print $2}' ${IMAGE_VIEWER}) | |||||
for type in ${types[@]}; do | |||||
if [[ ${type} =~ ^image.*$ ]]; then | |||||
echo "Setting ${type} to ${IMAGE_VIEWER_NAME}" | |||||
xdg-mime default $(basename ${IMAGE_VIEWER}) ${type} | |||||
fi | |||||
done | |||||
# Set default video viewer | |||||
VIDEO_VIEWER_NAME=$(awk -F= '/^Name=/ {print $2;exit;}' ${VIDEO_VIEWER}) | |||||
IFS=';' read -ra types <<< $(awk -F= '/MimeType/ {print $2}' ${VIDEO_VIEWER}) | |||||
for type in ${types[@]}; do | |||||
if [[ ${type} =~ ^video.*$ ]]; then | |||||
echo "Setting ${type} to ${VIDEO_VIEWER_NAME}" | |||||
xdg-mime default $(basename ${VIDEO_VIEWER}) ${type} | |||||
fi | |||||
done | |||||
# Set default PDF viewer | |||||
PDF_VIEWER_NAME=$(awk -F= '/^Name=/ {print $2;exit;}' ${PDF_VIEWER}) | |||||
IFS=';' read -ra types <<< $(awk -F= '/MimeType/ {print $2}' ${PDF_VIEWER}) | |||||
for type in ${types[@]}; do | |||||
if [[ ${type} =~ ^application.*$ ]]; then | |||||
echo "Setting ${type} to ${PDF_VIEWER_NAME}" | |||||
xdg-mime default $(basename ${PDF_VIEWER}) ${type} | |||||
fi | |||||
done | |||||
# Set communication applications | |||||
MSTEAMS_NAME=$(awk -F= '/^Name=/ {print $2;exit;}' ${MSTEAMS}) | |||||
IFS=';' read -ra types <<< $(awk -F= '/MimeType/ {print $2}' ${MSTEAMS}) | |||||
for type in ${types[@]}; do | |||||
if [[ ${type} =~ ^x-scheme-handler.*$ ]]; then | |||||
echo "Setting ${type} to ${MSTEAMS_NAME}" | |||||
xdg-mime default $(basename ${MSTEAMS}) ${type} | |||||
fi | |||||
done | |||||
TS3_NAME=$(awk -F= '/^Name=/ {print $2;exit;}' ${TS3}) | |||||
IFS=';' read -ra types <<< $(awk -F= '/MimeType/ {print $2}' ${TS3}) | |||||
for type in ${types[@]}; do | |||||
if [[ ${type} =~ ^x-scheme-handler.*$ ]]; then | |||||
echo "Setting ${type} to ${TS3_NAME}" | |||||
xdg-mime default $(basename ${TS3}) ${type} | |||||
fi | |||||
done | |||||
ZOOM_NAME=$(awk -F= '/^Name=/ {print $2;exit;}' ${ZOOM}) | |||||
IFS=';' read -ra types <<< $(awk -F= '/MimeType/ {print $2}' ${ZOOM}) | |||||
for type in ${types[@]}; do | |||||
if [[ ${type} =~ ^x-scheme-handler.*$ ]]; then | |||||
echo "Setting ${type} to ${ZOOM_NAME}" | |||||
xdg-mime default $(basename ${ZOOM}) ${type} | |||||
fi | |||||
done | |||||
@@ -0,0 +1,68 @@ | |||||
#!/bin/bash | |||||
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 | |||||
} | |||||
function end { | |||||
### Cleans up after exiting | |||||
# Stop DroidCamX on device | |||||
echo "Stopping DroidCamX" | |||||
adb shell am force-stop com.dev47apps.droidcamx | |||||
# blank device | |||||
blank 0 | |||||
} | |||||
# Unlock phone | |||||
unlock | |||||
# Start DroidCamX app, intent may vary for free DroidCam version | |||||
echo "(Re-)Starting DroidCamX" | |||||
adb shell << EOF | |||||
am force-stop com.dev47apps.droidcamx | |||||
am start -n com.dev47apps.droidcamx/com.dev47apps.droidcamx.DroidCamX | |||||
EOF | |||||
# Wait some seconds for the app to settle | |||||
sleep 3 | |||||
# Initiate screen blanking in X seconds (mind the background function "&") | |||||
x=10 | |||||
blank ${x} & | |||||
# Start droidcam binary | |||||
# 1920x1080 breaks Skype! | |||||
echo "" | |||||
echo "+-------------------------------------------------------------+" | |||||
echo "| |" | |||||
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 | |||||
# Cleanup when droidcam binary exited | |||||
end | |||||