我要啦免费统计
  • 嘿,ubuntu - [电脑生活]

    2009-01-18

    版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
    http://pchu.blogbus.com/logs/34066182.html

    标题与文章内容无关……

    ————{ 壹 }————

    上次说了在ubuntu下用wine运行迅雷的问题,目的自然是它自动运行,所以后来呢是写了几个小shell的,一直不记得拿出来show……

    xunlei

    #!/bin/sh
    export WINEPREFIX="$HOME/.ies4linux/ie6"
    export WINEDEBUG=warn-all,err-all,fixme-all,trace-all
    date 1>>$HOME/xunlei.log
    echo "xunlei starting..." 1>>$HOME/xunlei.log
    wine "$HOME/.ies4linux/ie6/drive_c/Program Files/Thunder Network/Thunder/Thunder.exe" 2>>/dev/null

    killxunlei

    #!/bin/sh
    date 1>>$HOME/xunlei.log
    echo "xunlei is stopped" 1>>$HOME/xunlei.log
    export WINEPREFIX="$HOME/.ies4linux/ie6"
    wineserver -k

    guard

    #!/bin/bash
    date 1>>$HOME/xunlei.log
    echo "xunlei guard is running..." 1>>$HOME/xunlei.log
    renice 19 -p $$
    export DISPLAY=:0.0
    zenity --progress --percentage=50 --auto-kill&
    while true
    do
    traffic=`sudo iptables -L INPUT -v -x | sed -n 1p | awk '{ print ($7)};'`
    if (( traffic>270000000 ))
    then
    /bin/bash /home/pchu/killxunlei.sh
    break 2
    else
    sleep 5
    fi
    done

    quota

    #!/bin/sh
    date +"%F %T"
    sudo iptables -L INPUT -v | awk '{ print($7)};' | sed -n 1p | sed -e 's/.*/& downloaded/'
    sudo iptables -L OUTPUT -v | awk '{ print($7)};' | sed -n 1p | sed -e 's/.*/& uploaded/'

    学校宿舍网络有流量限制,放假期间的一天内有五个重置点,所以那时候我用了这么些crontab:

    crontab -l

    # m h  dom mon dow   command
    0 6    * * *    export DISPLAY=:0.0 && /bin/bash /home/pchu/xunlei.sh
    30 6    * * *    /bin/bash /home/pchu/killxunlei.sh
    50 11,15,19,23    * * *    export DISPLAY=:0.0 && zenity --info --text "xunlei?"
    30 11,15,19,23    * * *    export DISPLAY=:0.0 && /bin/bash /home/pchu/xunlei.sh
    0 0,9,12,16,20    * * *    /bin/bash /home/pchu/killxunlei.sh

    sudo crontab -l

    # m h  dom mon dow   command
    0 0,9,12,16,20    * * *    date >>/home/pchu/xunlei.log && sudo iptables -L INPUT -v | awk '{ print($7)};' | sed -n 1p | sed -e 's/.*/& downloaded/' 1>>/home/pchu/xunlei.log && sudo iptables -L INPUT -Z
    0 0,9,12,16,20    * * *    sudo iptables -L OUTPUT -Z

    awk和sed真是好东西~~另,为了使得摆脱iptables每次都要sudo的问题和sudo只有十几分钟效用的问题,需要修改/etc/sudoers给与iptables命令足够的权限。警告!不要直接sudo修改,而是用visudo命令来修改(sudo visudo),加上这么几行:

    pchu    ALL=NOPASSWD: /sbin/iptables -L INPUT -Z
    pchu    ALL=NOPASSWD: /sbin/iptables -L OUTPUT -Z
    pchu    ALL=NOPASSWD: /sbin/iptables -L INPUT -v

     

    ————{ 贰 }————

    由于感觉linux下的celestia非常的卡,google得知是显卡驱动问题,进而回忆起我根本没特别去装显卡驱动,估计电脑只是在“得过且过”状态,故而google解决方案。中间过程略去,因为我着实走了弯路,估计是ATI的闭源驱动早就把的小黑X31的老卡给彻底忘了。LinuxSir论坛的一篇帖子也提到这一点。最后该感谢ubuntu论坛的ibm X31 Ati Mobility Radeon(M6) 驱动及开启3D全攻略,同样的方法对8.10版仍然通过。

    把重点复制过来,方便以后看:

    a.更新系统
    sudo apt-get update
    sudo apt-get upgrade
    b.确定显卡被识别
    lspci | grep ATI
    应该含有 "ATI Technologies Inc Radeon Mobility M6 LY"
    c.安装开源驱动
    (注意:如果您安装了frlgx驱动,则必须将其拆卸,最简便的方法是在“系统——系统管理——受限驱动管理器”中将启用勾掉,并重新启动计算机。 )
    glxinfo | grep vendor
    如果出现
    server glx vendor string: SGI
    client glx vendor string: SGI
    OpenGL vendor string: Tungsten Graphics, Inc.
    则可以继续安装开源驱动 。
    sudo apt-get remove xorg-driver-fglrx;
    sudo apt-get install libgl1-mesa-glx libgl1-mesa-dri
    d.配置开源驱动
    sudo dpkg-reconfigure xserver-xorg
    选择驱动时一般保持默认即可。
    sudo gedit /etc/X11/xorg.conf
    使用以下代码替换
    ############################
    Section "Module"
    Load "i2c"
    Load "bitmap"
    Load "ddc"
    Load "dri"
    Load "extmod"
    Load "freetype"
    Load "glx"
    Load "int10"
    Load "vbe"
    EndSection

    Section "Device"
    Identifier "ATI Technologies Inc Radeon Mobility M6 LY"
    Busid "PCI:1:0:0"
    Driver "radeon"
    Option "AGPSize" "32"
    Option "XAANoOffscreenPixmaps" "on"
    Option "AGPMode" "4"
    Option "AGPFastWrite" "on"
    Option "DisableGLXRootClipping" "on"
    Option "AddARGBGLXVisuals" "on"
    Option "AllowGLXWithComposite" "on"
    Option "EnablePageFlip" "on"
    EndSection

    Section "Monitor"
    Identifier "Generic Monitor"
    Option "DPMS"
    EndSection

    Section "Screen"
    Identifier "Default Screen"
    Device "ATI Technologies Inc Radeon Mobility M6 LY"
    Monitor "Generic Monitor"
    DefaultDepth 16
    SubSection "Display"
    Depth 8
    Modes "1024x768"
    EndSubSection
    SubSection "Display"
    Depth 16
    Modes "1024x768"
    EndSubSection
    SubSection "Display"
    Depth 24
    Modes "1024x768"
    EndSubSection
    EndSection

    Section "ServerLayout"
    Identifier "Default Layout"
    screen 0 "Default Screen" 0 0
    Inputdevice "Generic Keyboard"
    Inputdevice "Configured Mouse"
    Inputdevice "Synaptics Touchpad"
    option "AIGLX" "true"
    EndSection

    Section "DRI"
    Mode 0666
    EndSection

    Section "Extensions"
    Option "Composite" "Enable"
    EndSection
    ###############################
    然后保存文件重新启动计算机。
    e.检验设置
    glxinfo | grep “direct rendering”
    得到“direct rendering: Yes”,即为设置正确,否则请仔细检查上述步骤或考虑选用闭源驱动。

     

    ————{ 叁 }————

    为了常常提醒自己,我写了这么几个小shell:

    remind

    #!/bin/sh
    echo "export DISPLAY=:0.0 && zenity --info --text $2" 1>alert.tmp
    at $1 < alert.tmp
    rm alert.tmp

    vremind

    #!/bin/bash
    d=`date +%m%d%H%M`
    rec -r 20000 -t .ogg - | sox -t .ogg - $d.ogg vol 40 dB
    sox $d.ogg -n trim 0 1.5 noiseprof | sox $d.ogg -t .ogg - noisered - 0.2 lowpass 9000 | sox -t .ogg - $d.ogg
    echo "play /home/pchu/$d.ogg" 1>test.log
    at $1 < test.log

    没错vremind就是vocal remind的意思,这里面要用sox包,自己sudo apt-get install一下。

    包里有三个命令,rec是录音,-r是bit rate,“-t .ogg -”是以ogg格式用管道输入/输出。sox命令是音频处理,包括滤波、动态、移相、回响、去噪等等。所以我先trim出前面1.5秒用于生成noise profile,再用管道接到noisered参数后面,再低通一下,再用管道接给sox把结果保存下来。(似乎不允许直接sox一个文件,以原文件名保存结果)sox包里的第三个命令就是play了。

     

    ————{ 肆 }————

    有天我findsmb了一下,居然发现我们宿舍局域网里有一台Windows 7……

    那次我也想用samba共享以下文件,于是google到了这篇文章。要装samba包和smbfs包,之后修改/etc/samba/smb.conv

    ; security = user

    改成

    security = share

    还有

    usershare allow guests = yes

    之后重启samba:

    sudo /etc/init.d/samba restart

    之后共享目录的命令是这样的:

    sudo net usershare add photos /media/MUSIC\&PHOTO/photo/相片/ "" Everyone:R guest_ok=y

    如果要调整guest_ok成y,前面的参数comment和allow都要写上去("" 和 Everyone:R)


    历史上的今天:

    杂记 2009-01-18

    收藏到:Del.icio.us