• 0 Posts
  • 30 Comments
Joined 1 year ago
cake
Cake day: June 18th, 2023

help-circle

  • There are two common types of laser printers. Those that have special paper that react to heat, such as receipt printers, would fit the description.

    The other laser printers… Hm, I don’t think your description is accurate either. It’s more that the laser electrically charges ink particles so that they jump on to a separate roller that gets rolled on to the paper.

    I’m no expert though.




  • I don’t think the Unix philosophy of having lots of small tools that do one thing and do it well that you compose together has ever been achieved

    Why do you think this might be the case? It’s not remotely accurate, which suggests that you must understand it very differently than I do. To some extent, I am curious.

    I’ll give you a recent example. Which is just from yesterday. I had a use case where some program had a memory leak, which would eventually lead to the system running out. So, I “built a program that would monitor this and kill the process that used the most memory”. I don’t know how complicated this is in windows and PS, but it took about 2 minutes in Linux, and it very much leverages the Unix philosophy.

    Looks something like this:

    get_current_available_memory_mb() {
        cat /proc/meminfo | grep MemAvailable | grep -oP '\d*' | xargs printf "%d / 1024  \n" | bc
    }
    

    Functionality based on putting together very small pieces that do their things well.

    • /proc/meminfo is a file pipe that gives you access to information related to memory usage.
    • cat just outputs data from a file or a named pipe, here the latter
    • grep lets you filter stuff. First time the relevant line. Then again to strip out the number with a regex.
    • xargs does one thing well, and lets you pass that on to another command as arguments, instead of stdin.
    • printf formats the output, here to express the numerical operation of dividing the value by 1024 as “[number] / 1024”
    • bc evaluates simple mathematical operations expressed in text

    Result: 1 file pipe and 5 simple utilities, and you get the relevant data.

    The PID of the process using the most memory you can get with something like:

    ps aux --sort=-%mem | head -n2 | tail -n1 | awk '{print $2}'
    

    Same sort of breakdown: ps gives you access to process information, and handles sorting by memory usage. head -n2 just keeps the first two lines, but the first one is a header so tail -n1 keeps the second line. awk is used here to only output the second column value. And, you get the relevant data. Also, with simple tools that leverage the Unix philosophy.

    You then check if the available memory is below some threshold, and send a kill signal to the process if it does. The Unix way of thinking also stops you from adding the infinite loop in the script. You simply stop at making it do that one thing. That is, 1. check remaining memory. 2. if lower than X, kill PID". Let’s call this “foo.sh”.

    You get the “monitoring” aspect by just calling it with watch. Something like watch -n 2 -- ./foo.sh.

    And there you go. Every two seconds, it checks available free memory, and saves my system from freezing up. It took me 10 times longer to write this reply, than to write the initial script.

    If memory serves me correctly, PS also supports piping, so I would assume you could do similar things. Would be weird not to, given how powerful it is.

    I could give you an endless list of examples. This isn’t so much a case of “has ever been achieved”, but… a fundamental concept, in use, all the time, by at least a dozen people. A dozen!

    Also yesterday, or it might have been Saturday. To give you another example, I scratched different itch by setting up a script that monitors the clipboard for changes, if it changes, and now matches a YouTube URL, it opens that URL in FreeTube. So… with that running, I can copy a YouTube URL, from anywhere, and that program will immediately pop up and play the video. That too, took about 2 minutes to do, and was also built using simple tools that do one thing, and one thing well. If you wanted it to also keep a local copy of that video somewhere, it wouldn’t be more effort than the 10 seconds it takes to also send that URL to yt-dlp. One tool, that does that one thing well. Want to also notify you when that download is complete? Just add a line with notify-send "Done with the thing". What about the first example, if you want to get a OS level notification that it killed the process? Just add a line to notify-send, same tool that does that same one thing well.

    None of this takes much effort once you get into it, because the basic tools are all the same, and they don’t change much. The whole workflow is also extremely iterative. In the first example, you just cat meminfo. Then you read it, and identify the relevant line, so you add grep to filter out that line, and run the command again. It’s now a line containing the value, so you add another grep to filter it out the number, and again, run it. “Checks out”. So, you pipe that to printf, and you run it. If you fuck something up, no biggie, you just change it and run it again until that little step matches your expectations, and you move on.







  • I don’t know about all of those. Not sure if you downvoted me, in which case you might have the predisposition of not giving a shit. In which case I’d be most happy to oblige.

    As for the technical implementations / shortcomings, I… don’t really care about it. The reason I didn’t use Wayland before was because things didn’t work. The reasons why I don’t use X11 now, is because things occasionally stop working. The reason why I still sometimes use X11, is that unless I do so, some specific software doesn’t work. That’s the frame of mind I have, and I don’t have any allegiance or vested interest beyond that. You seem to have that, and that’s great. Caring about the technical details has my respect.

    So as for the stuff you mention that is directly user-facing:

    • Screen recording used to be a problem, haven’t had that issue recently. OBS records my screens and part of it, just fine.
    • Window sharing like you could with X11 with ssh -X is amazing, and doesn’t work, but it’s been about 15 years since I used it.
    • Crashes that completely freeze my computer. Doesn’t happen in Wayland. Happens in X11 (it’s not a kernel panic, but whatever it is, I have to reboot, end result is the same to me).
    • Have had no issues with any of the monitors I own.
    • Global hotkeys work, and have always worked, for me. If it didn’t, I simply wouldn’t use Wayland, as a lot of my workflows surround tools I have built and trigger with global hotkeys.
    • Sleep mode, I don’t use. Is that the same as Hibernation?
    • I don’t use a single appimage, but I downloaded one to try now, and it worked fine.
    • What is redshift?
    • “Windows can’t raise themselves or keep themselves raised”, does this mean to request to be in focus? I’m curious which programs benefit from this.
    • sudo is insecure by default in Wayland? How come? I’d be interested to know how it has anything to do with wayland/x11. unless you mean GUI applications executed with sudo, not having access to wayland stuff?

  • I was in the same camp one year ago. I sometimes still use it due to Synergy not working otherwise.

    It’s a common occurrence in X11 that I get a full screen “Oops something broke. [Log out]”-screen, except you cannot log out because the screen doesn’t register any inputs.

    So, these days: Wayland just works, and X11 (except for some specific software) causes problems. But, I aslo use AMD GPU.

    So, what in particular is not ready with Wayland? I hated it two years ago. Now, I have little reason to.





  • Also. MacOS is absolute garbage. I’ve used it for 4 months now, and it pisses me off how inconsistent it is, and poorly designed and written. Two days wasted because of an almost bricked laptop because the monitor was set to 60Hz while installing an update. Just think about that.

    I also had the misfortune of booting into windows after changing a motherboard. It was an absolute shit show there too, with broken drivers. Two hours of debugging. Had to use a long ethenet cable to even start fixing it, a flashback to a Linux experience I had in 2007.

    Same system in Linux? Not a single second spent. WiFi drivers, microcode. Everything worked fine. Only thing necessary was fixing the grub/mbr partition that Windows decided to write over, on a separate drive. But that’s also Microsoft being shit.

    People just don’t know how much more usable Linux is these days. Especially for power users. You can do so many things, so easily, that either works out of the box, or you can do with simple scripting. The only issue is software availability, but that too is mostly a thing of the past, and not really a fault of the OS.