[ Content | Sidebar ]

Archives for linux

shell:列出子目录的大小

偶尔看了一下磁盘状况,分给home的一百多G竟然快用光了
/dev/sda8 101G 80G 17G 84% /home

于是找出老早之前写的一句拿出来跑跑,列出所有上M的目录

ls -la|grep ^d|awk '{print $8}'|xargs -i du -sh {}|grep M
Copy Code 

———–
post by gmail~

一个python版的开源web截图工具:python-webkit2png

http://github.com/AdamN/python-webkit2png/
一个使用pyqt4里的QtWebkit实现的命令行的web截图软件,可用于服务器端的web截图
貌似是个比较新的项目,以前找过类似的工具,没有多好用的,但是这个真的很好用,看一下参数就知道了

Creates a screenshot of a website using QtWebkit.This program comes with
ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to
redistribute it under the terms of the GNU General Public License v2.
 
Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -x WIDTH HEIGHT, --xvfb=WIDTH HEIGHT
                        Start an 'xvfb' instance with the given desktop size.
  -g WIDTH HEIGHT, --geometry=WIDTH HEIGHT
                        Geometry of the virtual browser window (0 means
                        'autodetect') [default: (0, 0)].
  -o FILE, --output=FILE
                        Write output to FILE instead of STDOUT.
  -f FORMAT, --format=FORMAT
                        Output image format [default: png]
  --scale=WIDTH HEIGHT  Scale the image to this size
  --aspect-ratio=RATIO  One of 'ignore', 'keep', 'crop' or 'expand' [default:
                        none]
  -F FEATURE, --feature=FEATURE
                        Enable additional Webkit features ('javascript',
                        'plugins')
  -w SECONDS, --wait=SECONDS
                        Time to wait after loading before the screenshot is
                        taken [default: 0]
  -t SECONDS, --timeout=SECONDS
                        Time before the request will be canceled [default: 0]
  -W, --window          Grab whole window instead of frame (may be required
                        for plugins)
  --style=STYLE         Change the Qt look and feel to STYLE (e.G. 'windows').
  -d DISPLAY, --display=DISPLAY
                        Connect to X server at DISPLAY.
  --debug               Show debugging information.
  --log=LOGFILE         Select the log output file
Copy Code 

使用举例:
使用之前安装依赖的包

sudo apt-get install python-qt4
Copy Code 

OK,可以用了,假如在用ubuntu桌面版的话就很简单了

#加上运行权限 
chmod +x ./webkit2png.py
#高度设置为0,就可以获得整个页面的截图了
./webkit2png.py -g 1024 0 http://bluehua.org -o test.png
Copy Code 

假如运行在服务器上,没有x环境,则需要安装一些额外的依赖包

#安装xvfb用于虚拟X环境
apt-get install xvfb
#安装中文字体
apt-get install xfonts-wqy
#配置字体
fontconfig-voodoo -f -s zh_CN
Copy Code 

运行时需要加额外的参数

#x选项用于指定虚拟出来的X桌面的尺寸
./webkit2png.py -x 1024 768 -g 1024 0 http://bluehua.org -o test.png
Copy Code 

恩,其实我找这个东西的目的是想在服务器端获取一个页面的实际渲染宽度,目的达成~

———–
post by gmail~

列出所有可用的dbus服务

还是记下,用一次查一次。。

dbus-send --system --print-reply --type=method_call  --dest="org.freedesktop.DBus"  /org/freedesktop/DBus  org.freedesktop.DBus.ListNames
dbus-send --print-reply --type=method_call  --dest="org.freedesktop.DBus"  /org/freedesktop/DBus  org.freedesktop.DBus.ListNames
Copy Code 

———–
post by gmail~

remuco,一个linux平台的播放器遥控软件

看书的时候一般不会听音乐,因为一旦冒出一个不想听的就想去换一首。今天找到了remuco (http://code.google.com/p/remuco/)这个牛b的开源软件,可以用手机通过蓝牙或者wifi遥控linux上的播放器。

上面是E71上控制端的截图,控制我本子上的mpd播放器。除了mpd,还支持Amarok ,Audacious ,Banshee , Exaile  , MPlayer,Rhythmbox  , Songbird , Totem  ,TVtime ,VLC , XMMS2。控制端是用java写的,一般支持java的手机应该都可以用。很佩服这个软件的作者,一个小众的开源软件能做到这么强大。

写下mpd服务端安装步骤:

#安装依赖
sudo apt-get install python-bluetooth python-mpd
tar -zxvf remuco-0.9.2.tar.gz
cd remuco-0.9.2
#安装mpd服务端
sudo make install-mpd
#运行服务端
sudo remuco-mpd
Copy Code 

terminal里看农历的东西

曾经装了一个 liblunar ,用来在gnome panel里显示农历日历,今天升级到10.04,发现不灵了。由于liblunar提供了python的lib,于是简单写了一个命令行版的前端,顺便保持对python的熟悉程度。最近接触的语言有点杂,码代码时经常会搞混。。。

下载:zhcal.zip

使用之前需要安装liblunar,编译选项

./configure --prefix=/usr --enable-python
make
sudo make install
Copy Code 

———————————–
另:分享一个firefox插件default full zoom level, 可以设置页面的默认缩放级别,对于高分屏的同学会有帮助~
现在终端的字体我已经调到16,浏览器默认缩放120%,基本上回到1024时代~