2017/12/26

用 rsync 複製系統

【前言】


前面已有多篇敘述用 dd 複製系統。這種方法的問題是必需複製整個分割區。也就是說,檔案以外的空白區 (free space) 也要複製。如果用 rsync,就可以只複製檔案,以節省時間、空間。

Linux 系統的分割區可以有很多種分配方式。最單純的是只有一個,也就是把所有目錄都放在一起。其次是兩個分割區,系統一個,HOME 一個。也有人用更多的分割區,把系統目錄分散在多個分割區。本文介紹前兩種狀況。

此外,除了可以複製非使用中的分割區,也可以複製正在使用的分割區。下文都一併介紹。

所以,要複製的狀況有:
狀況一:單一分割區,非使用中。
狀況二:雙分割區,非使用中。
狀況三:使用中系統。


本文更新於 WordPress:
Backup And Restore Debian GNU/Linux 10 Using rsync Commands

2017/12/16

用 Wine/PlayOnLinux 安裝 CBETA 閱經器 CBReader

【前言】


CBETA 的 CBReader 是依 Windows 系統製成,無法直接在 Linux 使用,這是非常遺憾的事。所幸,Linux 有 Wine,可藉此使用 CBReader 閱經器。但是,大家好像很擔心因果似的,沒人詳述安裝過程,致使新手不知如何安裝。

本篇網誌敘述安裝法,以利大眾。因無提供任何程式供人使用,應該沒有侵犯版權。若有因果,欣然接受;只願大眾深入經藏,智慧如海。至於依之而行的人,若有因果,則需自行承擔。

特別提醒:將安裝好的結果供人使用流通,或有因果;若是自用,應該問題比較小。

本文更新於 WordPress:
Linux 系統安裝 CBETA 閱經器 CBReader

Linux 系統安裝“大正藏在线阅读”程序

2019/08/17 更新

【目錄】


前言
安裝 python 3.6
 1. 下載
 2. 解壓
 3. 安裝工具
 4. 安裝 python 3.6
 5. 建立 python 3.6 環境
大正藏在线阅读程序
 1. 取得檔案
 2. 加入藏經檔
 3. 取得並修改 make_xml.py 檔
 4. 在 python 環境中安裝必需程式庫
 5. 修改 xml 檔
 6. 啟動閱經器
 7. 再啟動閱經器
後語


【前言】


前篇已敘述了用 Wine/PlayOnLinux 安裝 CBETA 閱經器 CBReader 的方法,本篇介紹北京趙文平大德發心編寫的閱經器。因其主要以 python 撰寫並使用 W3C 的 XSLT 呈現經文,故可跨平台;而且不要求版權,無償供人使用;雖然目前仍在積極開發中,尚未完備,但架構已成,值得介紹。

此閱經器要在 python 3.6 的環境中執行,所以下文先介紹下載安裝 3.6 版的方法,才談閱經器。

因為每個 Linux 版本所安裝的程式不同,為了得知安裝時所需的程式,本例特別使用了一個較簡單、沒有安裝很多應用程式的 Debian 10 系統。以下提及要安裝的程式,若諸位的系統已經有了,略過即可。

2017/11/09

用 Bash 指令產生 html 色表

【 前言 】


在編輯佈景樣式時,都會牽扯到顏色的設定;尤其是程式碼的 highlight 需要在不同背景色下選用多種顏色。所以最好能有色表參考。

以下 Bash 指令可產生 html 碼,在一種背景色下顯示 729 種前景色。


本文更新於 WordPress:
Generating HTML Color Tables with BASH Script

另有用 ImageMagick 的方法:
Generating Color Tables with ImageMagick

2017/11/02

GTK2 深灰色佈景

GTK2 使用版本:GTK 2.24。

範例:Spacefm


【GTK2 設定檔內容】


.gtkrc-2.0 檔的位置在 ~ 目錄。

# GtkSettings (見官方 "Reference Manual" II; 小括號內是預設值)

