-- Leo's gemini proxy

-- Connecting to senders.io:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; lang=en;

re: The Linux shell is not a good automation platform


gemini://ebc.li/posts/shell-is-not-good-automation.gmi


I was drinking my morning coffee and I came across admicos' post about the linux shell as an automation platform, comparing it to an android app Tasker.


What is a task?


One thing I felt was lacking here, and perhaps a follow-up with some specific actions they're trying to accomplish would be more welcome. The only two examples I found were "Do something when I copy something to the clipboard" and click a GUI button.


I chuckled when I read the first task was based off of clipboard - which besides laptop wifi is one of the eternal struggles of Linux. So it was quite a "way to pick the hardest fight first!".


But to address the question at hand "what is a task?" - in the Linux Shell a task is a command. In Tasker it is:

> ... tasks (set of actions) based on contexts (application, time, date, location, event, gesture) ...


The linux shell is actually a GREAT automation platform


The linux shell can be invoked from most programming languages directly by calling the underlying process function - even higher level languages like python and Java. If you wanted to - in your program - run some task based on an action from your program (say click: "launch browser" button) you could spawn a new process.


But the equivalence here is a house to a hardware store. The linux shell provides all of the tools you need to be able to run through commands automatically (shell-scripting). You can configure things to run at start-up, at an interval, or as a daemon that, depending on your setup, can watch the logs or file creations in a location to trigger something.


I would argue the linux shell is integrated VERY well into the linux echosystem - but they're asking the tool to be the product it can build.


The shell is not discoverable


This was the first point - but I wanted to clarify the differences between the two softwares before addressing this. I can't disagree that the linux shell is not daunting to someone who is new to the software. Most shells open in a small window - and typing "help" into it drops an unhelpful list of commands that scrolls past the window height... and some shells may not have scrolling that is intuitive (shift+up/scroll wheel?) at first.


But if we look at the actual output it drops a core set of shell commands that allow you to do various things - execute processes - traverse the filesystem - etc.


Tasker (I installed the 7-day trial) follows the Material/Android convention for how to do things, so it leans heavily on an assumed workflow - though to be honest the rest of the GUI was a bit clunky so setting up some things did require me to try and find a help guide - which was a bit daunting to look at.


Linux And Android


I am not doubting the power of an application like Tasker - but it benefits significantly from running without a closed, homogenous environment. We should be comparing "N Linux OS" to Android - since in-reality the post should just be (Which in admicos' defense is the resulting question of the post) "why isn't there a good automation tool like this for "N Linux OS"".


Linux is the kernel which powers the operating system (and to-an-extent Android). The Linux Shell is the interface directly to the system - but not the operating system itself.


Which leads to the final question of the post:


Shell doesn't put all my automation in a single place


Which based on all of the above points shows that this is an unreasonable (but also kindof false) ask. Linux has standards for where programs put their configurations /etc/ or ~/.config depending on what level the programs configurations exist at (system or user). But also on Android - if I needed to install a second program that did something Tasker was unable to do/ didn't implement yet - now I have to use TWO APPS to do this (gasp). And now the configuration for that second thing is in a different place! (This is effectively what/how Linux works). But the beauty of Linux is I can actually put all of these files in a single place /home/username/configs - then symlink the files to their expected location (or if supported, override their location with the desired environment variable). Having your configurations in your config file, your custom commands in the bin folder and such are all where someone familiar with the Linux shell would EXPECT to find them. So to me, that is "correct". I can't even think of a way to even have both keybindings, commands, and other definitions IN a single file? Would I write all my scripts directly in there? I guess the .bashrc/.bash_profile does sortof act this way. As I define alias' and shortcut commands directly in there sometimes...


Why isn't there a good automation tool?


So the heart of the post is really this question. And there are actually a ton of automation tools out there - but perhaps one that isn't quite Tasker. I have only done a quick search to see if say a more full-featured GUI Desktop Environment (like KDE/Gnome) has automation tools. There are some app-to-app automation in Linux. DBus is a good service for allowing applications to emit messages that can be picked up by other applications. Journactl has logs that systemd emits - some of which can be listened to/for. But all the examples I could list are "the tools to build an automation tool, or a specific automated task". I suspect the main reason a tool doesn't exist is because each Linux installation is slightly different, and every app is developed using its own paradigm, language, and toolkit. So trying to have every app expose its GUI in a way another application can directly click a button within it is forcing every developer to build either off of a specific GUI toolkit or implement a ton of things for a small gain.


I was able to very easily write a script that ran in a loop that basically checked "does the clipboard contain X" then trigger an application if so (and cleared the clipboard - otherwise you'd get into quite the infinite loop there :P).


Thoughts


I wrote this post because I found the comparison to be a bit comical - since a single program compared to the shell to an entire operating system funny. But I wanted to also call out that once you admit they exist at two entirely different levels of the userspace, the Linux shell can be used for automation, just in a very DIY fashion. I am actually in the process of writing an automated script using rsync to sync files between two servers. As an operating system Linux is more powerful than anyone could want - but also means it's going to be extremely complex.


If you end up reading this post admicos' I mean no ill-will - I think your request for a good Tasker-like automated program would be very powerful. Since they're meant for productivity and nothing soaks up time like digging into a shell script.

xkcd: Automation


But I doubt one exists for Sway/Wayland - since Wayland is still on the "newer side" of Linux, and it's also a stripped down DE as a whole. So then I ask - What specific automated tasks are you trying to do? Perhaps, suggestions can be made on where to start with the DIY side of things?


As someone who spends their day writing shell scripts to automate processes for myself - I felt obligated to reply. I do admit its tedious and not having a universal interface does mean it can be hard - I mean Spotify can't even open a link in the same instance on machine - despite the forums saying they've fixed it countless times! So once you want to do something specific within a proprietary/ complex application you're usually shit-out-of-luck if they don't have an API for doing the thing you need. But if they do - I'd much rather try and write the automated script on Linux than Windows.


Links


Gemlog

Home


-- Response ended

-- Page fetched on Thu Apr 18 16:13:23 2024