Skip to content

Instantly share code, notes, and snippets.

@Efimenko
Last active January 21, 2020 07:28
Show Gist options
  • Select an option

  • Save Efimenko/4c9a74396cc376182b7b28ca8dcc551e to your computer and use it in GitHub Desktop.

Select an option

Save Efimenko/4c9a74396cc376182b7b28ca8dcc551e to your computer and use it in GitHub Desktop.
---getBatteryStats.sh---
#!/bin/bash
battery0=''
battery25=''
battery50=''
battery75=''
battery100=''
acConnectionIcon='
ﮣ
'
batteryCharge=`pmset -g batt | tail -n -1 | awk '{printf "%d", $3}'`
powerWattage=`pmset -g ac | head -n 1 | awk '{printf "%d", $3}'`
icon=battery0
if (( batteryCharge > 75 )); then
icon=$battery100
elif (( batteryCharge > 50 )); then
icon=$battery75
elif (( batteryCharge > 25 )); then
icon=$battery50
elif (( batteryCharge > 5 )); then
icon=$battery25
else
icon=$battery0
fi
printf "$icon $batteryCharge%%%s%s%s\n" $( [ $powerWattage -gt 0 ] && echo "$acConnectionIcon $powerWattage W")
---getCpuUsage.sh----
#!/bin/bash
top -l 1 | head -n 4 | tail -n 1|awk '{printf "%3d%%\n", $3}'
---getMemUsage.sh----
#!/bin/bash
top -l 1 | head -n 7 | tail -n 1|awk '{printf "%s\n", $2}'
----spotify.sh----
music=$(osascript ~/applescript/spotify.scpt)
if [[ $music ]]; then
echo "$music"
fi;
-----spotify.scpt------
if application "Spotify" is running then
tell application "Spotify"
set theName to name of the current track
set theArtist to artist of the current track
set theAlbum to album of the current track
set theUrl to spotify url of the current track
set playerState to player state
if playerState is playing then
set playIcon to "Playing:"
end if
if playerState is paused then
set playIcon to "Paused:"
end if
try
return playIcon & " " & theName & " by " & theArtist
on error err
end try
end tell
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment