openbox在ubuntu下安装及配置

一、系统安装:

$  nano sys.sh

#!/bin/sh

# install program
sudo apt-get install build-essential xorg openbox pcmanfm udevil sshfs -y
sudo apt-get install bcmwl-kernel-source broadcom-sta-common -y
sudo apt-get install gksu hal-info upower pm-utils python-software-properties software-properties-common xvfb -y
sudo apt-get install feh tint2 lxappearance obmenu qt4-qtconfig gnome-icon-theme ubuntu-mono pixmap gtk2-engines-murrine gtk2-engines-pixbuf gtk3-engines-unico dmz-cursor-theme -y
sudo apt-get install fcitx-rime wicd compton fonts-droid xscreensaver numlockx xdg-user-dirs -y
sudo apt-get install tilda xarchiver zip unzip p7zip-full rar unrar firefox firefox-locale-zh-hans -y
#sudo apt-get install openbox-xdgmenu xdotool gnome-screenshot -y

# set audio
sudo apt-get install alsa-base alsa-utils alsa-tools-gui -y
sudo alsactl init
sudo apt-get install volumeicon-alsa -y

# set path
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin/:/sbin:/bin:/usr/game:$PATH
rm -rf ~/.cache
ln -sT /tmp ~/.cache

# set autostart
mkdir ~/.config
mkdir ~/.config/openbox
cd ~/.config/openbox
echo 'xscreensaver -no-splash &' > autostart
echo 'eval `cat $HOME/.fehbg` &' >> autostart
echo 'compton -c -b -I 0.4 -O 0.4 -o 0.38 -t-17 -l-16 -e 0.96 -i 0.8 --backend xrender' >> autostart
echo '(sleep 1s && tint2) &' >> autostart
echo '(sleep 2s && volumeicon) &' >> autostart
echo '(sleep 3s && tilda -h) &' >> autostart

# set network
mkdir ~/bak
cp /etc/network/interfaces ~/bak
sudo sed -i '/usb/d' /etc/network/interfaces

# startx openbox-session
cd ~
cp /etc/X11/xinit/xinitrc ~/.xinitrc
echo 'exec openbox-session' >> .xinitrc
cp /etc/profile ~/.profile
echo '
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
    startx
fi
' >> .profile

$   sudo apt-get update

$  sh sys.sh

二、权限配置

$  nano pol.sh

#!/bin/sh

# add usr to power group
sudo groupadd power
# ${User}=your username
# sudo usermod -a -G power,disk,uucp,dialout,voice,cdrom,audio,video,netdev,messagebus ${User}

# set polkit
sudo chmod 775 /etc/polkit-1/localauthority
sudo chmod 775 /var/lib/polkit-1
sudo sed -i "s/auth_admin_keep/yes/g" `grep auth_admin_keep -rl /usr/share/polkit-1/actions`
sudo sed -i "s/auth_admin/yes/g" `grep auth_admin -rl /usr/share/polkit-1/actions`
$  sudo pol.sh


三、相关软件设置

1.开始需要做的事情

$  nano ~/.config/openbox/rc.xml

<!-- ~/.config/openbox/rc.xml设置快捷键 -->
<!-- keybind添加以下内容 -->
    <keybind key="C-A-space">
      <action name="ShowMenu">
        <menu>root-menu</menu>
      </action>
    </keybind>
    <keybind key="C-A-p">
      <action name="ShowMenu">
        <menu>client-list-combined-menu</menu>
      </action>
    </keybind>
2.tint2配置

$  nano ~/.config/tint2/tint2rc

# Tint2 config file
# Generated by tintwizard (http://code.google.com/p/tintwizard/)
# For information on manually configuring tint2 see http://code.google.com/p/tint2/wiki/Configure

# Background definitions
# ID 1
rounded = 0
border_width = 0
background_color = #2F343B 90
border_color = #FFFFFF 75

# ID 2
rounded = 1
border_width = 0
background_color = #FFFFFF 40
border_color = #FFFFFF 48

# ID 3
rounded = 1
border_width = 0
background_color = #FFFFFF 16
border_color = #FFFFFF 68

# Panel
panel_monitor = all
panel_position = top center horizontal
panel_size = 100% 25
panel_margin = 0 0
panel_padding = 7 0 7
panel_dock = 0
wm_menu = 1
panel_layer = top
panel_background_id = 1

# Panel Autohide
autohide = 0
autohide_show_timeout = 0.3
autohide_hide_timeout = 2
autohide_height = 2
strut_policy = follow_size