gtk-color-scheme = "gray_1: #101010"
gtk-color-scheme = "gray_2: #202020"
gtk-color-scheme = "gray_3: #303030"
gtk-color-scheme = "gray_4: #404040"
gtk-color-scheme = "gray_5: #505050"
gtk-color-scheme = "gray_6: #606060"
gtk-color-scheme = "gray_7: #707070"
gtk-color-scheme = "gray_8: #808080"
gtk-color-scheme = "gray_9: #909090"
gtk-color-scheme = "gray_a: #a0a0a0"
gtk-color-scheme = "gray_b: #b0b0b0"
gtk-color-scheme = "gray_c: #c0c0c0"
gtk-color-scheme = "gray_d: #d0d0d0"
gtk-color-scheme = "gray_e: #e0e0e0"
gtk-color-scheme = "gray_f: #f0f0f0"
gtk-color-scheme = "gray_g: #ffffff"
# A palette of named colors for use in themes ("")
gtk-color-scheme = "info_fg_color: lightgray"
gtk-color-scheme = "info_bg_color: #004000"
gtk-color-scheme = "warning_fg_color: lightgray"
gtk-color-scheme = "warning_bg_color: #804000"
gtk-color-scheme = "question_fg_color: lightgray"
gtk-color-scheme = "question_bg_color: #808000"
gtk-color-scheme = "error_fg_color: lightgray"
gtk-color-scheme = "error_bg_color: #800000"

#gtk-cursor-blink = TRUE
# Whether the cursor should blink (TRUE)

gtk-cursor-blink-time = 1000
# Length of the cursor blink cycle, in milliseconds (1200)

#gtk-cursor-blink-timeout = 2147483647
# Time after which the cursor stops blinking, in seconds (2147483647)

#gtk-cursor-theme-name = NULL
# Name of the cursor theme to use (NULL to use the default theme)

#gtk-cursor-theme-size = 0
# Size to use for cursors (0 ~ 128, 0 to use the default size)

gtk-fallback-icon-theme = "GNOME"
# Name of a icon theme to fall back to (NULL)

#gtk-font-name = "HanaMinA 13"
gtk-font-name = "AR PL UMing TW 13"
# Name of default font to use ("Sans 10")

gtk-icon-sizes = "gtk-menu=16,16:gtk-button=20,20:gtk-small-toolbar=18,18:gtk-large-toolbar=32,32:gtk-dnd=40,40:gtk-dialog=48,48"
# A list of icon sizes (NULL)

gtk-icon-theme-name = "Humanity"
# Name of icon theme to use (See index.theme file; "Hicolor")

gtk-menu-bar-accel = ""
# Keybinding to activate the menu bar ("F10")

gtk-menu-popdown-delay = 0
# The time before hiding a submenu when the pointer is moving towards the submenu (1000)

gtk-menu-popup-delay = 0
# Minimum time the pointer must stay over a menu item before the submenu appear (225)

#gtk-theme-name = "Raleigh"
# Name of theme RC file to load (Dir name, "Raleigh")

gtk-toolbar-icon-size = GTK_ICON_SIZE_SMALL_TOOLBAR
# The size of icons in default toolbars (GTK_ICON_SIZE_LARGE_TOOLBAR)

gtk-toolbar-style = GTK_TOOLBAR_ICONS
# Whether default toolbars have text only, text and icons, icons only, etc. (GTK_TOOLBAR_BOTH)

gtk-tooltip-timeout = 0
# Time, in milliseconds, after which a tooltip could appear if the cursor is hovering on top of a widget (500)

# Widgets and Objects

