• 2 posts
  • 0 comments
Joined 3 years ago
Cake day: December 3rd, 2023

Before I go off an write something myself, many things we open from our apps are HTTP/S URLs and they go straight to the browser. On Android, it’s possible to assign apps to certain domains. I know I could write a script to do the same in linux, but my question is if there is a solution that already does this.

For those who don’t know how, here’s a superuser page that explains how to handle custom protocols.

This is what I use for now to open videos directly in mpv instead of a browser

~/bin/open-http.sh

#!/usr/bin/env bash
set -eu
# install with `xdg-mime default http-handler.desktop x-scheme-handler/http`
#              `xdg-mime default http-handler.desktop x-scheme-handler/https`
# is https and supported by yt-dlp
if [[ "$1" == "https://"* ]] && yt-dlp --simulate "$1" ; then
    exec mpv "$1"
else
    librewolf "$1" 
fi

http-handler.desktop

[Desktop Entry]
Comment=
Exec=~/bin/open-http.sh %u
MimeType=x-scheme-handler/https;
Name=HTTP Scheme Handler
NoDisplay=false
Path=
PrefersNonDefaultGPU=false
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=

A GUI or just config file would be great.

I wrote a simple algorithm for predictive text that uses preceding words as context. Without looking at prior, it was an attempt as seeing what I could come up with.

The goal is for it to be incorporated in chorded input and pick the best candidate for the entered chord with the given context. Chorded input is the method of hitting all keys for a word simultaneously instead of hitting each key individually in expected order.

E.g you’ve typed “this is the worst” and hit the chord “aet”, which word should be chosen? ate? tea? eta? This algorithm is there to answer that.

What I’m looking for in the code review in order of importance:

  • documentation (is it understandable? are there things missing? …)
  • code architecture, code structure (function should be a member? composition could be changed? clarity, …)
  • algorithm review (optimisations, improvements)
  • variable and class names (naming things is hard)
  • rust specific stuff (f64 instead of u32 maybe? dyn vs impl? …)

The code is linted and automatically formatted.