# Taskbar
taskbar_mode = single_desktop
#taskbar_mode = multi_desktop
taskbar_padding = 2 3 2
taskbar_background_id = 0
taskbar_active_background_id = 0
taskbar_name = 1
taskbar_name_padding = 3 0 0
taskbar_name_font = sans 8
taskbar_name_active_font_color = #FFFFFF 68

# Tasks
urgent_nb_of_blink = 8
task_icon = 1
task_text = 1
task_centered = 1
task_maximum_size = 140 35
task_padding = 6 2
task_background_id = 3
task_active_background_id = 2
task_urgent_background_id = 2
task_iconified_background_id = 3
task_tooltip = 0

# Task Icons
task_icon_asb = 70 0 0
task_active_icon_asb = 100 0 0
task_urgent_icon_asb = 100 0 0
task_iconified_icon_asb = 70 0 0

# Fonts
task_font = sans 9
task_font_color = #FFFFFF 68
task_active_font_color = #FFFFFF 83
task_urgent_font_color = #FFFFFF 83
task_iconified_font_color = #FFFFFF 68
font_shadow = 0

# System Tray
systray = 1
systray_padding = 0 4 5
systray_sort = ascending
systray_background_id = 0
systray_icon_size = 20
systray_icon_asb = 70 0 0

# Clock
time1_format = %H:%M %b%d日 %A
time1_font = sans 9
#time2_format = %A %d %B
#time2_font = sans 8
clock_font_color = #FFFFFF 60
clock_padding = 1 0
clock_background_id = 0
# rclick in clock=openbox root-menu lclick=desktop menu
clock_rclick_command = xdotool key ctrl+alt+space
clock_lclick_command = xdotool key ctrl+alt+p

# Tooltips
tooltip_padding = 2 2
tooltip_show_timeout = 0.7
tooltip_hide_timeout = 0.3
tooltip_background_id = 1
tooltip_font = sans 10
tooltip_font_color = #000000 80

# Mouse
mouse_middle = desktop_left
mouse_right = desktop_right
mouse_scroll_up = toggle
mouse_scroll_down = iconify

# Battery
battery = 0
battery_low_status = 10
battery_low_cmd = notify-send "battery low"
battery_hide = 98
bat1_font = sans 8
bat2_font = sans 6
battery_font_color = #FFFFFF 74
battery_padding = 1 0
battery_background_id = 0

# End of config
3.openbox menu配置

$  nano ~/.config/openbox/menu.xml

