Notes

Small posts that doesn't need to be a blog/article.

Subscribe: JSON Feed | Atom Feed

Posts

Using en-dash and em-dash in SwayWM with Compose

Profile of Coding Otaku

Published on:

While many think that people who use en-dash or em-dash are using LLMs, it’s pretty easy to do with a keyboard, and I use it quite a lot in my blogs.

Most keyboards available now has a compose key, and even if it doesn’t, the operating system can usually handle it by mapping the compose key to another less-used key.

In my SwayWM configuration, I have the following:

input type:keyboard {
  xkb_options "ctrl:nocaps, compose:ralt"
}

The first option makes the caps lock key behave as Ctrl key. The second option makes the right Alt key behave as the compose key.

To type an en-dash (–), I have to press and release the right Alt key, then type --. (two dashes followed by a period/full stop/dot).

To type an em-dash (—), I have to press and release the right Alt key, then type --- (three dashes).

I’ve been using it for too long that I instinctively try to type it that way on all other systems and be disappointed. Just lookup how to do it in your system, it can usually be done without any configuration or installing anything new!

Dynamic Script Execution with fzf

Profile of Coding Otaku

Published on:

A simple and modular script to organize and run scripts using fzf

I have got a number of scripts in my system to configure thing or to do some common tasks faster. But what’s the point of having scripts if you always need to remember the file name, the path, or even the alias? So this is a small script that will list all executable files in a single directory, and execute them on select.

#!/usr/bin/env sh

name=$(basename "$0")
path="${1:-$(pwd)}"

while true; do
    options=$(find "${path}" -maxdepth 1 -executable -type f -not -name "${name}" -exec basename '{}' \; | tr '-' ' ')
    choice=$(printf '%s\nExit' "${options}" |
        fzf --height=10 --header='Select What to do' --layout=reverse --prompt='choice > ' |
        tr '[:upper:]' '[:lower:]' | tr ' ' '-')

    [ -z "${choice}" ] || [ "${choice}" = "exit" ] && exit

    "${path}/${choice}"
done

Save it to $HOME/.local/bin/fexe. You could have scripts arranged in any folder you would like, and you may want to add alias to use them.

I have an alias set like alias fzettings='fexe $HOME/code/shell/fzettings'. and $HOME/code/shell/fzettings has several scripts that configure the system.

One thing to note is to write the script names in kebab-case (hyphenated-file-name-like-this) so that the script can replace hyphens with a space when listing them. If you do not like that behaviour, remove the tr commands (| tr '-' ' ') and (| tr ' ' '-') in the fexe script.

Just like all my other small scripts, it’s very simple, effective, and prone to security issues.

Another Managa App Bites the Dust

Profile of Coding Otaku

Published on:

Kotatsu, the manga app that became famous after Tachiyomi was forced to shut down, has… shut down.

If you now navigate to the project, you will be greeted with the following important message:

In light of recent challenges — including threating actions from Kakao Entertainment Corp and upcoming Google’s new sideloading policy — we’ve made the difficult decision to shut down Kotatsu and end its support. We’re deeply grateful to everyone who contributed and to the amazing community that grew around this project.

Kotatsu is just one of many specialized browsers that fought through legal challenges to help Manga fans read their favourite manga without distractions. I say specialized browser because that’s what Kotatsu and similar programs do, they just show the website content, cleans up irrelevant stuff, and add a way to easily navigate between chapters/pages. People who actually read the Manga and Comic from bot official and unofficial websites will also block/remove the distractions in one or the other way to enjoy what they want to read.

The same goes for Anime too. The reason for both Anime and manga being popular outside Japan is because of fans translating and aggregating them. Not because of the official Dub or the official translations that worsens over time.

As the world is becoming increasingly hostile to almost everything that could improve the daily life, it is no surprise that apps like Kotatsu and Tachiyomi who live in a gray area can’t survive.

So what now? Kotatsu shutting down does not mean that the Manga fans will just stop reading Manga, they will all just flock to some other app or website. What lacks in the industry is a true official Aggregator platform. Nobody wants to subscribe to yet another service to read just one or two Manga or watch a few Anime. So it is just a matter of time before we find an alternative.

Shameless plug, I am working on Ani-GUI, a GUI client inspired from ani-cli. Make sure to fork it 😉.

Using Fuzzel to Manage Clipboard History in Wayland

Profile of Coding Otaku

Published on:

I use Fuzzel for almost everything, but I forgot that I also manage the clipboard also with it until today.

I don’t usually use clipboard manager, in fact, I even forgot that this script existed with a key binding in my window manager.

The required packages are just cliphist and fuzzel.

It provides the option to copy a text/multimedia from the history, delete an item from history, and delete all items from the history.

I bind it to the Mod+C keyboard shortcut in SwayWM, today I accidentally pressed it and instead of Ctrl+C and remembered that I had this set up.

Here is the script:

#!/usr/bin/env sh

tolower() {
    tr '[:upper:]' '[:lower:]'
}

delete() {
    cliphist delete
}

copy() {
    cliphist decode | wl-copy
}

history() {
    while true; do
        item=$(cliphist list | fuzzel -d --prompt='History > ')
        [ -z "${item}" ] && return 130

        choice=$(printf 'Copy\nDelete' | fuzzel -d --prompt='History > ' | tolower)
        [ -z "${choice}" ] && return 130

        printf '%b' "$item" | "${choice}"

        if [ "${choice}" = 'copy' ]; then
            return 0
        fi
    done
}

wipe() {
    choice=$(printf 'Yes\nNo' | fuzzel -d --prompt='Wipe clipboard? ' | tolower)
    [ -z "${choice}" ] || [ "${choice}" = 'no' ] && return 130

    cliphist wipe

    exit 0
}

while true; do
    hist_count=$(cliphist list | wc -l)

    if [ "${hist_count}" -eq 0 ]; then
        choice=$(printf 'Exit' | fuzzel -d --prompt='Nothing in clipboard history, exit > ' | tolower)
    else
        choice=$(printf 'History\nWipe\nExit' | fuzzel -d --prompt='Clip Manager > ' | tolower)
    fi
    [ -z "${choice}" ] && exit 130
    [ "${choice}" = 'exit' ] && exit 0

    if "${choice}"; then
        exit 0
    fi
done

It might look long, that’s because I wrote it with POSIX compatibility in mind.

Always Use the Location Flag in Curl

Profile of Coding Otaku

Published on:
Last updated on:

The --location or -L will let curl redirect if the route was changed and the webmaster has set up proper redirects. For example, my curl card was at https://codingotaku.com/cc, after I did my website updates, it is now https://codingotaku.com/static/uploads/9bca2ae5-7643-4a1c-bb0c-fe37136f6cb1/beb2d053-7a5d-4691-9c60-f3a177c9d284.txt because that’s how I set up my uploads.

domain.tld/cc is very easy to remember, and I would like to keep it that way. So set up a redirect for it so that people can still access my curl card with curl -sL https://codingotaku.com/cc

Likewise, some of my feeds and old posts also has redirect set up so that people who stored my posts offline can still access them.