Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1099705
  • 博文数量: 276
  • 博客积分: 8317
  • 博客等级: 少将
  • 技术积分: 2329
  • 用 户 组: 普通用户
  • 注册时间: 2006-09-12 08:17
个人简介

http://ads.buzzcity.net/adpage.php?partnerid=40096

文章分类

全部博文(276)

文章存档

2013年(1)

2012年(38)

2011年(102)

2010年(85)

2009年(45)

2008年(5)

分类: LINUX

2012-11-22 00:08:28

由于kde和gnome都太庞大了,我终于下定决心把小黑上的UI换成x window,不过这样一来有些功能不工作了,比如用快捷键切换显示器和投影这个。我选用的window manager是fluxbox,在xorg中,xrandr命令可以实现显示器切换功能,具体的使用方法可以参考man手册。我们做一个简单的脚本用于切换显示器: 

点击(此处)折叠或打开

  1. #!/bin/bash
  2. function show_vga()
  3. {
  4. xrandr --output LVDS1 --auto --output VGA1 --mode 1280x800
  5. echo "vga" > /dev/shm/xscreen-mode
  6. }
  7. function show_novga()
  8. {
  9. xrandr --output LVDS1 --auto --output VGA1 --off
  10. echo "novga" > /dev/shm/xscreen-mode
  11. }
  12. function show_ext()
  13. {
  14. xrandr --output LVDS1 --auto --output VGA1 --right-of LVDS1 --auto
  15. echo "ext" > /dev/shm/xscreen-mode
  16. }
  17. function show_vgaonly() {
  18. xrandr --output LVDS1 --off --output VGA1 --auto
  19. echo "vgaonly" > /dev/shm/xscreen-mode
  20. }
  21. case $1 in
  22. vga)
  23. show_vga
  24. ;;
  25. novga)
  26. show_novga
  27. ;;
  28. ext)
  29. show_ext
  30. ;;
  31. vgaonly)
  32. show_vgaonly
  33. ;;
  34. *)
  35. touch /dev/shm/xscreen-mode
  36. if [ "`cat /dev/shm/xscreen-mode`" = "vga" ]; then
  37. show_ext
  38. elif [ "`cat /dev/shm/xscreen-mode`" = "ext" ]; then
  39. show_novga
  40. elif [ "`cat /dev/shm/xscreen-mode`" = "novga" ]; then
  41. show_vgaonly
  42. else
  43. show_vga
  44. fi
  45. ;;
  46. esac
这个脚本支持四种模式,如果使用vga(外接投影仪),novga(无外接投影仪),ext(投影仪作为扩展模式),vgaonly(只外接投影仪)作为参数,他就会切换到相应的显示器模式。并且将当前的显示器模式写入/dev/shm/xscreen-mode这个文件中,如果不带参数调用该脚本则会根据/dev/shm/xscreen-mode中的最新状态依次循环切换这四种显示器模式。 
将这个脚本文件存放到 /usr/local/bin/xscreen 
打开可执行标志 
# chmod u+x /usr/local/bin/xscreen 
最后在~/.fluxbox/keys的文件末尾添加以下内容
XF86Display :Exec ~/bin/xscreen 
其中XF86Display所对应的键位就是切换屏幕的键位,我们可以通过"xbindkeys -mk"获取到这个按键的名称。当用户按下这个键时,系统就执行刚才编写的脚本,进行显示器切换。
阅读(1053) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~