<?xml version="1.0" encoding="utf-8"?>
<openbox_menu xmlns="http://openbox.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://openbox.org/                 file:///usr/share/openbox/menu.xsd">
    <menu id="root-menu" label="Openbox 3">
        <separator label="OpenBox"/>
        <item icon="/usr/share/icons/Vibrantly-Simple-Dark/apps/48/gedit-icon.svg" label="文本编辑">
            <action name="Execute">
                <execute>geany</execute>
            </action>
        </item>
        <!-- This requires the presence of the 'menu' package to work -->
        <item icon="/usr/share/icons/Vibrantly-Simple-Dark/apps/48/file-manager.png" label="文件管理器">
            <action name="Execute">
                <execute>pcmanfm</execute>
            </action>
        </item>
        <item icon="/usr/share/icons/Vibrantly-Simple-Dark/apps/48/browser.svg" label="网络浏览器">
            <action name="Execute">
                <execute>x-www-browser</execute>
            </action>
        </item>
        <item label="Virtualbox">
            <action name="Execute">
                <execute>virtualbox</execute>
            </action>
        </item>
        <separator label="Applications"/>
        <menu icon="/usr/share/icons/Vibrantly-Simple-Dark/apps/48/wmtweaks.svg" id="root-menu-223938" label="配置OpenBox">
            <item label="ObConf">
                <action name="Execute">
                    <execute>obconf</execute>
                </action>
            </item>
            <item label="ObMenu">
                <action name="Execute">
                    <execute>obmenu</execute>
                </action>
            </item>
            <item label="Lxappearance">
                <action name="Execute">
                    <execute>lxappearance</execute>
                </action>
            </item>
            <item label="Reconfigure">
                <action name="Reconfigure"/>
            </item>
        </menu>
        <menu icon="/usr/share/icons/Vibrantly-Simple-Dark/apps/48/workspace-switcher.svg" id="client-list-combined-menu" label="工作区">
        </menu>
        <menu icon="/usr/share/icons/Vibrantly-Simple-Dark/apps/48/softwarecenter.svg" id="root-menu-165841" label="应用程序">
            <menu id="xdg-menu-设置" label="设置">
                <item label="Adobe Flash Player">
                    <action name="Execute">
                        <execute>flash-player-properties</execute>
                    </action>
                </item>
                <item label="Fcitx 配置">
                    <action name="Execute">
                        <execute>fcitx-configtool</execute>
                    </action>
                </item>
                <item label="Openbox Configuration Manager">
                    <action name="Execute">
                        <execute>obconf   </execute>
                    </action>
                </item>
                <item label="Qt 4 设置">
                    <action name="Execute">
                        <execute>/usr/bin/qtconfig-qt4</execute>
                    </action>
                </item>
                <item label="Screensaver">
                    <action name="Execute">
                        <execute>xscreensaver-demo</execute>
                    </action>
                </item>
                <item label="输入法">
                    <action name="Execute">
                        <execute>im-config</execute>
                    </action>
                </item>
            </menu>
            <separator/>
            <menu id="xdg-menu-互联网" label="互联网">
                <item label="utorrent -start">
                    <action name="Execute">
                        <execute>/home/nuc/.utorrent-server/utorrent.sh</execute>
                    </action>
                </item>
                <item label="utorrent -stop">
                    <action name="Execute">
                        <execute>pkill utserver</execute>
                    </action>
                </item>
                <item label="Firefox 网络浏览器">
                    <action name="Execute">
                        <execute>firefox   </execute>
                    </action>
                </item>
                <item label="Wicd Network Manager">
                    <action name="Execute">
                        <execute>wicd-gtk --no-tray</execute>
                    </action>
                </item>
            </menu>
            <menu id="xdg-menu-多媒体" label="多媒体">
                <item label="Kodi">
                    <action name="Execute">
                        <execute>kodi</execute>
                    </action>
                </item>
            </menu>
            <menu id="xdg-menu-系统" label="系统">
                <item label="BleachBit">
                    <action name="Execute">
                        <execute>bleachbit</execute>
                    </action>
                </item>
                <item label="BleachBit (as root)">
                    <action name="Execute">
                        <execute>su-to-root -X -c bleachbit</execute>
                    </action>
                </item>
                <item label="GDebi Package Installer">
                    <action name="Execute">
                        <execute>gdebi-gtk   </execute>
                    </action>
                </item>
                <item label="VirtualBox">
                    <action name="Execute">
                        <execute>VirtualBox   </execute>
                    </action>
                </item>
            </menu>
            <menu id="xdg-menu-附件" label="附件">
                <item label="Font Viewer">
                    <action name="Execute">
                        <execute>gnome-font-viewer   </execute>
                    </action>
                </item>
                <item label="Geany">
                    <action name="Execute">
                        <execute>geany</execute>
                    </action>
                </item>
                <item label="截图">
                    <action name="Execute">
                        <execute>gnome-screenshot -a</execute>
                    </action>
                </item>
                <item label="terminal">
                    <action name="Execute">
                        <execute>tilda</execute>
                    </action>
                </item>
            </menu>
        </menu>
        <separator label="Logout"/>
        <item icon="/usr/share/icons/Vibrantly-Simple-Dark/actions/48/gnome-shutdown.png" label="注销">
            <action name="Execute">
                <execute>python ~/文档/config/系统安装脚本/cb-exit.py</execute>
            </action>
        </item>
    </menu>
</openbox_menu>


4.虚拟机安装系统的简单版配置

$  nano vm.sh

#!/bin/sh

# install program
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install build-essential xorg openbox spacefm udevil sshfs -y
sudo apt-get install gksu hal-info upower pm-utils xvfb -y
sudo apt-get install feh lxappearance obmenu gnome-icon-theme ubuntu-mono gtk2-engines-murrine gtk2-engines-pixbuf gtk3-engines-unico dmz-cursor-theme -y
sudo apt-get install fcitx-rime tint2 fonts-droid numlockx sakura xdg-user-dirs -y
sudo apt-get install zip unzip -y

# set audio
sudo apt-get install alsa-base alsa-utils alsa-tools-gui -y
sudo alsactl init

# set autostart
mkdir ~/.config
mkdir ~/.config/openbox
cd ~/.config/openbox
echo 'eval `cat $HOME/.fehbg` &' > autostart
echo '(sleep 2s && tint2) &' >> autostart

# set path
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin/:/sbin:/bin:/usr/game:$PATH
rm -rf ~/.cache
ln -sT /tmp ~/.cache

