Skip to content

Instantly share code, notes, and snippets.

@niikoo
Last active January 25, 2019 18:03
Show Gist options
  • Save niikoo/870d5514d914c5e6af880fc7a0ae00b8 to your computer and use it in GitHub Desktop.
Save niikoo/870d5514d914c5e6af880fc7a0ae00b8 to your computer and use it in GitHub Desktop.
ViPER4Amdroid Bluetooth Profile Switcher
#!/system/bin/sh
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters, should be 1 (Matching profile dir inside the Bluetooth V4A folder in the internal storage"
exit 1
fi
if [ "$(whoami)" -ne "root" ]
then
echo "Must be run with root privileges"
exit 1
fi
export V4A_EXT="/storage/emulated/0/ViPER4Android"
export V4A_BT_PROFILES="$V4A_EXT/Bluetooth"
if [ -d "$V4A_BT_PROFILES/$1" ]
then
echo "Setting profile '$1'"
export V4A_PROFILE=$V4A_BT_PROFILES/$1
V4A_SPD="/data/data/com.audlabs.viperfx/shared_prefs/com.audlabs.viperfx.bluetooth.xml"
XML_SAVE=com.vipercn.viper4android_v2.bluetooth.xml
V4A_PN="$V4A_SPD.profilename"
if [ -f "$V4A_PN" ]
then
OldProfile=$(cat "$V4A_PN")
if [ "$1" = "$OldProfile" ]
then
echo "Profile already applied"
exit 0
fi
# Save changes
echo "Saving current profile before switching"
cp "$V4A_SPD" "${V4A_BT_PROFILES}/${OldProfile}/${XML_SAVE}"
fi
echo "Setting new profile"
killall com.audlabs.viperfx
cp -f "$V4A_PROFILE/$XML_SAVE" "$V4A_SPD"
echo "$1" > "$V4A_PN"
echo "Restarting V4A-Service"
/system/bin/sh "/sbin/.magisk/img/ViPER4AndroidFX/service.sh" >/dev/null
echo "All done"
exit 0
fi
echo "Profile '$1' not found"
exit 1
<TaskerData sr="" dvi="1" tv="5.6">
<Profile sr="prof2" ve="2">
<cdate>1545700999358</cdate>
<edate>1545701078307</edate>
<flags>2</flags>
<id>2</id>
<mid0>4</mid0>
<nme>BT Connected to Device2</nme>
<State sr="con0" ve="2">
<code>3</code>
<Str sr="arg0" ve="3">Device2</Str>
<Str sr="arg1" ve="3">11:00:11:00:11:00</Str>
</State>
</Profile>
<Profile sr="prof9" ve="2">
<cdate>1545698735133</cdate>
<edate>1545700443715</edate>
<flags>2</flags>
<id>9</id>
<mid0>3</mid0>
<nme>BT Connected Device1</nme>
<State sr="con0" ve="2">
<code>3</code>
<Str sr="arg0" ve="3">Device1</Str>
<Str sr="arg1" ve="3">22:00:22:00:22:00</Str>
</State>
</Profile>
<Project sr="proj0" ve="2">
<cdate>1545698688981</cdate>
<mdate>1545701078307</mdate>
<name>Base</name>
<pids>9,2</pids>
<tids>3,4</tids>
<Img sr="icon" ve="2">
<nme>mw_action_home</nme>
</Img>
</Project>
<Task sr="task3">
<cdate>1545698753874</cdate>
<edate>1545700669815</edate>
<id>3</id>
<nme>Set V4A profile to Device1</nme>
<Action sr="act0" ve="7">
<code>123</code>
<Str sr="arg0" ve="3">/system/bin/sh /storage/emulated/0/ViPER4Android/set-profile.sh Device1</Str>
<Int sr="arg1" val="30"/>
<Int sr="arg2" val="1"/>
<Str sr="arg3" ve="3">%Output</Str>
<Str sr="arg4" ve="3">%Output</Str>
<Str sr="arg5" ve="3"/>
</Action>
</Task>
<Task sr="task4">
<cdate>1545701026105</cdate>
<edate>1545701078307</edate>
<id>4</id>
<nme>Set V4A profile to Device2</nme>
<pri>100</pri>
<Action sr="act0" ve="7">
<code>123</code>
<Str sr="arg0" ve="3">/system/bin/sh /storage/emulated/0/ViPER4Android/set-profile.sh Device2</Str>
<Int sr="arg1" val="30"/>
<Int sr="arg2" val="1"/>
<Str sr="arg3" ve="3">%Output</Str>
<Str sr="arg4" ve="3">%Output</Str>
<Str sr="arg5" ve="3"/>
</Action>
</Task>
</TaskerData>
@niikoo
Copy link
Author

niikoo commented Dec 25, 2018

Run script with Tasker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment