解决secureCRT和vim乱码

2011年9月03日 14:50

secureCRT 和 vim 都有乱码问题,有时候以为是一个的问题结果却是另一个的,不如统一设成utf-8。

对于 secureCRT:
会话选项 -> 终端 ->外观:字体选为 fixsys 或 terminal,字体编码选为UTF-8。

对于 vim:
.vimrc 中加入:
set encoding=utf-8
set fileencodings=utf-8,chinese,latin-1

对于文件:
用:
$ file 文件命名
来查看文件编码,用:
$ iconv -f big5 -t UTF-8 -o users.txt users.utf8.txt
转换文件编码。
如果按如上 vim 设置后,文件打开无乱码,可用:
:set fenc
查看文件编码,用:
:set fenc=utf-8
转换文件编码并保存。

对于screen,新开或恢复时都加-U参数就可以了。

评论(1) 阅读(4141)

改变/home的挂载

2011年7月22日 09:46

问题:由于在virtualbox里装archlinux时非常懒的选择了自动分区,导致/home只有300多MB,这日子可没法过了,于是想改变分区大小或者把/home挂载回/,显然后者简单安全些

步骤:

进入单用户模式:
init 1
查看/home挂载的分区:
df -h
保存/home的数据:
cp -r -p /home /root/
umount掉/home:
umount /dev/sda4
现在的/home就是在/所在的分区下了,拷回来:
cp -r -p /root/home/* /home
编辑开机自动挂载的文件,去掉原来/home的挂载的那一行:
vim /etc/fstab
退出单用户模式:
exit

评论(1) 阅读(2439)

恢复 gnome 中默认的启动项

2011年5月12日 16:13

在gnome-session-properties中研究着有哪些启动项,手滑,想点编辑结果点到了删除......囧了

通过google大致了解到现在gnome-session-properties主要和~/.config/autostart这个文件夹下的条目相关,进行了一番实验,找到一些规律:

 

1.新加入的条目会以XXX.desktop的文件形式出现在这里;gnome默认的启动项则不会出现

2.当对gnome默认的启动项进行暂时取消启动或删除的操作时,该文件夹下会出现对应的XXX.desktop

2.删除条目,若不是gnome默认的启动项的话,则XXX.desktop会消失;若是gnome默认的启动项,则出现XXX.desktop且最下面已被加入一行Hidden=true

2.暂时取消启动条目,对应的XXX.desktop下会有X-GNOME-Autostart-enabled=false这么一句,对于新加入条目来说原本为true

 

好了,说这么多,主要就是说如果一不小心删除了gnome默认的启动项的话,只要到这个文件夹下 把对应的XXX.desktop删除就好了

 

update:默认启动项原来在/etc/xdg/autostart......

评论(2) 阅读(3600)

linux下使用xlib模拟鼠标移动和点击

2010年11月11日 20:36

/* ref: http://www.ishiboo.com/~danny/Projects/xwarppointer/ */
#include <stdio.h>
#include <string.h>
//头文件
#include <unistd.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
//全局变量
Display *display;
Window root;
//初始化
void init()
{
    if ((display = XOpenDisplay(NULL)) == NULL) {
        fprintf(stderr, "Cannot open local X-display.\n");
        return;
    }
    root = DefaultRootWindow(display);
}
//得到坐标
void GetCursorPos(int &x,int &y)
{
    int tmp;unsigned int tmp2;
    Window fromroot, tmpwin;
    XQueryPointer(display, root, &fromroot, &tmpwin, &x, &y, &tmp, &tmp, &tmp2);
}
//设置坐标
void SetCursorPos(int x,int y)
{
    int tmp;
    XWarpPointer(display, None, root, 0, 0, 0, 0, x, y);
    XFlush(display);
}

//模拟点击
/* http://www.linuxquestions.org/questions/programming-9/simulating-a-mouse-click-594576/ */
void mouseClick(int button)
{
    Display *display = XOpenDisplay(NULL);

    XEvent event;

    if(display == NULL)
    {
        printf("Errore nell'apertura del Display !!!\n");
        return;
    }

    memset(&event, 0x00, sizeof(event));

    event.type = ButtonPress;
    event.xbutton.button = button;
    event.xbutton.same_screen = True;

    XQueryPointer(display, RootWindow(display, DefaultScreen(display)), &event.xbutton.root, &event.xbutton.window, &event.xbutton.x_root, &event.xbutton.y_root, &event.xbutton.x, &event.xbutton.y, &event.xbutton.state);

    event.xbutton.subwindow = event.xbutton.window;

    while(event.xbutton.subwindow)
    {
        event.xbutton.window = event.xbutton.subwindow;

        XQueryPointer(display, event.xbutton.window, &event.xbutton.root, &event.xbutton.subwindow, &event.xbutton.x_root, &event.xbutton.y_root, &event.xbutton.x, &event.xbutton.y, &event.xbutton.state);
    }

    if(XSendEvent(display, PointerWindow, True, 0xfff, &event) == 0) printf("Errore nell'invio dell'evento !!!\n");

    XFlush(display);

    usleep(100000);

    event.type = ButtonRelease;
    event.xbutton.state = 0x100;

    if(XSendEvent(display, PointerWindow, True, 0xfff, &event) == 0) printf("Errore nell'invio dell'evento !!!\n");

    XFlush(display);

    XCloseDisplay(display);
}
int main()
{
    init();
    int x,y;
    GetCursorPos(x,y);
    printf("%d %d\n",x,y);
    SetCursorPos(0,0);
    XCloseDisplay(display);
    mouseClick(Button1);
    return 0;
}

 

评论(1) 阅读(8264)

archlinux 2010.05 安装笔记

2010年7月25日 17:08

刻盘启动

root 无密码

# /arch/setup

分区 选择软件包 安装软件包

配置系统

/etc/rc.conf: 语言(可稍后设置免得命令行下方块) 网络部分

/etc/resolv.conf: 设置dns服务器

/etc/locale.gen: 反注释zh_CN开头的四行

选定pacman镜像 设定root密码 安装grub

就可以重启了

 

ping -c www.google.com

网络不通的话 再配置/etc/rc.conf /etc/resolv.conf

开启ipv6

modprobe ipv6

新建用户

useradd -m -G users,audio,lp,optical,storage,video,wheel,power -s /bin/bash yourusername

passwd yourusername

在/etc/pacman.conf文件里,最后添加两行

[archlinuxfr]
Server = http://repo.archlinux.fr/$arch

更新系统

pacman -Syu

安装yaourt:  pacman -S yaourt

安装sudo: pacman -S sudo

然后 visudo 加入 YOURNAME ALL=(ALL) NOPASSWD: SETENV: ALL 就不用输密码了

安装alsa(参照wiki)

安装ati显卡驱动

pacman -S xf86-video-ati libgl ati-dri

安装xorg,生成 xorg.conf 配置文件

pacman -S xorg

Xorg -configure

(测试见官方指南)

cp /root/xorg.conf.new /etc/X11/xorg.conf

安装字体

pacman -S ttf-dejavu ttf-bitstream-vera

pacman -S wqy-zenhei

yaourt ttf-ms-fonts wqy-microhei

安装gdm : pacman -S gdm 添加到rc.conf 的 DEAMONS 保证顺序(dbus hal gdm)

安装gnome

pacman -S gnome gnome-extra gnome-system-tools

pacman -S hal dbus

DEAMONS 里添加 hal , MODULES里添加 fuse

基本搞定。。。待续

评论(3) 阅读(6511)