2021年5月5日 星期三

[ubuntu]不需要sudo權限重開機

一般在ubuntu要重開機要用
$sudo reboot
但這樣會被要求輸入admin的密碼
這時候可以在 /etc/sudoers.d/中新增任意檔名的檔案
內容是
username ALL = NOPASSWD: /sbin/reboot

[ubuntu]不需要sudo權限重開機

2021年4月26日 星期一

[Raspbian]raspberry pi 中文輸入法

 不知為何gcin就是無法在我的8G版本上work

後來改用fcitx就沒問題了..

安裝指令

$ sudo apt-get install fcitx fcitx-chewing

安裝完成後再去

menu > preference > input method 去選fcitx

安裝方式請參考

https://medium.com/gcc-me-c/fcitx-chewing-%E6%96%B0%E9%85%B7%E9%9F%B3%E4%B8%AD%E6%96%87%E8%BC%B8%E5%85%A5%E6%B3%95%E5%AE%89%E8%A3%9D-7f06b16b3e51

[Raspbian]raspberry pi 中文輸入法

[Raspbian][ raspberry pi ] dock window 與熱鍵修改

 pi 的os 竟然沒辦法dock window...

這樣基本的功能,難道沒人把它當便宜主機用嗎?

因為解決方法有點小麻煩,這邊就紀錄一下

ref: https://pastebin.com/NBkccE7B

使用方法基本上就是用win + q/w/e/a/d/z/x/c 將視窗移到各個角落

win + s 全螢幕, win+shift+s縮小

but.. 因為pi 預設 win 一按下去就會打開 lxpanelctl menu我把<keybind key="Super_L">小改了一下變成

    <keybind key="Super_L-m">
      <action name="Execute">
        <command>lxpanelctl menu</command>
      </action>
    </keybind>

首先要先找到設定熱鍵的檔案(/home/pi/.config/openbox/lxde-pi-rc.xml),然後用某個文字編輯器(pi os 預裝有geany,就決定是你了)開啟它

~$ geany /home/pi/.config/openbox/lxde-pi-rc.xml

這個檔案裡面可以找到所有pi可以用的hotkeys~
首先找到 <keyboard> 這個tag 
加入下面一狗票,改完之後存檔重開機 或是在terminal 中輸入
$ openbox-lxde --reconfigure
就可以囉

    <keybind key="W-a">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
    <height>100%</height>
    <x>0%</x>
    <y>0%</y>
  </action>
</keybind>
<keybind key="W-d">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
    <height>100%</height>
    <x>50%</x>
    <y>0%</y>
  </action>
</keybind>
<keybind key="W-x">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>100%</width>
    <height>50%</height>
    <x>0%</x>
    <y>50%</y>
  </action>
</keybind>
<keybind key="W-w">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>100%</width>
    <height>50%</height>
    <x>0%</x>
    <y>0%</y>
  </action>
</keybind>
<keybind key="W-q">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
    <height>50%</height>
    <x>0%</x>
    <y>0%</y>
  </action>
</keybind>
<keybind key="W-e">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
    <height>50%</height>
    <x>50%</x>
    <y>0%</y>
  </action>
</keybind>
<keybind key="W-z">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
    <height>50%</height>
    <x>0%</x>
    <y>50%</y>
  </action>
</keybind>
<keybind key="W-c">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
    <height>50%</height>
    <x>50%</x>
    <y>50%</y>
  </action>
</keybind>
<keybind key="W-s">
  <action name="Maximize"/>
</keybind>
<keybind key="W-S-s">
  <action name="Iconify"/>
</keybind>


[Raspbian][ raspberry pi ] dock window 與熱鍵修改

2021年4月25日 星期日

raspberry pi 截圖 without printscreen 按鍵

Microsoft的all in one 鍵盤加觸控板不知為何沒有printscreen鍵..

只好用terminal呼叫截圖程式