style "default" {
  fg[NORMAL] = @gray_f
  bg[NORMAL] = @gray_3
  text[NORMAL] = @gray_e
  base[NORMAL] = @gray_2

  fg[PRELIGHT] = @gray_f
  bg[PRELIGHT] = @gray_5
  text[PRELIGHT] = @gray_e
  base[PRELIGHT] = @gray_4

  fg[ACTIVE] = @gray_f
  bg[ACTIVE] = @gray_4
  text[ACTIVE] = @gray_f
  base[ACTIVE] = @gray_5

  fg[SELECTED] = @gray_g
  bg[SELECTED] = @gray_6
  text[SELECTED] = @gray_f
  base[SELECTED] = @gray_5

  fg[INSENSITIVE] = @gray_8
  bg[INSENSITIVE] = @gray_1
  text[INSENSITIVE] = @gray_7
  base[INSENSITIVE] = @gray_1

  xthickness = 1
  ythickness = 1

# A widget that creates a signal when clicked on
  GtkButton::child-displacement-x = 2
  # How far in the x direction to move the child when the button is depressed (0)
  GtkButton::child-displacement-y = 2
  # How far in the y direction to move the child when the button is depressed (0)
  GtkButton::default-border = { 2, 1, 2, 1 }
  # Extra space to add for GTK_CAN_DEFAULT buttons ({ 1, 1, 1, 1 })
#  GtkButton::default-outside-border = { 0, 0, 0, 0 }
  # Extra space to add for GTK_CAN_DEFAULT buttons that is always drawn outside the border ({ 0, 0, 0, 0 })
#  GtkButton::displace-focus = FALSE
  # Whether the child_displacement_x/_y properties should also affect the focus rectangle (FALSE)
#  GtkButton::image-spacing = 2
  # Spacing in pixels between the image and label (2)
#  GtkButton::inner-border = { 1, 1, 1, 1 }
  # Border between button edges and child ({ 1, 1, 1, 1 })

# Create widgets with a discrete toggle button
  GtkCheckButton::indicator-size = 18
  # Size of check or radio indicator (13)
  GtkCheckButton::indicator-spacing = 4
  # Spacing around check or radio indicator (2)

# A widget used to choose from a list of items
#  GtkComboBox::appears-as-list = FALSE
  # Whether dropdowns should look like lists rather than menus (FALSE)
#  GtkComboBox::arrow-size = 15
  # Sets the minimum size of the arrow in the combo box. Note that the arrow size is coupled to the font size, so in case a larger font is used, the arrow will be larger than set by arrow size. (15)
  GtkComboBox::shadow-type = GTK_SHADOW_OUT
  # Which kind of shadow to draw around the combo box (GTK_SHADOW_NONE)

# Create popup windows
  GtkDialog::action-area-border = 3
  # Width of border around the button area at the bottom of the dialog (5)
  GtkDialog::button-spacing = 3
  # Spacing between buttons (6)
  GtkDialog::content-area-border = 3
  # Width of border around the main dialog area (2)
  GtkDialog::content-area-spacing = 3
  # Spacing used between elements of the content area (0)

# A single line text entry field
#  GtkEntry::inner-border = {2, 2, 2, 2}
  # Border between the text and the frame ({2, 2, 2, 2})

# A menu widget
  GtkMenu::arrow-scaling = 1
  # Arbitrary constant to scale down the size of the scroll arrow (0.7)
  GtkMenu::horizontal-offset = 0
  # When the menu is a submenu, position it this number of pixels offset horizontally (-2)
  GtkMenu::horizontal-padding = 2
  # Extra space at the left and right edges of the menu (0)
  GtkMenu::vertical-offset = 2
  # When the menu is a submenu, position it this number of pixels offset vertically (0)
  GtkMenu::vertical-padding = 2
  # Extra space at the top and bottom of the menu (1)

# A subclass widget for GtkMenuShell which holds GtkMenuItem widgets
  GtkMenuBar::internal-padding = 0
  # Amount of border space between the menubar shadow and the menu items (1)

# A menu entry
  GtkMenuItem::arrow-scaling = 0.6
  # Arrow size, relative to the menu item's font size (0 ~ 2, 0.8)
  GtkMenuItem::arrow-spacing = 0
  # Space between label and arrow (10)
#  GtkMenuItem::horizontal-padding = 3
  # Padding to left and right of the menu item (3)
  GtkMenuItem::selected-shadow-type = GTK_SHADOW_ETCHED_OUT
  # Shadow type when item is selected (GTK_SHADOW_NONE)
#  GtkMenuItem::toggle-spacing = 5
  # Space between icon and label (5)
  GtkMenuItem::width-chars = 0
  # The minimum desired width of the menu item in characters (12)

# A widget with two adjustable panes
  GtkPaned::handle-size = 8
  # Width of handle (5)

# Base class for widgets which visualize an adjustment
  GtkRange::arrow-displacement-x = 2
  # How far in the x direction to move the arrow when the button is depressed (0)
  GtkRange::arrow-displacement-y = 2
  # How far in the y direction to move the arrow when the button is depressed (0)
  GtkRange::arrow-scaling = 0.8
  # The arrow size proportion relative to the scroll button size (0.5)
  GtkRange::slider-width = 10
  # Width of scrollbar or scale thumb (14)
  GtkRange::stepper-size = 16
  # Length of step buttons at ends (14)
#  GtkRange::stepper-spacing = 0
  # Spacing between the stepper buttons and thumb (0)
  GtkRange::trough-border = 2
  # Spacing between thumb/steppers and outer trough bevel (1)
  GtkRange::trough-under-steppers = 0
  # Whether to draw the trough across the full length of the range or to exclude the steppers and their spacing (TRUE, 用 FALSE 無效)

# A slider control used to select numeric values (Child of GtkRange)
  GtkScale::slider-length = 24
  # Length of scale's slider (31)
  GtkScale::value-spacing = 5
  # Space between value text and the slider/trough area (2)

# A scrollbar (Child of GtkRange)
  GtkScrollbar::has-backward-stepper = 0
  # Display the standard backward arrow button (1, TRUE/FALSE don't work)
  GtkScrollbar::has-forward-stepper = 1
  # Display the standard forward arrow button (1, TRUE/FALSE don't work)
  GtkScrollbar::has-secondary-backward-stepper = 1
  # Display a second backward arrow button on the opposite end of the scrollbar (0, TRUE/FALSE don't work)
  GtkScrollbar::has-secondary-forward-stepper = 0
  # Display a second forward arrow button on the opposite end of the scrollbar (0, TRUE/FALSE don't work)
  GtkScrollbar::min-slider-length = 14
  # Minimum length of scrollbar slider (21, GTK3 deprecated)

# Adds scrollbars to its child widget
  GtkScrolledWindow::scrollbar-spacing = 0
  # Number of pixels between the scrollbars and the scrolled window (3)

# A toolbar
  GtkToolbar::internal-padding = 2
  # Amount of border space between the toolbar shadow and the buttons (0)
  GtkToolbar::space-size = 8
  # Size of spacers (12)

# A widget for displaying both trees and lists
  GtkTreeView::even-row-color = @gray_3
  # Color to use for even rows
  GtkTreeView::expander-size = 16
  # Size of the expander arrow (12)
  GtkTreeView::horizontal-separator = 0
  # Horizontal space between cells (Must be an even number, 2)
  GtkTreeView::odd-row-color = @gray_2
  # Color to use for odd rows
  GtkTreeView::tree-line-pattern = "\000"
  # Dash pattern used to draw the tree view lines (\001\001)
  GtkTreeView::tree-line-width = 2
  # Width, in pixels, of the tree view lines (1)
  GtkTreeView::vertical-separator = 0
  # Vertical space between cells (Must be an even number, 2)

# Base class for all widgets
  GtkWidget::cursor-aspect-ratio = 0.08
  # Aspect ratio with which to draw insertion cursor (0.04)
  GtkWidget::cursor-color = "#ff0000"
  # Color with which to draw insertion cursor
  GtkWidget::focus-line-pattern = "\002"
  # Dash pattern used to draw the focus indicator (\001\001)
#  GtkWidget::focus-line-width = 1
  # Width, in pixels, of the focus indicator line (1)
  GtkWidget::focus-padding = 0
  # Width, in pixels, between focus indicator and the widget 'box' (1)
#  GtkWidget::interior-focus = TRUE
  # Whether to draw the focus indicator inside widgets (TRUE)
  GtkWidget::link-color = "#ff8040"
  # Color of unvisited links
#  GtkWidget::scroll-arrow-hlength = 16
  # Length of horizontal scroll arrows (16)
#  GtkWidget::scroll-arrow-vlength = 16
  # Length of vertical scroll arrows (16)
  GtkWidget::separator-height = 1
  # Height of separators (This property only takes effect if “wide-separators” is TRUE, 0)
  GtkWidget::separator-width = 1
  # Width of separators (This property only takes effect if “wide-separators” is TRUE, 0)
#  GtkWidget::tooltip-alpha = 255
  # Opacity of widget tooltips (255)
  GtkWidget::tooltip-radius = 3
  # Radius of widget tooltips (0)
  GtkWidget::visited-link-color = "#ff80ff"
  # Color of visited links
  GtkWidget::wide-separators = 1
  # Whether separators have configurable width and should be drawn using a box instead of a line (FALSE)
}

