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

help-circle

  • Remove the loop and sleep from the script you created so it just runs and exits.

    Then create a file at /etc/systemd/system/battery-alarm.service with the following:

    [Unit]
    Description="Sound alarm when battery is low"
    
    [Service]
    ExecStart=/usr/local/bin/battery-alarm.sh # point this to your script
    

    Then create a file at /etc/systemd/system/battery-alarm.timer with the following:

    [Unit]
    Description="Run battery-alarm.service every 2 mins"
    
    [Timer]
    OnUnitActiveSec=2m
    Unit=battery-alarm.service
    
    [Install]
    WantedBy=multi-user.target
    

    Then sudo systemctl enable --now helloworld.timer to start and enable the timer on boot.

    This will be a little more robust then your current script. It works without the user needing to log in. And there is nothing to get killed so will always trigger. The current script will just silently stop working if it ever gets killed or crashes.


  • Worth running shell scripts though https://www.shellcheck.net/ (has a cli as well). Finds lots of common issues that can blow up scripts when input is not what you expect. With links to why they make the suggestions they do.

    Line 4:
            battery_level=`cat /sys/class/power_supply/BAT0/capacity`
                          ^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
    
    Did you mean: (apply this, apply all SC2006)
            battery_level=$(cat /sys/class/power_supply/BAT0/capacity)
     
    Line 5:
            battery_status=`cat /sys/class/power_supply/BAT0/status`
                           ^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
    
    Did you mean: (apply this, apply all SC2006)
            battery_status=$(cat /sys/class/power_supply/BAT0/status)
     
    Line 6:
            if [ $battery_status = "Discharging" ] && [ $battery_level -lt 21 ];
                 ^-- SC2086 (info): Double quote to prevent globbing and word splitting.
                                                        ^-- SC2086 (info): Double quote to prevent globbing and word splitting.
    
    Did you mean: (apply this, apply all SC2086)
            if [ "$battery_status" = "Discharging" ] && [ "$battery_level" -lt 21 ];
    


  • You should not be struggling most of the time when using the CLI. Basic uses is just as easy as any GUI. Learning the commands might be a bit more involved and you need to be a bit more proactive about it. Anything you need to do 30+ times a day you should be over the learning curve of and can just execute them just as quickly if not quicker than using GUI. Especially when you look at tab competition and the reverse history search.

    But what using the CLI more often does teach you is how to lessen that initial learning curve. Making you quicker at finding the new commands you need and how they work slowly building up your tool belt of knowledge about the commands you do look up.


  • I see nothing in this graphic that isn’t easy to do with a gui.

    I didnt say the GUI was not easy for the common stuff. But I think the CLI is also easy for the common stuff so there is not much advantage other than a bit of a learning curve with the CLI. But the big thing that GUIs make harder is automation of common things. For instance, when I want to create a PR I like to rebase to the latest upstream. In a GUI that is a bunch of button clicks. With the cli I just <CTRL+R>pus and that will autocomplete to git pull --rebase=interactive --autostash && git push && gh pr create --web and I am landed in a web browser ready to review and submit my PR. Doing the same thing in a GUI takes a lot longer with a lot more clicking.

    And that is a very common command for me.

    Like logging and diffing is just so much easier when I can just scroll and click as opposed to having to do a log command, scroll, then remember the hashes, and then write the command.

    Never found that to be a big issue. Most of the time when you want a diff you want to diff local changes or staged changes which is simply git diff and git diff --staged neither of those are hard or any real easier in the GUI (especially with bash history). For diffing specific commits I dont find that hard either just git log --oneline and find the commits (and you can use grep to filter things out easily as well here) - typically does not require scrolling at all. Then git diff <copy paste>..<copy paste>. In the GUIs you are often scrolling through commits you want to select at some point so I dont see how that saves you any real time here. I would not say the CLI or GUI is vastly easier in this case. And even in this case it is rare to need to do. Far more often is just branches which on a decent shell can be tab completed for convenience.

    And sometimes I watch beginners use the gui and I have to bite my tongue because I know it would be faster in the cli.

    This is why I prefer the CLI for common stuff. It is just faster.

    But, especially for a beginner, i strongly recommend a gui.

    And that is where I disagree. I think beginners should spend some time learning the tools they will need to use. IMO the CLI is critical for developers to learn and the sooner the better. So many things a vastly easier with the CLI than GUIs and a lot of stuff is near impossible with GUIs. Automation being a big one. I have not seen a good CI system that is GUI focused that you never need to know the cli for. Or when you have a repetitive task then it is quicker to write a quick script and run that then doing the same thing over and over in the GUI. Repeating actions is also easier in the CLI. All of these apply to more than just git as well.

    I have seen so many beginners start with GUIs that don’t really understand what they are doing in git. And quite often break things and then just delete and recreate the repo and manually make their changes again. I find people that never bother with the CLI always hit a ceiling quite quickly in terms of their ability and productivity.

    The only real thing that makes the CLI worst is that it has a steeper learning curve. Once you are over that hill I find it to be vastly better for more situations or at least not practically any worst than a GUI equivalent. So that hill is one well worth climbing.

    I can always use a GUI if I really needed to. But those that only know the GUI will have a very hard time on the CLI when they need to - which is required far more often than the other way round.








  • REPLs are basically shells. They behave the same way in every essential way. So the real question is support vs non-supported shells. But then that is easy - non supported shells fall back to just what a normal commands do ATM to process input/output. Other applications like TUIs are also easy to deal with as they already enter a different mode called raw mode - when a application requests that it can do what they currently do - switch to a new buffer and give full control to that one application.

    I can’t think of any, but I’m not the most creative person… what do you have in mind?

    Having smarter scroll back that knows the difference between a prompt/command and the output would let you do quite a few things that would be nice to have. Such as collapsing the output so you can only see the commands, keeping the command at the top of the screen even as other output scrolls off the top so you can always see what was running. Extra support for other UI elements could be nice to have as well - like tooltip support for blocks or similar.

    All the shell - or really any application - needs to do is tell the terminal which bits of the output are witch. Like mark the start/end of the prompt, command and command output. Then the fallback is basically ignore the markers and print things out like it currently does.

    And those are just random thoughts I have had over the last few days. These can be implemented in backwards compatible ways I believe and don’t need special support for specific shells - just needs to expand the VT100 protocols to be able to send more information between the terminal and shells/applications that are running. Much like how color, cursor positioning, entering/exiting raw mode etc are already done. Though I think some tight specialized integration might be a good start to explore these ideas before the protocols are formed.


  • What I would love to see is a terminal that builds it’s own shell from scratch too rejecting the ancient ideas we have with bash. I still love bash but I’m curious what could come of it.

    Thinking about it some more I am not sure that we would have to go that far. Well not in the longer term - short term we might for experimenting with ideas. I think one of the bigger problems ATM is the terminal does not understand what a shell is or its component parts. Terminals just display characters and move the cursor around the screen and send keyboard and now mouse input back to the command they run. They are also aware of alternative buffers and raw input mode and know about echoing characters back the the screen.

    If we extended the terminals to also understand some shell concepts like the prompt, commands being typed and output from the commands and gave the shell some markers it could send along with these (like we do with color information ATM) the terminal would be able to use these to change how it displays each part and would open up a lot of new an interesting features. Could even add things like tooltip support or actions on clicking some bits of the text.

    I am starting to see these terminals as experimenting on what we features could be enabled if we were not stuck on the current VT100 protocals. Though if we ever get wider adoption and generalisation of these ideas backed back into the protocals will be another question to consider.


  • Thinking about it some more I don’t think we would need to abandon the whole TTY to get a good set of the features. What is basically required for a lot of the features is more communication between the shell and the terminal. There is already some communication for basic things - like raw mode and alternative buffers, colors and even images. These are how TUI programs like vim or screen/tmux function and how you can exit them without losing what was previously in the buffer.

    I wonder if markers for the prompt and start/end of command output would probably enable a lot smarter virtual terminals with only some minor additions to the VT100 protocols. Possibly some extra data could be sent as well - like optional tooltip data maybe or even supporting actions that when the user clicks something it can send a response back to the shell. Maybe like a retry button on previous commands for example.

    There is quite a lot that could be done if the terminal and shells had better protocals to communicate between each other. I dont think these will change overnight though so seeing terminal emulators try out these features to find what people like/want to use IMO is a good thing to see where we can take things in the longer term.

    Would we have to abandon SSH or always X forward

    No we would not. At the end of the day a TTY is just a input and output pipe between the terminal and the program running on the shell with a specific protocal VT100 (or some bastardized version of that - looking at you xterm). This is what network protocals are as well - just with different protocals in play. So you can do a lot over that connection with changes to the protocals. No need for xforwarding at all.


  • nous@programming.devtoLinux@lemmy.mlNew terminal apps: Warp and Wave
    link
    fedilink
    English
    arrow-up
    3
    arrow-down
    1
    ·
    20 days ago

    Might I add the idea that your terminal emulator must support your shell is utterly ridiculous?

    TBH I am starting to come around to the idea of a tightly integrated shell and terminal emulator support. There are just things you cannot do with these being separate things. I am very tempted to explore the idea from the other end though - writing a shell that has a emulator built into it (like screen/tmux basically are). But I do think that this integration is needed for any per command features that is not just printing out a prompt.

    It would be interesting to see what could be done with this type of integration but will likely break support for existing shells. Unless you maybe launch a shell for each command you run or something 🤔. Would like to seem more people experimenting with stuff like this and see what new things we could drive forward. We have been stuck with the current tty system since like the 80s to support devices that just dont exist anymore.


  • nous@programming.devtoLinux@lemmy.mlNew terminal apps: Warp and Wave
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    1
    ·
    20 days ago

    I think the issue fundamentally is that this isn’t what terminal emulators are. The terminal emulator initializes a TTY session and enters a shell environment (sh, zsh, fish, etc). The medium is text and cannot be anything else.

    This is 90s thinking. Why must terminal emulators only be text and only do things that a physical terminal could? What makes teminals so nice is not that they work on 90s technology. Some terminal emualtors can already display images. Which is great. And the ideas they are introducing are still fundamentally text based, but are geared towards structuring that texts a bit more than a constant stream of characters on the screen.

    Skill issue. Pipe your output to something (like a file or the “less” command)

    This is a convenience issue not a skill issue. Yes you can pipe output to things but you need to know before hand that you want to do that. And with less you lose that output once you close less. And with files you have to clean them up after the fact. Both of these are inconvenient and need to be thought of before you run a command. IMO it would be nice to just run a command and then be able to collapse or expand or search its output after the fact and not have to preempt everything beforehand.

    The argument that you can already do that in a much less convenient way is not a very good argument.


  • nous@programming.devtoLinux@lemmy.mlNew terminal apps: Warp and Wave
    link
    fedilink
    English
    arrow-up
    6
    arrow-down
    1
    ·
    20 days ago

    Konsole can display images, as can kitty alacritty, western, iterm2, etc.

    They can now? I know it was possible in some niche terminals but never knew it was as wide spread as that.

    but it’s not exactly game changing

    None of these features on their own are game changing I agree. But lots of small nice to haves can end up being game changing overall. Again - I don’t think these terminals offer anywhere near enough to warrant their IMO massive downsides though. But I would love to see more innovation in the terminal emulator space.

    Lastly, searching explicitly your last command for a term with context would be much better suited to the shell to solve as it’d be terminal independent.

    I had a similar thought TBH. But the more I thought about it the more I came to see that in order to do this nicely - ie with inline scroll back or being able to collapse command output like these terminals do then you would basically need to implement a terminal emulator into the shell. Either way you are breaking down the wall between what a shell and a terminal emulator are doing. I would be interesting in exploring this from the shell side, though I cannot fault them from doing it from the emulator side either.

    couldn’t be solved at the shells level or with supplementary applications

    I think the key benefit here is integration rather than technical ability to do something. Making it easy and convenient to do goes a long way. There is a lot that can be made much nicer with things more tightly integrated together than trying to string up a bunch of disparate applications together - even if you can do it the integrated approach will give you a much more refined experience.

    I doubt they’re outright rejecting any idea of progress

    It sounds like an outright dismissal of new features to me.


  • nous@programming.devtoLinux@lemmy.mlNew terminal apps: Warp and Wave
    link
    fedilink
    English
    arrow-up
    11
    arrow-down
    15
    ·
    20 days ago

    That is the Luddites argument against progressing anything. There are many problems with current terminal emulators that these newer ones are trying to fix and make the terminal experience better overall. Terminals as they currently work were designed the way they are to talk to dumb typewriters with a screen (that’s right, not keyboards, digital typewriters). And they have barely changed at all since then.

    Personally looking at these terminals they have a lot of niceties that I would love to use. But IMO these benefits are not worth the costs these particular terminals also have. One being closed source and requiring an account and the other being electron - no benefit is worth that. But to bury your head in the sand and claim they have no benefits at all is wrong.

    Begin able to view images in the terminal would be amazing alone - just like you can cat a text file. I would hate to need to launch a GUI program every time I wanted to see what was inside a text file but that is exactly what I need to do for images or PDFs.

    Being able to collapse the output of a command would be nice as well. The number of times I have had to scroll for days to get to the output of a previous command because I happen to run a noisy one but still want to check what something previously had done would save me quite a bit of annoyance. And being able to search just the last commands output would be great - like an after the fact, interactive grep with context. And being able to quickly copy the output of the last command would also be great.


  • Just factor it into your estimates and make it a requirement to the work. Don’t talk to managers as though it is some optional bit of work that can be done in isolation. If you do frequent refactoring before you start a feature then it does not add a load of time as it saves a bunch of time when adding the feature. And helps keep your code base cleaner over the longer term leading to fewer times you need to do larger refactors.