先用ctrl+alt+t打開termainal

呼叫scrot截圖

它還可以帶一些參數呼叫

scrot -s 框選擷取範圍

scrot -sb 選取視窗

scrot -d num num秒後截圖

scrot -cd num 倒數num秒後截圖

截下來的圖都會放在 ~目錄

raspberry pi 截圖 without printscreen 按鍵

[Raspbiam]raspberry pi4時鐘格式

 用Raspbian OS 若想把toolbar換到左/右邊可以在工具列上

右鍵 > Panel settings > Position > Edge 去選擇工具列位置

如果選側邊,可以把Size調整成跟icon size差不多比較簡潔

後pi預設是多的視窗不會合併,這可以從

task bar(window list) settings > combine multiple application windows into a single button 去設定

這時候還有個問題,時鐘分的部份會看不到分

這可以在時鐘那邊按右鍵

digital clock settings > clock format

例如我用的是

%a%n------%n %d%n%b%n------%n%H%n:%M

效果像這樣







[Raspbiam]raspberry pi4時鐘格式

2021年4月23日 星期五

linux筆記軟體cherrytree

因為覺得在公司電腦用私人的google doc筆記怕會有爭議,用了linux上的cherry tree, 希望好用

linux筆記軟體cherrytree

wps office

之前想說找到跟ms office很類似的wps office, 沒想到他竟然是金山出的...礙於對強國軟體的敬畏,只好將他移除了

wps office

2021年4月21日 星期三

在Ubuntu下執行window程式

ubuntu底下可以用okular註解pdf檔案,但有個問題是,他的inline comment竟然不能顯示英文以外的文字...傻眼
這個bug被report 5年以上也不見解決
後來找到一個方法,就是先裝wine讓window的程式可以run在ubuntu之後再裝pdfxchange這套widow常用pdf工具就解決了這個問題

在Ubuntu下執行window程式

2021年3月30日 星期二

[豆知識] command prompt 下切換硬碟

2021年3月24日 星期三

[linux] 增加動態函式庫搜尋路徑

 預設的搜尋路徑有

/lib/, /usr/lib/

在這裡面加入library只需呼叫

$ ldconfig

去更新/etc/ld.so.cache的內容

如果新增的lib在其他地方,有兩個選擇

1. 暫時的方法

在環境變數LD_LIBRARY_PATH加入資料夾路徑

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/myapp/lib

1.1 將上面的指令加入

  ~/.bashrc

這樣每次打開shell都會被執行

2. 永久的方式

/etc/ld.so.conf.d/中加入.conf檔案

$ touch opencv.conf
$ echo "/user/local/lib" > opencv.conf
$ sudo ldconfig


ps.

$ ldconfig -v

看ldconfig連結的librarys

$ ldconfig -n

看ldconfig連結的librarys,但排除預設目錄


[linux] 增加動態函式庫搜尋路徑

2021年3月23日 星期二

[git] 完全回復成未修改狀態

清除未追蹤檔案

 git clean -fx

(x表示連同ignored files)

可以先用 

git clean -fxn

測試

還原git controlled files

git reset --hard

[git] 完全回復成未修改狀態

back in time -qt

之前都用time shift 但因為看time shift的readme說 time shift主要用來回覆系統檔,要完整回朔可以用back in time

但第一次用就悲劇...

因為在做備份的時候沒有掛一個share槽 (/mnt/share/),但還原的時候不小心掛了,又選清除多餘的檔案,於是share整個被清空(幸好不是很大的備份碟)

所以用 backintime 記得把 /dev/, /mnt/之類的目錄加到例外

back in time -qt

[Linux Shell Script] sed 在指定行前面加字元

最近因為寫安裝realsense sdk的script, 需要將原本的script部分註解掉,找到這個sed指令


 sed -i '308,320 s/^/# /1' fileName

註解 308~320行

-i : 寫入原檔

308,320: 範圍 308 ~320