style "button" {
  bg[NORMAL] = @gray_4
  bg[PRELIGHT] = @gray_6
}

style "notebook" {
  bg[NORMAL] = @gray_4
  bg[ACTIVE] = @gray_2

#  GtkNotebook::arrow-spacing = 0
  # Spacing between the scroll arrows and the tabs (0)
  GtkNotebook::has-backward-stepper = 0
  # Whether the standard backward arrow button is displayed (TRUE, 用 FALSE 無效)
#  GtkNotebook::has-forward-stepper = TRUE
  # Whether the standard forward arrow button is displayed (TRUE)
  GtkNotebook::has-secondary-backward-stepper = 1
  # Whether a second backward arrow button is displayed on the opposite end of the tab area (FALSE, 用 TRUE 無效)
#  GtkNotebook::has-secondary-forward-stepper = FALSE
  # Whether a second forward arrow button is displayed on the opposite end of the tab area (FALSE)
  GtkNotebook::tab-overlap = -2
  # Size of tab overlap area (2)
}

style "toolbar" {
  bg[NORMAL] = @gray_6
}

style "tooltips" {
  xthickness = 6
  fg[NORMAL] = @gray_1
  bg[NORMAL] = @gray_a
}

class "GtkToolbar" style "toolbar"
class "GtkWidget" style "default"
widget_class "*<gtkbutton>" style "button"
widget_class "*<gtknotebook>" style "notebook"
widget "gtk-tooltip*" style "tooltips"

