right, so as the title suggests…

i like linux based OSes because you can pretty much mould your operating system to the shape of your brain. i call it cognitive ergonomy. and i’d like it to catch on. even on a relatively play-it-safe distro like the one i’m currently using, the repos are full of handy little applications to make life immeasurably easier for you, if they aren’t installed already. thanks to xdotool, xdo, wmctrl, and sxhkd, pretty much any action can easily be bound to a shortcut key. for eg, i have xdotool search --name vimnote windowactivate || kitty --title=vimnote nvim -c "norm 13j" ~/notes/index.md bound to mod+n. it’s so simple, and i was so proud of myself when i got it to work (i’m not really a scripty person). i just wanted to make something easy. then i wanted to make it a bit easier. then i was feeling like “idk this is still way too many key presses” so i found a way of making it even easier.

i’ve got a bunch of little hacks like this. before i found qmmp, i set up global keys for mpv so i could listen to podcasts on another workspace. i have ranger set up to give specific info from mediainfo as a preview for audio and video files. (which windows does easily in gui file browser but THAT’S NOT THE POINT OK)

anyway, the ubuntu forums and arch wiki are full of tricks that a lot of people want to set up, i’m curious as to the ones you had to set up for yourself.

  • Lvxferre
    link
    fedilink
    English
    161 year ago

    Are clicking games destroying your mouse?

    #!/bin/bash
    export LC_ALL=C
    if [[ $(xset -q | grep -o "Scroll Lock: off") == "Scroll Lock: off" ]]
      then xdotool key Scroll_Lock
      fi
    ScrollStatus=$"Scroll Lock: on"
    while [[ $(xset -q | grep -o "Scroll Lock: on") == "Scroll Lock: on" ]]
      do xdotool click --delay 40 1
      done
    

    Save it as whatever.sh, then create some convenient shortcut for it (I use Ctrl+Print Screen). Use the shortcut to make it click once each 40ms, indefinitely. Press Scroll Lock to turn it off.

    I have a more complex version of that using grabc (to detect pixel colour) and a bunch of if/while/until loops to literally bot some games.

    • @Secret300
      link
      English
      31 year ago

      would this work on wayland if I just replace xdotool with ydotool?

      • ChrisOP
        link
        English
        31 year ago

        ahh good to know that wayland has a dotool in case i ever end up on a distro that uses it. i’m so scared of leaving x.

      • @dotancohen
        link
        English
        21 year ago

        Wait, what? That’s x-do as in “x do something”? I never realized that. Thanks.

    • ChrisOP
      link
      English
      21 year ago

      ahh i like that one. i don’t really game any more but there are a bunch of old mmos where i could have made good use of this.

  • @dethb0y
    link
    English
    111 year ago

    lynx -dump https://wttr.in/XXXXX?u -width 127 > “/home/dethb0y/Documents/Obsidian Vault/Calendar Events/Astronomical Calendar/Weather.md”

    Uses lynx to grab Wttr.in, format it appropriately, dump it into a specific MD file in my obsidian directory, which i then display in obsidian.

    It is so hysterically niche that i can’t imagine hardly anyone would ever need, use, or want such a thing but when i came up with the idea i simply had to make it happen.

      • @dethb0y
        link
        English
        21 year ago

        I’d not see why not - it’s just plain text.

        This is what it looks like “raw”: https://pastebin.com/ejY8SHim

        but i use sed to add ``` to the top so it looks like a quote (since i think it looks nicer, YMMV).

        I also have it set up like this so if it fails it writes an error to the file:

            lynx -dump https://wttr.in/91311?u -width 127 > "/home/dethb0y/Documents/Obsidian Vault/Calendar Events/Astronomical Calendar/Weather.md"
        	if [ ! -s "/home/dethb0y/Documents/Obsidian Vault/Calendar Events/Astronomical Calendar/Weather.md" ]
        	then
        		echo " Could not read weather" > "/home/dethb0y/Documents/Obsidian Vault/Calendar Events/Astronomical Calendar/Weather.md"
        	fi
        
            sed -i '1i ```' "/home/dethb0y/Documents/Obsidian Vault/Calendar Events/Astronomical Calendar/Weather.md"
        

        Now, how Logseq would display the file? I do not know but it’s not doing anything fancy inside, it’s all just spaced text.

    • @Secret300
      link
      English
      31 year ago

      That’s such a neat trick, but why do you need to display the weather in obsidian?

      • @dethb0y
        link
        English
        41 year ago

        I like having everything in one “dashboard” (so to speak) - calendar, weather, rss stuff.

      • ChrisOP
        link
        English
        21 year ago

        this is something i come across sometimes - an application can be designed to do one thing i need, and do it well, but another application, which was designed to do something completely different, actually does the thing i need more conveniently, and does it well enough to work.

  • ffhein
    link
    English
    61 year ago

    At my old job I wanted to use zsh, but all the build and test scripts only worked in bash or csh, because they would depend on you sourcing other scripts setting up the correct environment for the project you were currently working in. The scripts were also quite slow, and sometimes one script would depend on changes to the environment done by a different script, so it wasn’t feasible to simply launch a new bash shell each time I wanted to run something.

    So my hack was to write a zsh function that would spawn a bash process in the background, source the environment depending on your current folder, and then wait for commands. The zsh function then piped the command line to run to bash, which in turn piped any output from the command back to the foreground shell. On the next invocation it would reuse the already running bash process, and if it detected that you had changed dir to a different project it printed a warning that you probably wanted to re-start the bash shell (which was done with another zsh function).

    E.g. b tb7 build would run “tb7 build” in the bash background process while to the user appearing as if had been run normally in a foreground shell. Then b tb7 test would run “tb7 test” in the same bash process as the previous command.

    Since I worked a lot in terminals connected to remote servers, I also wrote zsh functions for copying the current directory, and another for cd-ing to whatever is in the copy-paste buffer. If it was only locally I would press ctrl-shift-t to open a new terminal at the same location, but it doesn’t work if you first have to open another ssh connection. Later I started using tmux and these functions became less useful.

    The third “hack” I made was to easier resume work in terminals where the ssh connection had timed out. My zsh prompt prints a shortened version of the current directory, e.g. “/storage/cnffhein/proj/monkeys/somemodule/dir/anothersubmodule/cloned/src” prints as “/s/c/p/m/s/d/a/c/src >>>” so my function did a depth first search of the file system to find a path that matched the abbreviation and cd:d there. Since everybody had the same prefix to their username and had the same projects checked out I made it search any dir matching my username first. E.g. ccd /s/c/p/m/s/d/a/c/src would find and cd to /storage/cnffhein/proj/monkeys/somemodule/dir/anothersubmodule/cloned/src

  • z3bra
    link
    fedilink
    English
    51 year ago

    I used to put them all under version control until 2017. I have well over 200 scripts now, so I stopped bothering with version control ^^

    But there are a few things I use every now and then that I find “fun”:

    temporary workspace

    tempsh starts a new shell in a temporary directory, and destroy it when you exit the shell. I use it to test code snippets, open tar bombs, whatever task that don’t need to save my work.

    emojis !

    I have an emoji script, which prompts me for all emojis of the spec using dmenu, so I can search them by name, and put them in my clipboard. It’s a stupid script but I use it a lot (much more than those :shortcut: style selector you have in messaging software!).

    love

    I have a love script, which simply outputs “♥️” to the terminal. Most important script of my workflow!

    • ChrisOP
      link
      English
      21 year ago

      yeah i had an emoji selector for rofi, it was super useful. the problem with emoji selectors is on some sites they’re really easy to use, and on some they are terrible or non-existent, so it’s much better to have a universal menu. only problem was that i just could not train my brain to use the universal menu rather than clicking the face on the box i was writing in. i must revisit this.

      this is what i’m talking about too. i have a similar scripts folder and honestly i can’t remember half the stuff that’s in there ha.

  • @[email protected]
    link
    fedilink
    English
    41 year ago

    I have a folder of invoices for articles with warranty I bought (PDFs). I can tag the files with their warranty expiration date using xattrs.

  • @GustavoM
    link
    English
    11 year ago

    Not exactly amusing, but… just this short script:

    echo "What would you like to know more?" &&
    read url &&
    curl cht.sh/$url &&
    unset url