s: 取代

^: pattern前的空字元 ($ 表示pattern 的空字元)

1: 作用在第一個matched pattern (g表示所有)

sed -i '1 s/^/# /1 ; 3 s/^/# /1' test

註解 1,3行

sed -i 's/# //g' test

刪掉 test 中所有 '# '

ref:

https://terryl.in/zh/linux-sed-command/

regular express

https://www.gnu.org/software/sed/manual/sed.html#sed-regular-expressions


ps. 如果要取代檔案中的字

sed -i 's/WORD_TO_REPLACE/replacer/g' fileName


會將

abcdWORD_TO_REPLACEabcdWORD_TO_REPLACE123

變成

abcdreplacerabcdreplacer123


[Linux Shell Script] sed 在指定行前面加字元

2021年3月9日 星期二

bazel cache

 最近在搞Isaac, 他用bazel這個build tool聽說是很scallable的tool

but...他的cache真的是神大,build幾個Isaac sample,cache了5xGB... SSD都塞暴了

bazel cache

2021年3月8日 星期一

[Isaac install]nvidia driver's location

Isaac 官網上有提到要自行增加環境變數,讓unity可以抓到nv driver

在~/.bashrc最後新增

export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json

但實際去找/usr/share/vulkan/icd.d/資料夾找不到nvidia_icd.json

後還發現在我的NB上是在/etc/vulkan/icd.d/nvidia_icd.json

實務上可以先updatedb後去locate nvidia_icd.json

[Isaac install]nvidia driver's location

2021年3月7日 星期日

[install cuda] install gcc

$ sudo apt update

$ sudo apt install build-essential

install manuals

$  sudo apt-get install manpages-dev

check install

$ gcc --version


[install cuda] install gcc

install cuda -- turn off Nouveau

 before install cuda,Nouveau need to be turned off

create a new text file

$ sudo nano /etc/modprobe.d/blacklist-nouveau.conf

in blacklist-nouveau.conf

 

blacklist nouveau
options nouveau modeset=0
 
then, rebuild kernel and reboot
$ sudo update-initramfs -u
$ sudo reboot 

after reboot make sure Nouveau have been shut down
$ lsmod | grep nouveau

install cuda -- turn off Nouveau

[pre noted] 將linux移到其他硬碟

 因為公司筆電的ssd很小(128G)上面大只夠run一個linux

  1. Create an ext4 partition and a swap partition on the new drive.

  2. Boot from LiveUSB.

  3. Mount the old Ubuntu partition to some directory, mount the new one to some other directory.

  4. Copy all files from the old one to the new one using cp -a command.

  5. Install grub to the new drive.

  6. Update /etc/fstab with new UUIDs.

[pre noted] 將linux移到其他硬碟

在已有ubuntu的狀況下免cd/usb安裝其他inux

用 grml-rescueboot套件

$ sudo apt-get install grml-rescueboot

安裝完成後會產生

/boot/grml資料夾

將iso移動到 /boot/grml

$ sudo mv <.iso> /boot/grml

更新grub

$ update-grub

重開機
$ reboot
這時候grub menu中就會多一個 grml-rescueboot 的選項

但這樣做會有個問題就是installer無法在已掛載的磁碟上做改變分割磁區的動作,如果只有一個實體磁碟的話會需要先割好再安裝

在已有ubuntu的狀況下免cd/usb安裝其他inux

bazel geetting sart

 最近因為用到Nv 的 Isaac, 他用的是bazel這個編譯器

之前沒接觸過,查了一下發現他原本是google內部用的編譯器,後來release出來產生的

但從他的官網進去要getting start卻一直是404找不到網頁

一直以為是有捨麼梗

後來檢查URL才發現他連結的URL是

https://docs.bazel.build/guide.html/getting-started.html

但應該要連到

https://docs.bazel.build/getting-started.html

才對...orz

bazel geetting sart