2017/09/13

用 BASH 指令將 XML 檔自動排版 (Format XML with BASH)

有不少現成的工具可以將 XML 檔自動排版。自己試著用 bash 指令寫一個,記錄於此。

本文更新於 WordPress:
Format XML with BASH Script

2017/07/17

FluxBox Settings

【前言】

曾經談過 Fluxbox 的樣式設定,現在談其他的設定檔。

$HOME/.fluxbox 為放置設定檔的路徑,

本文更新於 WordPress:
FluxBox Window Manager Settings

2017/07/13

Linux Bash Countdown Timer

【前言】

用 bash 寫的倒數計時程式,在此做個記錄,也提供參考。

設定時間,可用一個、兩個或三個數字。
輸入一個數字,則視為:秒 (可超過 60)。
輸入兩個數字,則分別視為:分、秒 (皆可超過 60)。
輸入三個數字,則分別視為:時、分、秒。
輸入更多數字,只取前三者,餘皆忽略。


本文更新於 WordPress:
Countdown Timer Using BASH Script

2017/07/03

用 Zenity 做簡易的行事曆程式

【前言】


Linux 系統常會安裝有 Zenity 程式,它主要是用來顯示對話框,如:月曆、選檔、選色、輸入框等,多達十五種。

其中的 --text-info 是用來顯示文字訊息。雖然可用在「是否願意接受版權」的場合,但因為可以讀取檔案,所以能當成簡易的行事曆。


本文更新於 WordPress:
A Simple Calendar/To-Do Program Using Zenity

2017/07/02

