2013年4月23日 星期二

解決zsh中自訂alias過的指令不能用tab補全參數

我的.zshrc都是到處抄來的,很久以前只要設定類似alias ys='yaourt -S'這樣用ys都不能補全yaourt的參數,直到最近用上了oh-my-zsh,在打開他的外掛plugins=(systemd archlinux),這兩個能補全yaourt、pacman、systemctl指令,我很好奇他是怎麼寫的,打開~/.oh-my-zsh/plugins/中的systemd/systemd.plugin.zsh及archlinux/archlinux.plugin.zsh發現明明人家也是alias沒什麼特別的,為何我原本的就不行。





好奇殺死貓,我不信邪,一部份一部關閉alias、functions、setopt、zstyle等等,終於被我找到一個設定會引起我這個問題,只要註解或刪掉setopt complete_aliases這樣自設的alias就沒問題了。



原本這個設定就有其註解其作用:# 補完動作の解釈前にエイリアス展開,我將他修改成這樣以作警惕## 不要打開 補全會不見setopt complete_aliases # 補完動作の解釈前にエイリアス展開





這是systemd.plugin.zsh,寫的好聰明要用commands或sudo_commands都不用自已在加sudo對我這個常常忘記加sudo的蛋來講相當好用。

user_commands=(

list-units is-active status show help list-unit-files

is-enabled list-jobs show-environment)



sudo_commands=(

start stop reload restart try-restart isolate kill

reset-failed enable disable reenable preset mask unmask

link load cancel set-environment unset-environment)



for c in $user_commands; do; alias sc-$c="systemctl $c"; done

for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done

編譯firefox-kde-opensuse時將語系檔一併包進去

我原本編譯都是英文加上額外安裝中文語系,這樣升級後會造成一個困擾,語系檔不相容一開就當,還要先手動砍掉語系檔的資料夾,再次開啟又要抓新的語系檔,我想為編譯時為何不加上語系檔?



這想法說來簡單,但有點難度搞了二、三天才搞定,好幾次編譯到一半就當掉,最後得到的心得是,一、關掉Firefox,二、移除掉Firefox,三、不要加入--disable-pango,加上語系檔可能額外要修改過才行。四、記憶體小於2GB打包時會失敗,最好放在大於2GB的硬碟空間,而不要直接在/tmp、/dev/shm編譯。







好的,現在開始實作一樣是用Arch,先下載tarball解壓縮後進入資料夾,修改mozconfig(沒有PGO)或mozconfig-pgo(編譯加上PGO)。



找到# System libraries在其下插入

ac_add_options --with-l10n-base=..
mk_add_options MOZ_CO_LOCALE="zh-TW"
ac_add_options --enable-ui-locale=zh-TW


在開啟PKGBUILD



