mlvzk / discocss

A tiny Discord css-injector for Linux and MacOS.
Mozilla Public License 2.0
211 stars 16 forks source link

More unique symlink name inside /tmp #20

Closed zkwinkle closed 1 year ago

zkwinkle commented 1 year ago

I'm trying to run discocss from different users in my system simultaneously. Whoever runs it first is fine but whoever is second gets the error:

ln: failed to create symbolic link '/tmp/discocss-preload.js': Operation not permitted

The file inside /tmp/ could be named using date +%s to create a unique name for example:

TMP_LINK="/tmp/discocss-preload-$(date +%s).js"

If there's an issue with the link inside /tmp changing name each time discocss is rerun at least it could have a unique name per each user with something like:

TMP_LINK="/tmp/discocss-preload-${USER}.js"
mlvzk commented 1 year ago

$USER sounds good, but it needs to be padded/truncated to a constant length for patching to work. It can take place of "preload" in /tmp/discocss-preload.js, so it has to be truncated/padded to 7 chars. If you want to make a PR I will merge it.

mlvzk commented 1 year ago

The name needs to be consistent across system restarts, in case the file gets deleted (like on systems that use tmpfs for /tmp), because the patched Discord binary holds a path for the old tmp file. We could generate a random name and store it in ~/.config, but $USER (or hashed $USER) would be easier.

zkwinkle commented 1 year ago

Adressed it in #21 . For the name I used awk to generate a random ID using $USER as the seed, so it'll stay consistent across restarts and be unique for each user.