用 Zenity 做簡易的 Memo 程式

【前言】


Linux 系統常會安裝有 Zenity 程式,它主要是用來顯示對話框,如:月曆、選檔、選色、輸入框等,多達十五種。

其中的 --text-info 是用來顯示文字訊息。雖然可用在「是否願意接受版權」的場合,但因為可以讀取檔案並編輯內容,所以能當成簡易的備忘錄。

本文更新於 WordPress:
A Simple Memo Program Using Zenity

2017/07/01

Fluxbox 深灰色樣式

【前言】


Fluxbox 的樣式檔放在 ~/.fluxbox/styles/ 資料夾中。放入後,會自動讀取,桌面的右鍵選單中,Styles 一項就會包含之。

有五類可設定:桌面 (background)、桌面的右鍵選單 (menu)、桌面小窗格 (slit)、工具列 (toolbar)、視窗 (window)

下述 <texture> 的選項可以有五種:
* [ Flat | Raised | Sunken ] 平面、凸起、或凹下的外觀
* [ Gradient | Solid ] 漸層色或單色
* [ Horizontal | Vertical | Diagonal | Crossdiagonal | Pipecross | Elliptic | Rectangle | Pyramid ] 漸層色的樣式
* [ Interlaced ] darken every other line,可用於 Gradient 或 Solid
* [ Bevel1 | Bevel2 ] 斜角陰影,預設值為 Bevel1,陰影在邊緣。Bevel2 的陰影在邊緣內的 1px。

除以上五種外,還可以用 Pixmap 或 ParentRelative。前者是用圖片,後者是指依父組件的樣式,所以就像透明沒有樣式。


本文更新於 WordPress:
Fluxbox Window Manager Dark Gray Style

2017/06/27

GoldenDict 深灰色樣式

【前言】
GoldenDict 是很好用的字典工具,衍生於 StarDict,在此先感謝這兩個軟體的開發者。

Linux 系統中,GoldenDict 樣式的設定是靠 ~/.goldendict/ 資料夾內的 article-style.css 和 qt-style.css 兩檔。前者設定查詢結果的內容,後者設定兩旁側欄的外觀。

article-style.css 可以設定的選項大部分可按 F12 取得,或在查詢結果的窗格內按滑鼠右鍵,選 [檢查原始碼]。 看到原始碼後,展開 <head> ,再展開 <style ... media="all"> ,看到的這一大串就是。 要複製時,在 <style ... media="all"> 這一行點擊一下,讓底色變藍,按 Ctrl+C,就可以複製起來。 然後在 ~/.goldendict/ 開一個文字檔貼上,存成 article-style.css。

若要取得內容比較完整的 qt-style.css 檔,要去官方網站下載來源碼。當然,article-style.css 也可以由此而得。


本文更新於 WordPress:
GoldenDict Dark Gray Theme

2017/06/02

Linux 系統鍵盤鎖定的顯示

【前言】

本例的筆記型電腦沒有 LED 燈顯示大寫鍵和數字鍵是否鎖定。以前是靠 lxpanel 來顯示,後來不用 lxpanel,就安裝程式來顯示。最近發現根本不需要靠其他程式,只要寫幾個簡短的指令就可解決,現敘述於下。這幾個簡短的指令要存成檔案,並將之設成可執行檔。

視窗管理員(Window manager)通常有一個檔案可以設定,按某一鍵或某些組合鍵,即可執行某個動作。IceWM 和 Fluxbox 都叫 keys 檔。

以下就是結合這兩項,在 keys 檔中設定,按大寫鎖定鍵 (Caps Lock) 或數字鎖定鍵 (Num Lock) 時,分別執行對應的可執行檔,來顯示是否鎖定。



本文更新於 WordPress:
Num Lock / Caps Lock Notifications

2017/03/29

Linux 系統改變筆電螢幕亮度的方法

【前言】

如果筆電的鍵盤有按鍵可以直接改變螢幕亮度,但使用 Linux 系統,按鍵卻失效,有多種方法可以解決。