找到build() {

在其下插入

hg clone http://hg.mozilla.org/releases/l10n/mozilla-release/zh-TW zh-TW


找到md5sums=(

將第其下兩行改成'SKIP',修改後像這樣:

md5sums=('b822ff4b2348410587dec563235d9320'

'SKIP'

'SKIP'
這兩行是對映mozconfig mozconfig-pgo的md5sums當然你也可以在修改mozconfig先算出他的md5sum,修改後找到原本的md5sum後將其改成新的數值即可。

source=(https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/$pkgver/source/firefox-$pkgver.source.tar.bz2

mozconfig mozconfig-pgo






最後開啟終端機進入該資料夾,下編譯指令即可

makepkg -si


P.S編譯PGO

要開啟PGO只要將PKGBUILD中_enable_pgo="n"改成_enable_pgo="y"即可,但編譯到一半如果停在http xxx 0404只要在開啟另一個終端機下指令將Xvfb程序砍掉,程序將會繼續編譯。

pkill Xvfb


P.S2這是我修改過的,我怕講的不清楚特別放上來讓你們參考



2013年4月13日 星期六

samba4.0分享設定中的share已經不行用了

samba4.0已經不能設定security = share了,如果一樣要用匿名分享,只要修改以下幾行就行了。



sudo vim /etc/samba/smb.conf


[global]

security = user

map to guest = Bad User

guest ok = Yes

guest account = XXX


最後一個guest account不一定要設功能是以匿名登入後使其認為是你所指定的ID連入,只要本機的資料是你那個所指定的ID所建立的,都可以直接刪除,不用設定writable = yes囉。之前幾版好像就有對我來講還蠻好用的所以補上它。



設定完成要重開smbd nmbd才會生效哦



sudo systemctl restart smbd nmbd


以下是我的完整設定可以參考參考。有需要看自已的請用指令:

testparm


Load smb config files from /etc/samba/smb.conf

rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)

Processing section "[homes]"

Processing section "[printers]"

Processing section "[電影]"

Processing section "[連續劇]"

Processing section "[歌仔戲]"

Processing section "[tmp]"

Loaded services file OK.

Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions





[global]

workgroup = MSHOME

server string = Samba Server

map to guest = Bad User

guest account = hepha

log file = /var/log/samba/log.%m

max log size = 50

printcap name = /etc/printcap

dns proxy = No

wins support = Yes

idmap config * : backend = tdb

guest ok = Yes



[homes]

comment = Home Directories

read only = No

browseable = No



[printers]

comment = All Printers

path = /var/spool/samba

guest ok = No

printable = Yes

print ok = Yes

browseable = No



[電影]

path = /mnt/big

read only = No

create mask = 0664

directory mask = 0775

想要了解更多4.0版的請看另外4.0版也可以當不過我用不到沒研究。



另外我在Jamyy's的部落格看到以下兩個設定或許對其它也有用。

Fedora 9 升級 Samba Server

徹底取消印表機功能



load printers = no

printcap name = /dev/null

disable spoolss = yes

;cups options = raw



samba 3.5 以上, 允許家目錄內的 soft link



wide links = yes

unix extensions = no


參考資料:

2012年11月21日 星期三

install arch64 for hard driver

以前弄ubuntu的似乎是比較簡單,arch設定有點不同,今天終於弄成功了,很棒!



  • 另外得知pacstrap、genfstab、arch-chroot,只要安裝arch-install-scripts就能執行了,這樣應該能在原有系統進行安裝囉。







我們要先取得存放裝置的_id與iso檔案的archisolabel



  • _id

sudo blkid|grep total
/dev/sdb2: LABEL="total" UUID="b7d0b427-8963-4e09-a5cd-93d703b9ff9f" TYPE="ext4"


  • archisolabel

iso-info /mnt/total/iso/arch/archlinux-2012.11.01-dual.iso
iso-info version 0.83 x86_64-unknown-linux-gnu

ISO 9660 image: /mnt/total/iso/arch/archlinux-2012.11.01-dual.iso

Application: ARCH LINUX LIVE/RESCUE CD

Preparer : PREPARED BY MKARCHISO

Publisher : ARCH LINUX

Volume : ARCH_201211


完成後新建一個檔案,內容請自行修改。

sudo vim /etc/grub.d/60_Arch


#!/bin/bash
exec tail -n +3 $0
menuentry "Archlinux-2012.11.01 uuid" {
_id=b7d0b427-8963-4e09-a5cd-93d703b9ff9f
insmod loopback
insmod iso9660
search --fs-uuid --no-floppy --set=root $_id
set isofile="/iso/arch/archlinux-2012.11.01-dual.iso"
loopback loop $isofile
linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201211 img_dev=/dev/disk/by-uuid/$_id img_loop=$isofile
initrd (loop)/arch/boot/x86_64/archiso.img
}


再來就是寫入grub.cfg,最後重新開機測試囉

sudo chmod +x /etc/grub.d/60_Arch
sudo grub-mkconfig -o /boot/grub/grub.cfg


附上Installation Guide (正體中文)



參考資料: GRUB2 (正體中文)

2012年11月7日 星期三

Install Nvidia Beta Driver On Arch Linux

我沒有實際在Linux試過遊戲效能,只是看到新東西就想裝一下,加上安裝出現下面那個錯誤就順便記錄一下怎麼處理。



NVIDIA 推出全新 GeForce R310 驅動程式 大幅提升 Linux 平台遊戲效能

Valve 公司行銷副總裁 Doug Lombardi 表示:「 NVIDIA (輝達) 今天釋出的驅動程式,可讓遊戲在 Linux 平台上全面提升效能。 NVIDIA (輝達) 在遊戲界的領導地位毋庸置疑,並率先與我們和其他遊戲開發商一起開發了 R310 驅動程式,這是遊戲玩家在 Linux 玩遊戲的一大福音,這無疑是一個讓 Linux 遊戲快速大幅提升效能的好方法。」


NVIDIA R310驅動性能翻番-Steam,Linux,NVIDIA,R310,310.14-驅動之家

所謂的遊戲性能翻番,NVIDIA是這麼解釋的:在基於Core i7-3930K 3.2GHz處理器、8GB內存、GeForce GTX 680顯卡、Ubuntu 12.04 32位系統的平台上,《Left 4 Dead 2》遊戲使用304.51驅動的幀率為142.7FPS,換成310.14則可以跑出301.4FPS,提升了1.1倍。
根據NVIDIA的說法,310.14驅動適合使用GeForce GTX 600系列最新顯卡的Linux玩家,GeForce 8800 GT以上的也可以更新但效果沒那麼明顯。






nvidia-beta-all適用於liunx、linux-ck(我有裝這兩個核心),linux-uksm、linux-uksm-ck或許可用(目前沒裝沒試)。



For hava yaourt

yaourt -S nvidia-beta-all


For no have yaourt

先安裝nvidia-utils-beta後安裝nvidia-beta-all



Error message

如果安裝過程出現以下訊息停止安裝,請安裝linux-headers在重新安裝驅動程式即可。

If you are using a Linux 2.4 kernel, please make sure you either have configured kernel sources matching your kernel or the correct set of kernel headers installed on your system.



If you are using a Linux 2.6 kernel, please make sure you have configured kernel sources matching your kernel installed on your system. If you specified a separate output directory using either the “KBUILD_OUTPUT” or the “O” KBUILD parameter, make sure to specify this directory with the SYSOUT environment variable or with the equivalent nvidia-installer mmand line option.



Depending on where and how the kernel sources (or the kernel headers) were installed, you may need to specify their location with the SYSSRC environment variable or the equivalent nvidia-installer command line option.


初次安裝官方驅動程式請執行此指令產生新的xorg.conf設定檔



sudo nvidia-xconfig




參考資料:NVIDIA - ArchWiki

2012年11月6日 星期二

Fix【新版】定時調整音量

這裡是定時調整音量新版,說明請看舊版,這次新加入在晚上自動將音量調小前儲存原本音量,過了設定的週期或重新開機時設回原本音量。





Fix Note:


  1. 取得音量錯誤,無法正確儲存音量。

  2. 比對時間錯誤。


Add Note:


  • 睡眠週期設定:

    _SleepOn=音量調整的開始時間 

    _SleepOff=音量調整的結束時間 

    _SleepVolume=調整音量為此設定值 





Default Useing:



當22點(晚上10點)先儲存你目前音量,而後從22點(晚上10點)至9點(早上9點)音量調整為85%,於10點後(含)恢復先前所儲存的音量設定。



P.S 設定1點到9點前面不用加0,也就是3點就寫成3不要寫成03,這樣無法比對時間。



#!/bin/bash
_Hour=$(date "+%-H")
_Sound=/var/tmp/sound
_SleepOn=22
_SleepOff=9
_SleepVolume=85%
_SAVE(){
_Mono=$(amixer get Master | grep "Mono:" | awk '{print $4}' | tr -d '[]')
_Front=$(amixer get Master | grep "Front Left:" | awk '{print $5}' | tr -d '[]')
if [ "x${_Front}" != "x" ]
then
_Volume=${_Front}
elif [ "x${_Mono}" != "x" ]
then
_Volume=${_Mono}
else
echo "Unknown Volume"
exit
fi
echo "_Default=${_Volume}" >> ${_Sound}
echo "Save Volume: ${_Volume}"
}

echo "The time now: ${_Hour} "
if [[ -f ${_Sound} && ${_Hour} -le ${_SleepOff} || ${_Hour} -ge ${_SleepOn} ]]
then
echo "Now is Sleep Time Change Volume: ${_SleepVolume}"
amixer sset Master ${_SleepVolume} 1>/dev/null
elif [[ ${_Hour} -le ${_SleepOff} || ${_Hour} -ge ${_SleepOn} ]]
then
_SAVE
echo "Now is Sleep Time Change Volume: ${_SleepVolume}"
amixer sset Master ${_SleepVolume} 1>/dev/null
elif [[ -f ${_Sound} && ${_Hour} -gt ${_SleepOff} && ${_Hour} -lt ${_SleepOn} ]]
then
. ${_Sound}
echo "Now the end of the sleep time to restore the volume: ${_Default}"
amixer sset Master ${_Default} 1>/dev/null
rm -f ${_Sound}
fi



2012年10月12日 星期五

Firefox無法在Google Translate發出聲音?

不知何時開始我的Firefox無法在Google Translate發出聲音,找了很多文章修改設定都是沒用,使用Google Chrome就沒有這個問題,這是讓我苦惱的一件事。



今天心血來潮開Google Translate網頁的原始碼來看,發現了原來它是用Flash來播放聲音,那麼只要從Flash下手我想應該能解決。





Flash Player至使至終都裝著,那麼在從Flash相關套件下手,關閉Adblock Plus沒效那麼只剩一個影響的可能Flashblock。



賓果,猜對了只要將Google Translate網頁加入Flashblock白名單,許久不見的聲音就出現了。