brodierobertson / scripts Goto Github PK
View Code? Open in Web Editor NEWMessing around with shell scripting because it seems like fun, maybe you'll find something useful
License: GNU General Public License v3.0
Messing around with shell scripting because it seems like fun, maybe you'll find something useful
License: GNU General Public License v3.0
I thought you might be interested in this:
#!/usr/bin/env bash
read -a ARRAY <<< `df -h -l --output=pcent /home`
VALUE="${ARRAY[1]%\%}"
if [ $VALUE -gt 90 ]; then
printf "\e[1;31m%s%%\e[0m\n" "$VALUE"
else
printf "%s%%\n" "$VALUE"
fi
It saves the need for and loading up of awk
, which I believe is a lot faster (good for polling) but the caveat is that it needs bash
, whereas your previous script uses sh
. If you're okay with that.
However, this works differently, as I thought I'd offer something slightly different, in that this will instead turn red when the percentile hits and exceeds 90%. On that note, this will show the percentage of space used on the provided device. The previous behavior shouldn't be a problem to replicate, though.
Less parsing is needed too, since df
is specifying to only display one field (plus header, sadly).
The code here is more of a proof of concept, by the way; I realise it might be missing some stuff you'd otherwise have.
you have defined a shortcut in your i3 config and have a readme entry for "mntandroid", but the script is not in your repo.
is the script really missing, as you are currently using bspwm and there is no shortcut in your shxkd config.
I noticed a number of these scripts are marked as #!/bin/sh
, but still have some bashisms. I was running some on my system where I have sh
linked to dash
and had errors due to this (it would be the same on Ubuntu/Debian, where dash is default, I believe). I'd recommend running shellcheck
on them all to be careful.
In general:
printf "%s" "$var"
rather than echo -n "$var"
.==
is a bashism too, but it looks like a simple =
would suffice in most places in these scripts.[[ ]]
are undefined in posix as well.Again, shellcheck is the easiest way to know what's what. Otherwise, it's better to mark them as bash scripts.
This works for me:
#!/bin/sh
set -e
thumb=$(playerctl metadata --format '{{lc(mpris:artUrl)}}')
song=$(playerctl metadata --format "Title: {{ title }}\nArtist: {{ artist }}\nAlbum: {{ album }}")
convert "$thumb" -flatten -thumbnail 256x256 /home/dboneham/.icons/target && dunstify -I /home/dboneham/.icons/target -t 5000 "Spotify" "$song"
Depends on dunstify, playerctl, convert (ImageMagick)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.