Skip to content

Instantly share code, notes, and snippets.

@mikhailnov
Created August 18, 2020 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikhailnov/577f49c809d5be103134c54c73459197 to your computer and use it in GitHub Desktop.
Save mikhailnov/577f49c809d5be103134c54c73459197 to your computer and use it in GitHub Desktop.
Crazy assocheck.sh from WPS Office 11.x
#!/bin/bash
unset XDG_DATA_HOME
templatedir="/opt/kingsoft/wps-office/office6/asso_template"
if [ ! -d $templatedir ]; then
echo "asso_template not found"
exit 1
fi
mimelist=(".pptx" ".ppt" ".pptm" ".pps" ".pot" ".potm" ".potx" ".ppsx" ".dps" ".dpsx" ".dpt" ".dptx" ".dpss" ".dpso" ".xlsx" ".xls" ".xlsm" ".xlt" ".xltm" ".xltx" ".et" ".etx" ".ett" ".ettx" ".ets" ".eto" ".docx" ".docm" ".doc" ".dot" ".dotm" ".dotx" ".wps" ".wpsx" ".wpss" ".wpso" ".wpt" ".wptx" ".rtf")
fushion=$(grep -oP '(?<=AppComponentMode=).*' "$HOME/.config/Kingsoft/Office.conf")
for suffix in ${mimelist[*]}; do
if [ -f /usr/bin/gio ]; then
mime_result=`gio info -a standard::content-type "${templatedir}/wps${suffix}" | grep "standard::content-type" | awk '{print $2}'`
default_result=`gio mime "${mime_result}" | awk 'NR==1'`
else
mime_result=`gvfs-info -a standard::content-type "${templatedir}/wps${suffix}" | grep "standard::content-type" | awk '{print $2}'`
default_result=`gvfs-mime --query "${mime_result}" | awk 'NR==1'`
fi
if [[ ! ${mime_result} =~ "application/wps-office" ]]; then
echo "needasso"
break
fi
if [[ $fushion == "prome_fushion" ]]; then
if [[ ! ${default_result} =~ "wps-office-prometheus.desktop" ]]; then
echo "needasso"
break
fi
else
if [[ ! ${default_result} =~ "wps-office-wpp.desktop" ]] && [[ ! ${default_result} =~ "wps-office-et.desktop" ]] && [[ ! ${default_result} =~ "wps-office-wps.desktop" ]]; then
echo "needasso"
break
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment