2016年6月25日 星期六

reset USB device when resume/wakeup my desktop with linux mint 17 (ubuntu 14.04)

Cause I've replace my desktop before, from Homebuilt computer that old than 8-year
To brix mini computer, and I've solve the monitor VH226H HDMI source could not sleep issue by replace it to VGA source...

Now I have a computer that can sleep/hibernation and wakeup/resume
but following issue is, I've plug a DVB-T usb dongle on my Desktop, and I'm using Me-TV 1.4 as my TV player,
Me-TV 1.4 turn into server and client architecture, so server application will stay in background, keep open device

If computer sleep or hibernation, it wake up or resume quickly, but DVB-T dongle might be work abnormal, maybe the driver does not implement relative power management function? I don't know:~

I need replug my DVB-T dongle , kill Me-TV server manually to make it work
Hm.... Try to make it easier:)

put following code to /usr/lib/pm-utils/sleep.d, save as 99ZZ_my_script, and make it executable
it could kill me-tv both server and client when sleep,
and when you wake up, find the usb port number, force it reset

#!/bin/sh
# resume me-tv-client if exist

case "$1" in
hibernate|suspend)
#echo "7 blink" >/proc/acpi/ibm/led
killall me-tv-server
killall me-tv-client
;;
thaw|resume)
for X in /sys/bus/usb/devices/*; do
#if [ "$VID" == "$(cat $X/idVendor 2>/dev/null)" -a "$PID" == "$(cat $X/idProduct 2>/dev/null)" ]
if [ "MDTV Receiver" = "$(cat $X/product 2>/dev/null)" ]
then
Port_Number=`echo $X | awk -F / '{print $NF}'`
#echo "Found $Port_Number"
echo $Port_Number > /sys/bus/usb/drivers/usb/unbind
sleep 1
echo $Port_Number > /sys/bus/usb/drivers/usb/bind
break
fi
done
;;
*) exit $NA
;;
esac

exit 0



refer:
  1.  Run Script on Wakeup?
  2.  POWER OFF AND ON USB DEVICE IN LINUX (UBUNTU)

2016年6月19日 星期日

換了新眼鏡...

換了新眼鏡,留個紀錄
這次配的度數比較高一些,
不過好市多的眼鏡部,驗光比一般的眼鏡行要來的仔細咧...


Fix msmtp does not work in old ubuntu/debian version

主要是舊版msmtp沒有處理好email header 現在的smtp伺服器會檢查mail header 寄件人跟帳號不一致不給寄 收件人不是合法mail address自然不能寄 #!/bin/bash # Workaround until mtmsp >= 1.8....