Open Files Everywhere
- Dominant language
- Shell
- Stars
- 10.3k
- Forks
- 452
- PR merge metrics
- No merged PRs in 30d
Description
I have multiple drives so it's nice to be able to open a document in a different path than my home path. I have all of my harddrives mounted on /media/.... and it's nice to be able to use the "open with default" application and have the translation work for these additional drives instead of just for the home folder.
Currently in the winapps script this exists:
```bash
98 if [ -n "${2}" ]; then
99 dprint "HOME:${HOME}"
100 FILE=$(echo "${2}" | sed 's|'"${HOME}"'|\\\\tsclient\\home|;s|/|\\|g;s|\\|\\\\|g')
101 dprint "FILE:${FILE}"
102 xfreerdp ${RDP_FLAGS} /d:"${RDP_DOMAIN}" /u:"${RDP_USER}" /p:"${RDP_PASS}" /v:${RDP_IP} +auto-reconnect +clipboard +home-drive -wallpaper /scale:${RDP_SCALE} /dynamic-resolution /${MULTI_FLAG} /wm-class:"${FULL_NAME}" /app:"${WIN_EXECUTABLE}" /app-icon:"${ICON}" /app-cmd:"\"${FILE}\"" 1> /dev/null 2>&1 &
103 else
```
If you pass the '/drives' switch then all other drives are available. I changed the script to the following and it works decently, This is just for me so I didn't test this extensively but I wanted to offer it up for an improvement when the time permits. The idea is that you loop through your mounted drives for the file and then look at your home folder:
```bash
98 if [ -n "${2}" ]; then
99 dprint "HOME:${HOME}"
100
101 FOLDERS=( $(mount | grep /media | grep /dev | gawk '{print $3}') )
102 FILE="X"
103 FOUND=false
104 for i in ${FOLDERS[@]}; do
105 if grep -q "${i}" <<< "$2"; then
106 FOLDERNAME=$(basename "${i}")
107 FILE=$(echo "${2}" | sed 's|'"${i}"'|\\\\tsclient\\'"${FOLDERNAME}"'|;s|/|\\|g;s|\\|\\\\|g')
108 FOUND=true
109 break
110 fi
111 done
112 if [ ! $FOUND ]; then
113 FILE=$(echo "${2}" | sed 's|'"${HOME}"'|\\\\tsclient\\home|;s|/|\\|g;s|\\|\\\\|g')
114 fi
115 dprint "FILE:${FILE}"
116 xfreerdp ${RDP_FLAGS} /d:"${RDP_DOMAIN}" /u:"${RDP_USER}" /p:"${RDP_PASS}" /v:${RDP_IP} +auto-reconnect +clipboard +home-drive -wallpaper /scale:${RDP_SCALE} /dynamic-resolution /${MULTI_FLAG} /wm-class:"${FULL_NAME}" /app:"${WIN_EXECUTABLE}" /app-icon:"${ICON}" /app-cmd:"\"${FILE}\"" 1> /dev/null 2>&1 &
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.