Things to be done in this weekend

I have to finish the following things:

  • Python Scripts which fetch back the Baidu disk, finish the exception.
  • RealTime OS on ATMEga328.
  • Python API for fetching back the pm data should be updated.
  • tumx learning.
  • Use markdown for writing the CV.
  • Hard disk cleaning and orgnization.
  • Writing articles for enum feature.
  • Maybe the pelican template should be written.

Converting Markdown into PDF under ArchLinux

Today I want to convert the webpages which wrote from markdown into PDF format file. Following is the steps for how to convert. Just one command is OK:

	pandoc jailbreak.md -o jailbreak.pdf --latex-engine=xelatex -V mainfont="WenQuanYi Zen Hei"

But the link will cause the format ugly, then we have to use a template for fixing this, download the template from following URL: https://raw.github.com/tzengyuxio/pages/gh-pages/pandoc/pm-template.latex Then put it into the same directory, replace the following lines with the fonts which you have installed on your system:

	# Following will be deleted
	\setCJKmainfont{LiHei Pro} 	% 設定中文字型
	\setCJKmainfont{WenQuanYi Zen Hei} 	% 設定中文字型

Now you lock of Microsoft fonts, simply copy it from your own windows machine, and setup a link

	ln -s /windows/Windows/Fonts /usr/share/fonts/WindowsFonts
	# Update font cache
	fc-cache

Generate the pdf file with the following command:

	pandoc jailbreak.md -o jailbreak1.pdf --latex-engine=xelatex -V mainfont="WenQuanYi Zen Hei" --template=pm-template.latex

Now you will see the well-formated PDF file has been generated from the Markdown file.

/images/wellpdf.jpg

rip mp3 under ArchLinux

First you have to install sound-juicer, by:

	sudo pacman -S sound-juicer

Run “sound-juicer” will call the sound-juicer out, remember the pulse-audio should be started before the sound-juicer is called.

On start, sound juicer will automatically scan the CD-ROM, and retrieve back the track listing, this will take for a while. Sorry, failed. …

goobox is only a CD Player

grip is good, just use it for cd mp3 gripping.

After gripping the sound-track, the generated mp3 file is listed under the directory that your specified, with a m3u file and the mp3 fils. Here comes a new problem, how to rename from the m3u file?
Following is the bash script for doing this:

#!/bin/bash
number=0
# Make the directory for processed result
mkdir -p ./changed
underscore="_"
for filename in `cat ./verschiedene_knstler-piano_piano.m3u`
do
	number=`expr $number + 1`
	# How to get the filename? 
	file_basename=`basename $filename`
	#echo $file_basename
	if [ $number -lt 10 ]
	then
		# Add 0 before the number,
		# and form the name like "01_abc"
		zeroprefixname="0$number$underscore$file_basename"
		echo $zeroprefixname
		cp $filename ./changed/$zeroprefixname
	else
		# The name needn't add 0
		prefixname=$number$underscore$file_basename
		echo $prefixname
		cp $filename ./changed/$prefixname
	fi
done

Adding Battery Widget and ACPI Notification in Awesome

For keeping the “Clean Desktop”, the cleaner in my office unpluged my laptop’s powerline, and the laptop suddenly going to black when I was coding, so I want to write some scripts for calculating the battery’s power percentage and got notification when the power of the battery is too low. ###Add an indicator in Awesome Desktop Awesome have a very good 3rd-party library called “Vicious”, its page is athttp://awesome.naquadah.org/wiki/Vicious, following the guideline for install and configure it. Install the library:

	$ cd ~/.config/awesome
	$ git clone http://git.sysphere.org/vicious

Modify the rc.lua to add following lines:

-- Using vicious
-- Vicious is a modular widget library for awesome, derived from the Wicked widget library. 
vicious = require("vicious")

-- Add the Battery 
mybattery = wibox.widget.textbox()
vicious.register(mybattery, vicious.widgets.bat, "||Battery: $2% ", 30, "BAT0")

-------------------------------------
right_layout:add(mytextclock)
-- We add mybattery here!
right_layout:add(mybattery)
right_layout:add(mylayoutbox[s])
-------------------------------------


After modification, save the rc.lua and restart the awesome desktop, you will see the following pictures. /images/awesomebattery.jpg ###Add notification when battery is too low We can use acpi for getting the battery and power supply information, so first let’s install it:

	$ sudo pacman -S  acpi

Then we can write an script named notifybattery.sh, put it under the /bin folder:

battery_level=`acpi -b | grep -P -o '[0-9]+(?=%)'`
if [ $battery_level -le 10 ]
then
    notify-send "Battery low" "Battery level is ${battery_level}%!"
fi

Then we add an item under crotab:

	$ crontab -e
	# crontab's configuration:
	2 * * * * /bin/notifybattery.sh

Now we can got an indication when battery is less than 10%. you can adjust the number to whatever you want.

Write Local ntp sync server

Due to frequently query the ntp webserver, the website is banned by the administrator, thus I have to think about another way for updating the local machine’s time on OpenWRT.
First, install the coreutils-date: opkg install coreutils-date Add the no-login for local server: cat id_rsa.pub | ssh ddddd@1xx.xxx.xxx.xxx ‘cat >.ssh/authorized_keys’ Now you can directly call remote command via: ssh ddddd@1xx.xxx.xxx.xxx ls OK, we update the time.sh

#!/bin/sh
#echo $http_proxy
#echo $https_proxy
#date $(wget -O - "http://www.timeapi.org/utc/in+eight+hours" 2>/dev/null | sed s/[-T:+]/\ /g | awk '{print $2,$3,$4,$5,".",$6}' | tr -d " " )
timestring=`ssh ddddd@1xx.xxx.xxx.xxx date`
echo $timestring
/usr/bin/date -s "$timestring"

Add the following line into the crontab * */3 * * * /bin/time.sh Now you can enjoy the local server updated time.