Commands using acpi (12)

  • 3
    acpi -tc
    hypnojazz · 2009-03-29 22:27:31 2
  • The original proc file doesn't exist on my system. Show Sample Output

    acpi -b
    dbbolton · 2010-06-10 23:23:16 1
  • There is no need for variables. I also added sleep to reduce cpu usage, however I didn't test it.

    while :; do acpi -t | osd_cat -p bottom ; sleep 1; done &
    John_W · 2011-01-14 13:57:45 4
  • My firefox overheats my cpu, sometimes above 90 degrees Celsius ( hence the name? ) To keep an eye on temperature, I put this command inside KAlarm ( a kind of cron) to be repeated every minute, for 5 seconds, color red ( default for osd_cat). Its pretty, ultra small, displays a micro 2 lines text on every desktop and over everything and do not steal focus or interrupt any task. I get the information passively, in the low profile bottom of the screen. Of course you can use it inside a terminal. Just do it: watch -n 60 'acpi -t | osd_cat -p bottom'

    acpi -t | osd_cat -p bottom
    m33600 · 2009-10-23 05:22:01 0
  • works best in a shell script run at startup. It will ping localhost once and output to null, after it does that, acpi is called for temperature in fahrenheit and piped through to another loop that feeds notify-send for a tooltip. After waiting five minutes, it will start over. Show Sample Output

    while ping -c 1 > /dev/null; do acpi -t -f | while read tem; do notify-send "$tem"; done; sleep 300; done
    c0de · 2011-07-02 06:47:25 2
  • This time I added a print to reemaining energy, every minute, time stamped. The example shown here is complete and point to large discrepancies as time passes, converging to accuracy near the end. Show Sample Output

    echo start > battery.txt; watch -n 60 'date >> battery.txt ; acpi -b >> battery.txt'
    m33600 · 2009-10-19 05:28:15 0

  • 1
    acpi -V
    vajorie · 2010-06-09 14:23:08 0

  • 1
    acpi -a
    wiburg · 2010-06-12 20:07:27 0
  • No need for a colon, and one less semicolon too. Also untested.

    while sleep 1; do acpi -t | osd_cat -p bottom; done &
    linuts · 2011-01-14 23:22:57 0
  • This prints "Charging" or "Discharging". Obviously, this will indicate the status of the AC adapter. The awk part could be from 1-6. I removed the comma because it is useless when only looking at one element of the output array. See acpi(1) for more info.

    acpi -b | sed 's/,//g' | awk '{print $3}'
    dbbolton · 2010-06-11 05:32:57 0

  • -2
    acpi | cut -d '%' -f1 | cut -d ',' -f2
    sn0opy · 2009-02-16 13:36:01 3
  • Checks whether your power supply is still plugged in. If not it will trigger an alarm at maximum volume. Show Sample Output

    check(){ power=$(acpi -a) ; if [[ $power == *on-line* ]] ; then echo "supply is on"; else echo "somebody is steeling your laptop"; amixer -c0 set Master 100+ unmute ; mpg123 nuclear-alarm.mp3 ; fi } ;while true; do check ; sleep 2 ; done
    hoodie · 2011-12-10 13:42:52 0

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

Fast search in man files or bz-files by keyword direct by man or bz files
For example we need find fast where located and described keyword COMMIT_EDITMSG in man files. Here example howto solve it by search with command bzgrep in man files. Generally these files in bz compressed format. You can use another keywords to your search. Common syntax is: bzgrep -lE keyword1 /usr/share/man/man?/optional-keyword-to-refine* or bzgrep -lE keyword1 /usr/share/man/man?/* where optional-keyword-to-refine is optional and may be omitted but used to speedup search Of course you may combine other options for bzgrep (its based on grep)

Redirect STDIN
Several times, I find myself hitting my up arrow, and changing the search term. Unfortunately, I find myself wasting too much time typing: $ grep kernel /var/log/messages Redirecting STDIN allows me to put the search term at the end so I less cursor movement to change what I'm searching for: $ < /var/log/messages grep kernel If you're using the emacs keyboard binding, then after you press your up arrow, press CTRL+w to erase the word. If this has already been submitted, I couldn't find it with the search utility.

Print a monthly calendar with today's date highlighted
The cal command is handy, but sometimes you want to quickly see today's date highlighted. That's why I came up with this quick command. Much like but cleaner and more succinct.

Change prompt to MS-DOS one (joke)

Create a continuous digital clock in Linux terminal

summarize a list of IP addresses, verifying IP address and giving counts for each IP found
Working with lists of IP addresses it is sometimes useful to summarize a count of how many times an IP address appears in the file. This example, summarizeIP, uses another function "verifyIP" previously defined in to ensure only valid IP addresses get counted. The summary list is presented in count order starting with highest count.

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Find biggest 10 files in current and subdirectories and sort by file size

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

In Mac OS X, read the copy area (CMD + V) and convert text to audible speech

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: