···41 * [MediaInfo (`mediainfo`)](https://mediaarea.net/en/MediaInfo) _(optional: set `ATFILE_DISABLE_NI_MEDIAINFO=1` to ignore)_
42 * `md5sum` _(optional: set `ATFILE_DISABLE_NI_MD5SUM=1` to ignore)_
43 * Both GNU and BusyBox versions supported
0044 * [`websocat`](https://github.com/vi/websocat) _(optional: needed for `stream`)_
45* **ATProto account**
46 * Limit the amount of files you upload, and avoid copyrighted files, if using a managed PDS<br /><em>(e.g. [Blacksky](https://pds.blacksky.app), [Bluesky](https://bsky.social), [Spark](https://pds.sprk.so), [Tangled](https://tngl.sh), or any other independent PDS you don't own)</eM>
···67* __Linux/*BSD/Solaris/SerenityOS__
68 * Install: `$HOME/.local/bin/atfile`
69 * As `sudo`/`root`: `/usr/local/bin/atfile`
070 * Config: `$HOME/.config/atfile.env`, **or** `$XDG_CONFIG_HOME/atfile.env` (if set)
71* **macOS**
72 * Install: `$HOME/.local/bin/atfile`
···102103Various environment variables can be exported to control various aspects of the development version. These are as follows:
10400105* `ATFILE_DEVEL_ENABLE_PIPING` <em><int> (default: `0`)</em><br />Allow piping (useful to test installation) _(e.g. `cat ./atfile.sh | bash`)_
106-* `ATFILE_DEVEL_ENABLE_PUBLISH` <em><int> (default: `0`)</em><br />Publish build to ATProto repository (to allow for updating) as the last step when running `release`. Several requirements must be fulfilled to succeed:
107- * `ATFILE_DEVEL_DIST_USERNAME` must be set<br />By default, this is set to `$did` in `atfile.sh` (see **๐๏ธ Building โ Meta**). Ideally, you should not set this variable as updates in the built version will not be fetched from the correct place
108 * `ATFILE_DEVEL_DIST_PASSWORD` must be set
109 * No tests should return an **Error** (**Warning** is acceptable)
110 * Git commit must be <a href="https://git-scm.com/docs/git-tag">tagged</a>
···119120### Meta
121122-Various meta variables can be set to be available in the final compiled build (usually found in `help`). These are found in `atfile.sh` under `# Meta`. These variables are as follows:
123124* `author` <em><string></em><br />Copyright author
125* `did` <em><did></em><br />DID of copyright author. Also used as the source for published builds, unless `ATFILE_DEVEL_DIST_USERNAME` is set (see **๐๏ธ Building โ Environment variables**)
···137138* **Paul Frazee** — [๐ฆ @pfrazee.com](https://bsky.app/profile/did:plc:ragtjsm2j2vknwkz3zp4oxrd)<br /><a href="https://bsky.app/profile/did:plc:ragtjsm2j2vknwkz3zp4oxrd/post/3l63zzvthqj2o">His kind words</a>
139* **Laurens Hof** — [๐ฆ @laurenshof.online](https://bsky.app/profile/did:plc:mdjhvva6vlrswsj26cftjttd)<br />Featuring ATFile on [The Fediverse Report](https://fediversereport.com): _["Last Week in the ATmosphere โ Oct 2024 week 4"](https://fediversereport.com/last-week-in-the-atmosphere-oct-2024-week-4/)_
140-* **Samir** — [๐ @bdotsamir](https://github.com/bdotsamir)<br />Testing, and diagnosing problems with, support for macOS (`macos`)
141-* **Astra** — [๐ฆ @astra.blue](https://bsky.app/profile/did:plc:ejy6lkhb72rxvkk57tnrmpjl)<br />[Various PRs](https://github.com/ziodotsh/atfile/pulls?q=is%3Apr+author%3Aastravexton); testing, and diagnosing problems with, support for MinGW (`linux-mingw`) and Termux (`linux-termux`)
142* _(Forgot about you? [You know what to do](https://tangled.sh/@zio.sh/atfile/pulls/new))_
143144---
···149* **ยฒ** musl-powered distros do not use GNU/glibc packages, and have problems currently
150 * Known musl distros: Alpine, Chimera, Dragora, Gentoo (musl), Morpheus, OpenWrt, postmarketOS, Sabotage, Void
151 * Bypassing OS detection (see ยน) will cause unintended behavior
152-* **ยณ** As long as you have Bash installed, running from another shell will not be problematic ([`#!/usr/bin/env bash`](https://tangled.sh/@zio.sh/atfile/blob/main/atfile-install.sh#L1) forces Bash)
···41 * [MediaInfo (`mediainfo`)](https://mediaarea.net/en/MediaInfo) _(optional: set `ATFILE_DISABLE_NI_MEDIAINFO=1` to ignore)_
42 * `md5sum` _(optional: set `ATFILE_DISABLE_NI_MD5SUM=1` to ignore)_
43 * Both GNU and BusyBox versions supported
44+ * `sed`
45+ * Only GNU version supported
46 * [`websocat`](https://github.com/vi/websocat) _(optional: needed for `stream`)_
47* **ATProto account**
48 * Limit the amount of files you upload, and avoid copyrighted files, if using a managed PDS<br /><em>(e.g. [Blacksky](https://pds.blacksky.app), [Bluesky](https://bsky.social), [Spark](https://pds.sprk.so), [Tangled](https://tngl.sh), or any other independent PDS you don't own)</eM>
···69* __Linux/*BSD/Solaris/SerenityOS__
70 * Install: `$HOME/.local/bin/atfile`
71 * As `sudo`/`root`: `/usr/local/bin/atfile`
72+ * On **Termux:** `/usr/bin/atfile`
73 * Config: `$HOME/.config/atfile.env`, **or** `$XDG_CONFIG_HOME/atfile.env` (if set)
74* **macOS**
75 * Install: `$HOME/.local/bin/atfile`
···105106Various environment variables can be exported to control various aspects of the development version. These are as follows:
107108+* `ATFILE_DEVEL_DIST_USERNAME` <em><string></em><br />_(Todo)_. During runtime, this is set to `$did` in `atfile.sh` (see **๐๏ธ Building โ Meta**). Ideally, you should not set this variable as updates in the built version will not be fetched from the correct place
109+* `ATFILE_DEVEL_DIST_PASSWORD` <em><string></em><br />_(Todo)_
110* `ATFILE_DEVEL_ENABLE_PIPING` <em><int> (default: `0`)</em><br />Allow piping (useful to test installation) _(e.g. `cat ./atfile.sh | bash`)_
111+* `ATFILE_DEVEL_ENABLE_PUBLISH` <em><int> (default: `0`)</em><br />Publish build to ATProto repository (to allow for updating) as the last step when running `build`. Several requirements must be fulfilled:
112+ * `ATFILE_DEVEL_DIST_USERNAME` must be set
113 * `ATFILE_DEVEL_DIST_PASSWORD` must be set
114 * No tests should return an **Error** (**Warning** is acceptable)
115 * Git commit must be <a href="https://git-scm.com/docs/git-tag">tagged</a>
···124125### Meta
126127+Various meta variables can be set to be available in the final compiled build (usually found in `help`). These are found in `atfile.sh` under `# Meta`. These are as follows:
128129* `author` <em><string></em><br />Copyright author
130* `did` <em><did></em><br />DID of copyright author. Also used as the source for published builds, unless `ATFILE_DEVEL_DIST_USERNAME` is set (see **๐๏ธ Building โ Environment variables**)
···142143* **Paul Frazee** — [๐ฆ @pfrazee.com](https://bsky.app/profile/did:plc:ragtjsm2j2vknwkz3zp4oxrd)<br /><a href="https://bsky.app/profile/did:plc:ragtjsm2j2vknwkz3zp4oxrd/post/3l63zzvthqj2o">His kind words</a>
144* **Laurens Hof** — [๐ฆ @laurenshof.online](https://bsky.app/profile/did:plc:mdjhvva6vlrswsj26cftjttd)<br />Featuring ATFile on [The Fediverse Report](https://fediversereport.com): _["Last Week in the ATmosphere โ Oct 2024 week 4"](https://fediversereport.com/last-week-in-the-atmosphere-oct-2024-week-4/)_
145+* All contributors on [Tangled](https://tangled.org/@zio.sh/atfile/pulls) and [GitHub](https://github.com/ziodotsh/atfile/pulls)
0146* _(Forgot about you? [You know what to do](https://tangled.sh/@zio.sh/atfile/pulls/new))_
147148---
···153* **ยฒ** musl-powered distros do not use GNU/glibc packages, and have problems currently
154 * Known musl distros: Alpine, Chimera, Dragora, Gentoo (musl), Morpheus, OpenWrt, postmarketOS, Sabotage, Void
155 * Bypassing OS detection (see ยน) will cause unintended behavior
156+* **ยณ** As long as you have Bash installed, running from another shell will not be problematic ([`#!/usr/bin/env bash`](https://tangled.sh/@zio.sh/atfile/blob/main/atfile.sh#L1) forces Bash)
···1+#!/usr/bin/env bash
2+3+function atfile.handle() {
4+ uri="$1"
5+ handler="$2"
6+7+ function atfile.handle.is_temp_file_needed() {
8+ handler="${1//.desktop/}"
9+ type="$2"
10+11+ handlers_needing_tmp_file=(
12+ "app.drey.EarTag"
13+ "com.github.neithern.g4music"
14+ )
15+16+ if [[ ${handlers_needing_tmp_file[*]} =~ $handler ]]; then
17+ echo 1
18+ elif [[ $type == "text/"* ]]; then
19+ echo 1
20+ else
21+ echo 0
22+ fi
23+ }
24+25+ # shellcheck disable=SC2154
26+ [[ $_output_json == 1 ]] && atfile.die "Command not available as JSON"
27+28+ actor="$(echo "$uri" | cut -d "/" -f 3)"
29+ key="$(echo "$uri" | cut -d "/" -f 4)"
30+31+ # shellcheck disable=SC2154
32+ atfile.util.create_dir "$_path_blobs_tmp"
33+34+ if [[ -n "$actor" && -n "$key" ]]; then
35+ atfile.util.override_actor "$actor"
36+37+ # shellcheck disable=SC2154
38+ atfile.say.debug "Getting record...\nโณ NSID: $_nsid_upload\nโณ Repo: $_username\nโณ Key: $key"
39+ record="$(com.atproto.repo.getRecord "$_username" "$_nsid_upload" "$key")"
40+ error="$(atfile.util.get_xrpc_error $? "$record")"
41+ [[ -n "$error" ]] && atfile.die.gui.xrpc_error "Unable to get '$key'" "$error"
42+43+ blob_cid="$(echo "$record" | jq -r ".value.blob.ref.\"\$link\"")"
44+ blob_uri="$(atfile.util.build_blob_uri "$_username" "$blob_cid")"
45+ file_type="$(echo "$record" | jq -r '.value.file.mimeType')"
46+47+ # shellcheck disable=SC2154
48+ if [[ $_os == "linux"* ]] && \
49+ [ -x "$(command -v xdg-mime)" ] && \
50+ [ -x "$(command -v xdg-open)" ] && \
51+ [ -x "$(command -v gtk-launch)" ]; then
52+53+ # HACK: Open with browser if $file_type isn't set
54+ [[ -z $file_type ]] && file_type="text/html"
55+56+ if [[ -z $handler ]]; then
57+ atfile.say.debug "Querying for handler '$file_type'..."
58+ handler="$(xdg-mime query default "$file_type")"
59+ else
60+ handler="$handler.desktop"
61+ atfile.say.debug "Handler manually set to '$handler'"
62+ fi
63+64+ # shellcheck disable=SC2319
65+ # shellcheck disable=SC2181
66+ if [[ -n $handler ]] || [[ $? != 0 ]]; then
67+ atfile.say.debug "Opening '$key' ($file_type) with '${handler//.desktop/}'..."
68+69+ # HACK: Some apps don't like http(s)://; we'll need to handle these
70+ if [[ $(atfile.handle.is_temp_file_needed "$handler" "$file_type") == 1 ]]; then
71+ atfile.say.debug "Unsupported for streaming"
72+73+ download_success=1
74+ # shellcheck disable=SC2154
75+ tmp_path="$_path_blobs_tmp/$blob_cid"
76+77+ if ! [[ -f "$tmp_path" ]]; then
78+ atfile.say.debug "Downloading '$blob_cid'..."
79+ atfile.http.download "$blob_uri" "$tmp_path"
80+ [[ $? != 0 ]] && download_success=0
81+ else
82+ atfile.say.debug "Blob '$blob_cid' already exists"
83+ fi
84+85+ if [[ $download_success == 1 ]]; then
86+ atfile.say.debug "Launching '$handler'..."
87+ gtk-launch "$handler" "$tmp_path" </dev/null &>/dev/null &
88+ else
89+ atfile.die.gui \
90+ "Unable to download '$key'"
91+ fi
92+ else
93+ atfile.say.debug "Launching '$handler'..."
94+ gtk-launch "$handler" "$blob_uri" </dev/null &>/dev/null &
95+ fi
96+ else
97+ atfile.say.debug "No handler for '$file_type'. Launching URI..."
98+ atfile.util.launch_uri "$blob_uri"
99+ fi
100+ else
101+ atfile.say.debug "Relevant tools not installed. Launching URI..."
102+ atfile.util.launch_uri "$blob_uri"
103+ fi
104+ else
105+ atfile.die.gui \
106+ "Invalid ATFile URI\nโณ Must be 'atfile://<actor>/<key>'" \
107+ "Invalid ATFile URI"
108+ fi
109+}
+6-4
src/commands/help.sh
···75 bsky [<actor>]
76 Get Bluesky profile for <actor>\n
77 handle <at-uri>
78- Open at:// URI with relevant App\n
79 handle <atfile-uri> [<handler>]
80 Open atfile:// URI with relevant App
81 โน๏ธ Set <handler> to a .desktop entry (with '.desktop') to force the
···132 Endpoint of the PDS
133 โน๏ธ Your PDS is resolved from your username. Set to override it (or if
134 resolving fails)
00135 ${_envvar_prefix}_ENDPOINT_PLC_DIRECTORY <url> (default: ${_endpoint_plc_directory_default}$([[ $_endpoint_plc_directory_default == *"zio.blue" ]] && echo "ยฒ"))
136 Endpoint of the PLC directory
137 ${_envvar_prefix}_ENDPOINT_SOCIAL_APP <url> (default: ${_endpoint_social_app_default})
···162 Disable periodic update checking when command finishes
163 ${_envvar_prefix}_DISABLE_UPDATE_COMMAND <boolยน> (default: $_disable_update_command_default)
164 Disable \`update\` command\n
165- ${_envvar_prefix}_DEBUG <boolยน> (default: 0)
166 Print debug outputs
167 โ ๏ธ When output is JSON (${_envvar_prefix}_OUTPUT_JSON=1), sets to 0\n
168 ยน A bool in Bash is 1 (true) or 0 (false)
169- ยฒ These servers are ran by @$handle. You can trust us!"
0170171 usage_paths="Paths
172 $_path_envvar
···190191Usage
192 $_prog <command> [<arguments>]
193- $_prog at://<actor>[/<collection>/<rkey>]
194 $_prog atfile://<actor>/<key>\n\n"
195196 [[ $ATFILE_DEVEL == 1 ]] && usage+="$usage_commands_devel\n\n"
···75 bsky [<actor>]
76 Get Bluesky profile for <actor>\n
77 handle <at-uri>
78+ Open at:// URI with PDSls\n
79 handle <atfile-uri> [<handler>]
80 Open atfile:// URI with relevant App
81 โน๏ธ Set <handler> to a .desktop entry (with '.desktop') to force the
···132 Endpoint of the PDS
133 โน๏ธ Your PDS is resolved from your username. Set to override it (or if
134 resolving fails)
135+ ${_envvar_prefix}_ENDPOINT_PDSLS <url> (default: ${_endpoint_pdsls_default})
136+ Endpoint of PDSls
137 ${_envvar_prefix}_ENDPOINT_PLC_DIRECTORY <url> (default: ${_endpoint_plc_directory_default}$([[ $_endpoint_plc_directory_default == *"zio.blue" ]] && echo "ยฒ"))
138 Endpoint of the PLC directory
139 ${_envvar_prefix}_ENDPOINT_SOCIAL_APP <url> (default: ${_endpoint_social_app_default})
···164 Disable periodic update checking when command finishes
165 ${_envvar_prefix}_DISABLE_UPDATE_COMMAND <boolยน> (default: $_disable_update_command_default)
166 Disable \`update\` command\n
167+ ${_envvar_prefix}_DEBUGยณ <boolยน> (default: 0)
168 Print debug outputs
169 โ ๏ธ When output is JSON (${_envvar_prefix}_OUTPUT_JSON=1), sets to 0\n
170 ยน A bool in Bash is 1 (true) or 0 (false)
171+ ยฒ These servers are ran by @$handle. You can trust us!
172+ ยณ Cannot be set by config file"
173174 usage_paths="Paths
175 $_path_envvar
···193194Usage
195 $_prog <command> [<arguments>]
0196 $_prog atfile://<actor>/<key>\n\n"
197198 [[ $ATFILE_DEVEL == 1 ]] && usage+="$usage_commands_devel\n\n"