mirror of https://github.com/artizirk/dotfiles
Arti Zirk
5 years ago
2 changed files with 98 additions and 0 deletions
@ -0,0 +1,47 @@ |
|||||||
|
#!/bin/bash |
||||||
|
|
||||||
|
current=`xbacklight -get` |
||||||
|
# alternatively, if xbacklight does not work: |
||||||
|
# current=`qdbus org.gnome.SettingsDaemon.Power /org/gnome/SettingsDaemon/Power org.gnome.SettingsDaemon.Power.Screen.GetPercentage` |
||||||
|
|
||||||
|
scale="1 2 5 10 20 50 100" |
||||||
|
|
||||||
|
case $1 in |
||||||
|
"down") |
||||||
|
# translate space to newline so tac will reverse order of lines (values) |
||||||
|
for val in $(tr ' ' '\n' <<< $scale | tac) ; do |
||||||
|
# scale = 3 to preserve some decimal values |
||||||
|
if (( $(bc <<< "scale=3 ; $val < $current/1.1") )) ; then |
||||||
|
newval=$val |
||||||
|
break |
||||||
|
fi |
||||||
|
done |
||||||
|
;; |
||||||
|
"up") |
||||||
|
for val in $scale ; do |
||||||
|
# scale = 3 to preserve some decimal values |
||||||
|
if (( $(bc <<< "scale=3 ; $val > $current*1.1") )) ; then |
||||||
|
newval=$val |
||||||
|
break |
||||||
|
fi |
||||||
|
done |
||||||
|
;; |
||||||
|
*) |
||||||
|
echo "Usage: $0 [up, down]" |
||||||
|
exit 1 |
||||||
|
esac |
||||||
|
|
||||||
|
if [ "x$newval" == "x" ] ; then |
||||||
|
echo "Already at min/max." |
||||||
|
else |
||||||
|
echo "Setting backlight to $newval." |
||||||
|
|
||||||
|
# thanks: https://bbs.archlinux.org/viewtopic.php?pid=981217#p981217 |
||||||
|
notify-send " " -i notification-display-brightness-low -h int:value:$newval -h string:x-canonical-private-synchronous:brightness & |
||||||
|
|
||||||
|
xbacklight -set $newval -steps 1 -time 0 |
||||||
|
# alternatively, if xbacklight does not work: |
||||||
|
# qdbus org.gnome.SettingsDaemon.Power /org/gnome/SettingsDaemon/Power org.gnome.SettingsDaemon.Power.Screen.SetPercentage $newval |
||||||
|
fi |
||||||
|
|
||||||
|
exit 0 |
@ -0,0 +1,51 @@ |
|||||||
|
#!/bin/bash |
||||||
|
|
||||||
|
####################################### |
||||||
|
# Variables # |
||||||
|
####################################### |
||||||
|
|
||||||
|
SSD_DEVICE="/dev/sda" |
||||||
|
|
||||||
|
ON_TIME_TAG="Power_On_Hours" |
||||||
|
WEAR_COUNT_TAG="Wear_Leveling_Count" |
||||||
|
LBAS_WRITTEN_TAG="Total_LBAs_Written" |
||||||
|
LBA_SIZE=512 # Value in bytes |
||||||
|
|
||||||
|
BYTES_PER_MB=1048576 |
||||||
|
BYTES_PER_GB=1073741824 |
||||||
|
BYTES_PER_TB=1099511627776 |
||||||
|
|
||||||
|
####################################### |
||||||
|
# Get total data written... # |
||||||
|
####################################### |
||||||
|
|
||||||
|
# Get SMART attributes |
||||||
|
SMART_INFO=$(sudo /usr/sbin/smartctl -A "$SSD_DEVICE") |
||||||
|
|
||||||
|
# Extract required attributes |
||||||
|
ON_TIME=$(echo "$SMART_INFO" | grep "$ON_TIME_TAG" | awk '{print $10}') |
||||||
|
WEAR_COUNT=$(echo "$SMART_INFO" | grep "$WEAR_COUNT_TAG" | awk '{print $4}' | sed 's/^0*//') |
||||||
|
LBAS_WRITTEN=$(echo "$SMART_INFO" | grep "$LBAS_WRITTEN_TAG" | awk '{print $10}') |
||||||
|
|
||||||
|
# Convert LBAs -> bytes |
||||||
|
BYTES_WRITTEN=$(echo "$LBAS_WRITTEN * $LBA_SIZE" | bc) |
||||||
|
MB_WRITTEN=$(echo "scale=3; $BYTES_WRITTEN / $BYTES_PER_MB" | bc) |
||||||
|
GB_WRITTEN=$(echo "scale=3; $BYTES_WRITTEN / $BYTES_PER_GB" | bc) |
||||||
|
TB_WRITTEN=$(echo "scale=3; $BYTES_WRITTEN / $BYTES_PER_TB" | bc) |
||||||
|
|
||||||
|
# Output results... |
||||||
|
echo "------------------------------" |
||||||
|
echo " SSD Status: $SSD_DEVICE" |
||||||
|
echo "------------------------------" |
||||||
|
echo " On time: $(echo $ON_TIME | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta') hr" |
||||||
|
echo "------------------------------" |
||||||
|
echo " Data written:" |
||||||
|
echo " MB: $(echo $MB_WRITTEN | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')" |
||||||
|
echo " GB: $(echo $GB_WRITTEN | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')" |
||||||
|
echo " TB: $(echo $TB_WRITTEN | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')" |
||||||
|
echo "------------------------------" |
||||||
|
echo " Mean write rate:" |
||||||
|
echo " MB/hr: $(echo "scale=3; $MB_WRITTEN / $ON_TIME" | bc | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')" |
||||||
|
echo "------------------------------" |
||||||
|
echo " Drive health: ${WEAR_COUNT} %" |
||||||
|
echo "------------------------------" |
Loading…
Reference in new issue