# startx openbox-session
cd ~

cp /etc/X11/xinit/xinitrc ~/.xinitrc
echo 'exec openbox-session' >> .xinitrc

cp /etc/profile ~/.profile
echo '
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
    startx
fi
' >> .profile 
$  sh vm.sh

5.关机脚本

$  nano cb-exit.py

#!/usr/bin/env python
# url=https://gist.github.com/jaapz/9fd4304148b398983b3c by jaapz
# Replace the old /usr/bin/cb-exit with this one.

import pygtk
pygtk.require('2.0')
import gtk
import os
import getpass

class cb_exit:
	def disable_buttons(self):
		self.cancel.set_sensitive(False)
		self.logout.set_sensitive(False)
		self.suspend.set_sensitive(False)
		self.reboot.set_sensitive(False)
		self.shutdown.set_sensitive(False)

	def cancel_action(self,btn):
		self.disable_buttons()
		gtk.main_quit()

	def logout_action(self,btn):
		self.disable_buttons()
		self.status.set_label("Exiting Openbox, please standby...")
		os.system("openbox --exit")

	def suspend_action(self,btn):
		self.disable_buttons()
		self.status.set_label("Suspending, please standby...")
		os.system("cb-lock")
		os.system("dbus-send --print-reply --system --dest=org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.Suspend boolean:true")
		gtk.main_quit()

	def reboot_action(self,btn):
		self.disable_buttons()
		self.status.set_label("Rebooting, please standby...")
		os.system("dbus-send --print-reply --system --dest=org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.Reboot boolean:true")

	def shutdown_action(self,btn):
		self.disable_buttons()
		self.status.set_label("Shutting down, please standby...")
		os.system("dbus-send --print-reply --system --dest=org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.PowerOff boolean:true")

	def create_window(self):
		self.window = gtk.Window()
		title = "Log out " + getpass.getuser() + "? Choose an option:"
		self.window.set_title(title)
		self.window.set_border_width(5)
		self.window.set_size_request(500, 80)
		self.window.set_resizable(False)
		self.window.set_keep_above(True)
		self.window.stick
		self.window.set_position(1)
		self.window.connect("delete_event", gtk.main_quit)
		windowicon = self.window.render_icon(gtk.STOCK_QUIT, gtk.ICON_SIZE_MENU)
		self.window.set_icon(windowicon)

		
		#Create HBox for buttons
		self.button_box = gtk.HBox()
		self.button_box.show()
		
		#Cancel button
		self.cancel = gtk.Button(stock = gtk.STOCK_CANCEL)
		self.cancel.set_border_width(4)
		self.cancel.connect("clicked", self.cancel_action)
		self.button_box.pack_start(self.cancel)
		self.cancel.show()
		
		#Logout button
		self.logout = gtk.Button("_Log out")
		self.logout.set_border_width(4)
		self.logout.connect("clicked", self.logout_action)
		self.button_box.pack_start(self.logout)
		self.logout.show()
		
		#Suspend button
		self.suspend = gtk.Button("_Suspend")
		self.suspend.set_border_width(4)
		self.suspend.connect("clicked", self.suspend_action)
		self.button_box.pack_start(self.suspend)
		self.suspend.show()
		
		#Reboot button
		self.reboot = gtk.Button("_Reboot")
		self.reboot.set_border_width(4)
		self.reboot.connect("clicked", self.reboot_action)
		self.button_box.pack_start(self.reboot)
		self.reboot.show()
		
		#Shutdown button
		self.shutdown = gtk.Button("_Power off")
		self.shutdown.set_border_width(4)
		self.shutdown.connect("clicked", self.shutdown_action)
		self.button_box.pack_start(self.shutdown)
		self.shutdown.show()
		
		#Create HBox for status label
		self.label_box = gtk.HBox()
		self.label_box.show()
		self.status = gtk.Label()
		self.status.show()
		self.label_box.pack_start(self.status)
		
		#Create VBox and pack the above HBox's
		self.vbox = gtk.VBox()
		self.vbox.pack_start(self.button_box)
		self.vbox.pack_start(self.label_box)
		self.vbox.show()
		
		self.window.add(self.vbox)
		self.window.show()
		
	def __init__(self):
		self.create_window()


def main():
    gtk.main()

if __name__ == "__main__":
    go = cb_exit()
    main()



$  python cb-exit.py


你可能感兴趣的:(openbox在ubuntu下安装及配置)