Skip Navigation

What is the most duct-tape thing you've done to Linux?

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.

181 comments
  • An old (now decommissioned) notebook of mine had a broken headphone jack. I didn't have BT headphones then. Audio output worked technically but the detection whether headphones were plugged in or not did no longer work.

    I wrote a very short amixer script to force unmute the jack, set the volume to 50 or so percent and set the speaker volume to 0% but not "mute" state. I could then use my wired headphones again.

  • 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
    
      
  • holy shit i was about to post about how i have automatic login and lock to start a program that refuses to work correctly on boot through systemd.

    but then you guys are here casually posting some of the worst duct tape shit ive heard of so far. im not sure if i should reprimand or congratulate you for that jankiness.

  • 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.

  • 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.

  • 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.

  • I got an Orange Pi 5 Plus to play with smallish AIs (because it has an NPU) and I normally access it remotely, so I have to know its IP address to do it.

    In order to easilly know the IP address of it, I've wired a little 128x64 monochrome OLED screen to it (Orange PIs, like Raspberry PIs have a pin connector giving access to GPIO and interfaces like I2C, Serial and SPI) which talks via I2C.

    Turns out those interfactes aren't active in Linux by default (I.e. no /dev/i2c-x), so I figured out that I had to add a kernel overlay to activate that specific interface (unlike with the Raspberry PI whose Linux version has a neat program for doing it, in the Orange Pi you have to know how the low level details of activating those things), which I did.

    To actually render characters on that screen I went with an ARM Linux port of a graphics library for those screens I used before with Arduino, called u8g2)

    Then I made a program in C that just scans all network interfaces and prints their names and IP addresses on that screen, and installed it as a Cron job running once a minute.

    Now, as it turns out when you shutdown your Linux on that board, if you don't disconnect it from power there is actually still power flowing through the pin connector to any devices you wire there, so after shutdown my screen would remain ON and showing the last thing I had put there, but because the OS was down it would naturally not get updated.

    So the last thing I did was another small C program which just sends to that screen the command for it to go into power saving mode, shutting it down. This program was then installed as a Systemd Service to run when Linux is shutting down.

    The result is now that there is a little screen hanging from the box were I put this board with Linux which lists its IP addresses and the info is updated if it connects other interfaces or reconnects and gets a new IP address. Curiously I've actually been using that feature because it's genuinely useful, not just a funny little project.

  • Had a zfs array on an adaptec raid card. On reboot the partition table would get trashed and block the zfs pool from coming up, but running fdisk against the disk would recover it from the backup.

    Had a script to run on reboot that just ran "fdisk -l" on every disk, then brought up the zfs pool. Worked great for years until I finally did a kernel upgrade that resolved it.

  • I had an external hard drive enclosure that I stored my Plex content on before I built a nas, and the enclosure would go to sleep after 15 minutes and take the drives offline. So i had a cron script write a 1 kb file to each drive every 14 minutes. Worked well enough

  • Couldn’t figure out how to access my headless server’s desktop environment via VNC without a monitor connected and turned on. I bought a hardware displayport dummy adapter to pretend to be a real display to get it to work.

    A hardware solution to a software problem… felt really wrong.

    I’ve since wrapped my head around tmux and managing all my services via command-line or web-ui so I have no need for it anymore.

  • I'm not technically inclined at all, so the most duct tapey thing I can remember was hacking Gnome to use Nemo as my file browser instead of Gnome's default file browser once.

  • My Nvidia card won't properly resume the display after suspend with the default suspend script, but if I correct the script file, every time aptitude updates the nvidia drivers, it restores the bad version of the configuration file. If you set the file immutable with chattr, aptitude throws a fit and goes into a broken state when it can't overwrite the file on a driver update.

    So I keep a good copy of the script file in the directory, and in my pre-suspend script file I overwrite the main suspend script with the good version. Every single time.

  • something kept messing with my dns and i’m too lazy to find out why so i hardcoded etc/resolv.conf and chmod +i on it

  •  
        
    bindntr=CTRL,C,exec,hyprctl dispatch closewindow alacrittyclipboard & hyprctl activewindow | rg -q "class: Wfica" && alacritty -qq --config-file ~/.config/alacritty/alacrittyclipboard.toml --class 'alacrittyclipboard' --title 'Office365 Desktop - Nexus (SSL/TLS Secured, 256 bit)' -e sh -c 'sleep .03 && xclip -o | wl-copy ; wl-paste | xclip -i'
    windowrulev2 = float,class:(alacrittyclipboard)
    windowrulev2 = stayfocused,class:(alacrittyclipboard)
    windowrulev2 = noborder,class:(alacrittyclipboard)
    windowrulev2 = noanim,class:(alacrittyclipboard)
    windowrulev2 = noblur,class:(alacrittyclipboard)
    windowrulev2 = opacity 0,class:(alacrittyclipboard)
    windowrulev2 = maxsize 1 1,class:(alacrittyclipboard)
    
    
      

    Fixes the fucking clipboard in citrix, no, I cannot figure out a better solution.

    the move to aquamarine with hyprland mostly resolved this... but not completely and i'm going to have to write a new duct tape solution for that.

    If you're wondering why I launch alacritty... it doesn't work without alacritty, wayland needs the window to be in focus, if alacritty isn't there there's no in focus window and it doesn't update the clipboard.

  • I'm rebooting my router every week via a crontab because some dynamic dns update process fails from time to time and I find it hanging. No time to debug the actual problem.

181 comments