this post was submitted on 21 Aug 2024
279 points (98.3% liked)

Linux

47976 readers
1050 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

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.

top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 2 points 1 month ago

About a decade ago I was playing a game on Linux and the game crashed and took the entire DE with it. So I went to a different tty and started a fresh x desktop session and started playing again until the game crashed again (I was running a bunch of mods so it would crash every couple of hours or so) and still didn't feel like rebooting so I went to yet another tty and started yet another x desktop session. I did this about 3 times in total before I finally went "I should probably actually reboot because this has to be making a bigger mess of things"

[–] [email protected] 3 points 2 months ago (1 children)

I made a script to add a middle click scroll function with a toggle. I can share the script, it's a really bash script

[–] [email protected] 1 points 2 months ago

this sounds quit useful tbf

[–] [email protected] 4 points 2 months ago

Here's a few of the micro-hacks that I've hacked up in the past.

A 2-line script to chroot into Debian when logging in as a certain user on FreeBSD.

#!/bin/sh  

clear  
doas chroot /linux /bin/login

I didn't have an IDE, so I just made a script called ide which runs Vim, and then compiles the code and makes it executable.

#!/bin/sh
#Works only for C
vim $1.c && cc -O3 -Wall -Werror -Wno-unused-result $1.c -o $1
#MODE=`stat -f "%OLp" $1`
if ("stat -f "%OLp" $1 | grep -e 6 -e 4 -e 2") then
	chmod +x $1
fi

This thing, called demoronize, which does what it says in the comments

#!/bin/sh

#dos2unix -O -e -s $1 | sed 's/    /	/g' | sed 's/“/"/g' | sed 's/”/"/g'
cat $1 | sed 's/    /	/g' | sed 's/“/"/g' | sed 's/”/"/g'
#Convert DOS line endings to Unix ones and add a final newline if there isn't one,
#replace sequence of 4 spaces with tab,
#and replace "smart" quotes with normal ones

I just keep those ones for historical value, but there's one hack I use every day. My keyboard doesn't have a function key (Fn), so I use the Super/Windows key instead.
I have xdotool keyup Super_L keyup Super_R keyup F4 key XF86Sleep bound to a custom keyboard shortcut. It unpresses the keys used for the shortcut (Super + F4), then presses the sleep key.

[–] [email protected] 3 points 2 months ago
wayland.windowManager.sway.config.keybindings = let
    # ...
    screenshot = with pkgs; writeShellScriptBin "screenshot.sh" ''
          DATE=$(date +"%Y%m%d%H%M%S")
          if [ "$1" = "full" ]; then
            ${grim}/bin/grim ~/Pictures/shot_$DATE.png
            ${libnotify}/bin/notify-send "saved full screenshot to shot_$DATE.png"
          elif [ "$1" = "full-copy" ]; then
            ${grim}/bin/grim - | ${wl-clipboard}/bin/wl-copy -t image/png
            ${libnotify}/bin/notify-send "copied full screenshot"
          elif [ "$1" = "sel" ]; then
            ${grim}/bin/grim -g "$(${slurp}/bin/slurp)" ~/Pictures/sel_$(date +"%Y%m%d%H%M%S").png
            ${libnotify}/bin/notify-send "saved selection to sel_$DATE.png"
          elif [ "$1" = "sel-copy" ]; then
            ${grim}/bin/grim -g "$(${slurp}/bin/slurp)" - | ${wl-clipboard}/bin/wl-copy -t image/png
            ${libnotify}/bin/notify-send "copied screenshot"
          else
            printf "Invalid argument: '$1'\n"
          fi
          '';
  in lib.mkOptionDefault { # ...

This is in my Home Manager configuration. I don't think this is that bad, it's just kinda messy. If you can't tell, it's a script for taking screenshots, embedded in my configuration.

[–] [email protected] 1 points 2 months ago

Hmm. Maybe systemctl enable rc-local because I was too lazy to get the service order correct and I just wanted something to happen last and be done with it.

[–] [email protected] 1 points 2 months ago

When installing an encrypted Arch system, I couldn't figure out how to change the keymap in GRUB stage 1, which asks for the passphrase and then decrypts /boot. I just entered my passphrase with the default en-us keymap without really knowing what characters it outputs.

[–] [email protected] 2 points 2 months ago

I’ll leave this one here for someone:

You can tunnel L2 over OpenVPN. Just bridge your interfaces in both sides and it works.

That way if you need to provision a VOIP phone or just have something NetBoot remotely. Not that I recommend doing that…

[–] [email protected] 6 points 2 months ago (1 children)

I used to have a bug with my KVM switch muting my audio devices when I switch. Tried so many things but ended up running a login script that continuously runs unmute command on loop every 100ms.

[–] [email protected] 1 points 2 months ago (1 children)

can't you just trigger a script after some udev event? Your battery would be happg

[–] [email protected] 1 points 2 months ago

That was when I first switched to Linux so safe to say I did my best lol. A correction, the issue happened when I used the switch in my Bluetooth keyboard which connects to 3 devices but was working fine using a dedicated KVM switch with WiFi dongle. Maybe I should check again if its still a thing as its been almost an year now.

[–] [email protected] 5 points 2 months ago

I wrote a script to turn the power of the the Wifi+Bluetooth chip off, then enumerate the PCIe bus again to start it back up.

The chip sometimes hung itself when using both. I looked for the bug and even found an Intel engineer on some mailing list admitting that they had issues with coexistance mode.

Just turning the wireless off and back on wasn't enough I needed to reeinitialize the hardware and that was the best way I knew.

[–] [email protected] 2 points 2 months ago

I converted a custom raspberry pi distribution (some kind of a debian I think) into an Arch Linux ARM without a reinstall.

[–] [email protected] 5 points 2 months ago* (last edited 2 months ago)
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.

[–] [email protected] 28 points 2 months ago (1 children)

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 $@"
[–] [email protected] 7 points 2 months ago
[–] [email protected] 9 points 2 months ago

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

[–] [email protected] 8 points 2 months ago

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.

[–] [email protected] 14 points 2 months ago (1 children)

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.

[–] [email protected] 1 points 2 months ago (1 children)

@drwho @squid_slime

Wow, that sounds like quite the adventure!! I can’t imagine juggling all those steps just to boot up the system....

[–] [email protected] 1 points 2 months ago (1 children)

Huge pain in the ass to set up, but from the user's end of things it was pretty easy to do.

[–] [email protected] 1 points 2 months ago

@drwho It's amazing how much work can go on behind the scenes to make things smooth and simple for the user....

load more comments
view more: next ›