tell me the most ass over backward shit you do to keep your system chugging?
here’s mine:
sway struggles with my dual monitors, when my screen powers off and back on it causes sway to crash.
system service ‘switch-to-tty1.service’

[Unit]
Description=Switch to tty1 on resume
After=suspend.target

[Service]
Type=simple
ExecStart=/usr/local/bin/switch-to-tty1.sh

[Install]
WantedBy=suspend.target

‘switch-to-tty1.service’ executes ‘/usr/local/bin/switch-to-tty1.sh’ and send user to tty1

#!/bin/bash
# Switch to tty1
chvt 1

.bashrc login from tty1 then kicks user to tty2 and logs out tty1.

if [[ "$(tty)" == "/dev/tty1" ]]; then
    chvt 2
    logout
fi

also tty2 is blocked from keyboard inputs (Alt+Ctrl+F2) so its a somewhat secure lock-screen which on sway lock-screen aren’t great.

  • intel won’t allow its linux drivers to work above wifi 4 speeds in ap mode, so i created a kvm virtual windows machine with pci pass through on the wifi nic plus ip masquerade and now i’m getting wifi 6 speeds in ap mode.

  • My control key was broken, but I found that when I used an app and held down the space bar key, the CPU would get abnormally hot.

    So I wrote an Emacs interrupt to interpret a rapid CPU rise as “press the control button”.

    Unfortunately the dev pushed an update that broke space bar heating, which broke my workflow. I opened a bug report about it, though…

  • My mother uses some software that runs in the browser for her shop. It can print out receipts and scan items. To do these things it has a small “sattelite” application that runs on the system and interacts with the printer and scanner. This software only runs on Windows and Linux doesn’t have drivers for the scanner.

    When I switched her over to Linux and found this out in the process I wanted to stop, give up and install windows.

    But then I had a stupid idea. I could run the sattelite program in a Windows VM and pass through the USB devices for receipt printer and scanner. The webapp uses requests to localhost:9998 to communicate with the sattelite so I set up a apache server that proxies these requests into the VM. I also prevented the VM from acessing the Interner so Windows doesn’t update and screw everything up.

    And it works. It has been in use for a week now and I’ve heard no complaints. I’m just praying to god it doesn’t break

  • I like to use unclutter to hide my mouse pointer after a few seconds without being moved.

    Now, the thing is, it doesn’t just visually hide the cursor, it actually removes it, so UI elements triggered by hovering disappear. Sometimes that’s great, other times it’s infurriating, like when reading a tooltip or menu.

    I mostly use a touchpad, and so I developed a habit to wiggle my finger while I’m intentionally hovering something, so that there was enough mouse movement for unclutter to not remove my pointer.

    Then I found a setting for the jitter threshold of the touchpad. Basically, with the threshold on, it ignores tiny movements, because the hardware reports finger wiggling, even if you hold your finger perfectly still. Which is perfect for me to turn off.

    Now when I have my finger on the touchpad, it automatically wiggles and allows me to read hover elements. If I take my finger off, it stops wiggling and removes the cursor.
    It’s almost like someone designed an OS with touchpads in mind, rather than them being an afterthought.

  • I think this one beats them all.

    My home server keeps a few services up, including an instance of Jitsi Meet. The server runs nixos and the nixos package for jitsi is incomplete to say the least and doesn’t even support authentication, so I use the docker-compose version and I have a script that runs periodically to keep it updated. So far so good, right? Well, no.

    Because the server is at home, I have a dynamic external IP address, so I have to use a DDNS provider, but jitsi doesn’t expect this and uses a stun server at startup to determine the public IP of the server once, so if my connection goes down or is restarted and the IP changes, jitsi needs to be restarted or it won’t work anymore.

    The solution?

    • My router runs OpenWrt, so I am able to run a script that checks for external IP changes. When a change is detected, it uses SSH to connect to my server to restart jitsi
    • Because I don’t want the router to just be able to run any command, I created a jitsi-restart user that has no shell
    • When the router tries to log in with its pubkey, sshd creates a file called restartasap in the jitsi folder and closes the connection
    • On the server, there’s a systemd unit running a script as the jitsi user that periodically checks for that file, and if it exists it deletes it and restarts jitsi

    I’ve been running this setup since mid 2020 and I expect this to continue until IPv6 becomes the norm.

  •  CrabAndBroom   ( @CrabAndBroom@lemmy.ml ) 
    link
    fedilink
    English
    23
    edit-2
    27 days ago

    I have a folder full of scripts tied to aliases that fix various things when they go wonky, and I’ve long since forgotten what any of them do. I just know if xxx app stops working, I type fix_xxx into the terminal and then it does a bunch of stuff and then it works again lol.

    Also I have a bunch of aliases tied to common tasks, like e1 = reboot, e2 = shutdown etc. I have no idea where that habit came from.

    Edit: ALSO, just the general mish-mash of apps. I won’t have anything to do with Snaps, but the rest of it is an unholy combination of native apps, things from the AUR, flatpaks, Appimages, Docker containers and wine setups, mostly (but not all) in Bottles.

  • I have an old laptop running some basic services.

    I have taken it apart before to replace the hard drive with an SSD, but I never replaced the dead CMOS battery because you have to literally completely disassemble it to get at the battery.

    So I have a cronjob that runs on startup to change the system clock to the right time-zone.

    It just felt simpler than completely disassembling a hard-to-take-apart laptop.

  • I’m using Gentoo with systemd and a customized kernel, and additionally I have the /usr partition LUKS encrypted. Because /usr is absolutely essential for systemd to function, I configured dracut to make a specially crafted initrd which activates the luks lvm and prompts for the password to decrypt and mount /usr on startup before systemd init tries to run.

    About a year or two ago, some update to dracut or some other dependency (assumption) caused the dracut generated initrd’s to kernel panic. After multiple days of troubleshooting, I discovered that just copying forward an older initrd in /boot and naming it to match the new kernel, e.g. initramfs-6.6.38-gentoo.img , allows the system to boot normally .

    So, my Gentoo is booting a kernel 6.6.something with a ramdisk generated in the 5.9 kernel era. I am dreading the day when this behavior breaks and I can no longer update my kernel 😳

  •  The Doctor   ( @drwho@beehaw.org ) 
    link
    fedilink
    English
    1526 days ago

    Some years ago, I had a client with a really fucked up set of requirements:

    • Must run Gentoo Linux. (No, I don’t know why. But it was written into the project specs and everybody who had to sign off did.)
    • Must use LUKS for FDE.
    • Login (loosely interpreted as “booting up”) must have MFA.

    This was during the days when booting into a LUKS encrypted Gentoo install involved copy-and-pasting a shell script out of the Gentoo wiki and adding it to the initrd. I want to say late 2006 or early 2007.

    I remember creating a /boot partition, a tiny little LUKS partition (512 megs, at most) after it, and the rest of the drive was the LUKS encrypted root partition. The encrypted root partition had a randomly generated keyfile as its unlocker; it was symmetrically encrypted using gnupg and a passphrase before being stored in the tiny partition. The tiny partition had a passphrase to unlock it. gnupg was in the initrd. I think the workflow went something like this:

    • System boots up.
    • Script in the initrd prompted the user for the passphrase for the tiny LUKS partition. (first authentication step)
    • User entered passphrase.
    • Script in the initrd unlocked the tiny partition and prompted the user for the passphrase to decrypt the root partition’s keyfile stored therein.
    • User entered the symmetric passphrase for keyfile. (second authentication step_
    • Script used the passphrase to decrypt the keyfile to stdout, piped into an evocation of cryptsetup to unlock the root partition.
    • /dev/mapper/root mounted, /boot mounted, boot process continued.
    • User logged into the box.

    I don’t miss those days.

  • I made a systemd script that fires when going to / waking up from sleep - it checks how long the sleep was and if it was just a few seconds, it puts the computer back to sleep.

    In hindsight, I think the thing that made it work was bluetooth was somehow responsible for the initial failed suspend. The second shot at sleep happened before bluetooth came back up, so it succeeded.

  •  WFH   ( @wfh@lemm.ee ) 
    link
    fedilink
    English
    1327 days ago

    On my previous laptop, the trackpad had a bug that made it spam interrupts after waking up from sleep. It ruined battery life and basically kept one core at 100% permanently.

    So I duct-taped a systemd script that unbound and bound the trackpad after each wake up.

    #!/bin/sh
    case "$1" in
            post)
                    echo -n "i2c_designware.0" > /sys/bus/platform/drivers/i2c_designware/unbind
                    echo -n "i2c_designware.0" > /sys/bus/platform/drivers/i2c_designware/bind
            ;;
    esac
    
  • I had to use unity game engine for one of my assignments for school, but unity wouldn’t generate files needed for the language server unless I set the code editor to vscode. I fixed this by creating a bash script with the path /usr/bin/code that opens neovim in konsole.

    #!/usr/bin/env bash
    konsole -e "nvim $@"
    
  • You guys will probably groan but lots of people in this comment section should look into NixOS. My old Ubuntu machine was loaded with hacks I got from stack overflow to get certain things working (a script that runs at boot and shutdown to mount and unmount some network drives I wanted to appear natively). But now, I just use NixOS and there’s nothing on my machines that is even remotely hackey now. I just declare the drives as I want them and when I boot they are there and work as needed.

  • Youtube doesn’t seem to inhibit idle for me for some reason, so my screen would always turn off with swayidle while watching youtube videos. So I made my lockscreen script (which is called by swayidle)

    if [ "$(playerctl status)" = "Playing" ]; then
        exit 0
    else
        exec "/path/to/lockscreen/script"
    fi
    

    (lockscreen script was just swaylock called with a bunch of arguments)

    Not super crazy compared to some of the things people are saying in the comments, but also definitely not how you’re meant to handle idle inhibition when media is playing lol

    • Hey that’s pretty good, I’m gonna steal it. It might even be worth making a pullrequest to update swaylock to have a flag to do this, I use waybar and it has a lock inhibit button that I use before I start watching anything, but automating it like this is seems super nice

  • For me it’s probably the way I self-host overleaf, a online LaTeX editor. The community version has a docker image that’s horribly maintained (because they want to sell enterprise, I reckon), and instead relies on a horrendous amalgamation of setup scripts that wrap docker compose.

    What I have is a Dockerfile that pulls the image, manually installs a second version of TeX with the right dependencies, unlinks the old one and links the second one. Then for the database, it uses Mongo replsets, which be to be manually initialized. So I wrote a health check for the container that checks if the repl set is initialized, and if that fails the health check initializes it.

    It’s horrendous, it’s disgusting, and it’s an all-in-one compose file to get overleaf running. Good enough.