2016年8月7日日曜日

Linux Mint Xfceインストール時のメモ

Acer Aspire E11のHDDをSSDに換装した後、Linux Mint Xfceを入れてみた。その後にすることのメモ。

日本語化


$ sudo apt update
$ sudo apt dist-upgrade

としてパッケージを最新状態にした後、Fcitx-Mozc をインストールし、有効に。

$ sudo apt install fcitx-mozc --install-recommends
$ im-config -n fcitx

参考: 人気の「Linux Mint 17.2」/早速日本語入力を試す - ハルさんの電脳メモ 


輝度の調整



xbacklightをインストール。

$ sudo aptitude install xbacklight


次に、「セッションと起動」から「自動開始アプリケーション」を選んで「Add」。

名前:ディスプレイ輝度
説明:xbacklightで暗くする
コマンド:xbacklight -set 30

参考:LinuxMint17でのディスプレイ輝度の調整 - Raspi-Linux ガジェットベース


タッチパッドを無効化




僕のPCでは、タッチパッドを有効にしてると、なぜかたまにマウスカーソルが画面上を飛び回る愉快な状態になるので、無効化する。
スタートボタンをクリックし、「設定→マウスとタッチパッド」から無効化。


電池残量をタスクトレイに表示




タスクトレイを右クリックし、「パネル→新しいアイテムの追加」から「電源管理プラグイン」を追加。

Chrome


公式サイトからダウンロードし、インスコする。


Emacs


$ sudo apt install emacs

でインストール。次に、「.emacs」を編集し、以下を追加。

;;起動時の画面を消す
(setq inhibit-startup-message t)

;;アイコンを消す
(tool-bar-mode -1)

; 行番号表示
(require 'linum)
(global-linum-mode)

;; メッセージを消す
(setq initial-scratch-message "")

;; beep音を消す
(setq visible-bell t)
(setq ring-bell-function 'ignore)

;; *.~ とかのバックアップファイルを作らない
(setq make-backup-files nil)

;; .#* とかのバックアップファイルを作らない
(setq auto-save-default nil)

;; .emacs.dにパスを通す
(add-to-list 'load-path "~/.emacs.d")

;; howm-create2dir読み込み
(require 'howm-create2dir)

;; howmファイルをhowm2dirモードで開く
(setq auto-mode-alist
      (cons (cons "\\.howm$" 'howm-create2dir-mode) auto-mode-alist))

;; 文字コードをshift-jisに
(set-language-environment "Japanese")
(prefer-coding-system 'shift_jis)

次に、homeに「.emacs.d」フォルダを作成し、そこに以下のスクリプトを入れる(以前作ったやつをすっごく適当に改変したものなのでそのうち見直したい)。これで、Emacs起動後ミニバッファで「make-howm-create2dir-file」と入力すると、DropboxフォルダのTempフォルダにhowmを作成できる。
makehowm2dir.el 

;;; howmファイルを作成
(defun make-howm-create2dir-file (&optional howm-dir)
  (interactive)
  (let* ((filename (format-time-string "%Y-%m-%d-%H%M%S.howm"))
  (filepath
   (if howm-dir
       (concat (file-name-as-directory howm-dir) (format-time-string "%Y-%m-%d-%H%M%S.howm"))
     (format-time-string "Dropbox/Temp/%Y-%m-%d-%H%M%S.howm"))))
;;;     (format-time-string "%Y-%m-%d-%H%M%S.howm"))))
    (find-file filepath)
    (if (eq (point-max) (point-min))
 (progn
   (insert (format-time-string "= \n\n[%Y-%m-%d %H:%M]\n"))
   (goto-char (+ (point-min) 2))))
    ))

;;; howmファイルを作成2
(defun make-howm-create2dir-file2 ()
  (interactive)
  (let* ((filename (format-time-string "%Y-%m-%d-%H%M%S.howm"))
  (filepath (format-time-string "%Y-%m-%d-%H%M%S.howm")))
    (find-file filepath)
    (if (eq (point-max) (point-min))
 (progn
   (insert (format-time-string "= \n\n[%Y-%m-%d %H:%M]\n"))
   (goto-char (+ (point-min) 2))))
    ))


;;; 本体
(defun howm-create2dir (arg)
  (if (file-directory-p arg)
      (progn
 (make-howm-create2dir-file arg)
 (howm-create2dir-mode))))

;;; メジャーモード
(define-derived-mode howm-create2dir-mode nil "howm2dir"
       "homu mode"
       (define-key howm-create2dir-mode-map "\C-c,c" 'make-howm-create2dir-file2)
       (define-key howm-create2dir-mode-map (kbd "C-:") 'hateda-heading)
       (define-key howm-create2dir-mode-map (kbd "C-]") 'hateda-heading2)
       (font-lock-add-keywords
        nil
        '(("^\\*\\*\\*.*\n" . my-face-b-1)
   ("^\\*\\*.*\n" . my-face-b-2))))

;;; フェイス
(defface my-face-b-1 '((t (:foreground "white" :background "SteelBlue"))) nil)
(defface my-face-b-2 '((t (:foreground "white" :background "blue"))) nil)
(defvar my-face-b-1 'my-face-b-1)
(defvar my-face-b-2 'my-face-b-2)

;;; 行頭に見出しをつける
(defun hateda-heading ()
  (interactive "*")
  (save-excursion
    (beginning-of-line)
    (insert "**")))

(defun hateda-heading2 ()
  (interactive "*")
  (save-excursion
    (beginning-of-line)
    (insert "*")))

(provide 'howm-create2dir)
(provide 'howm-create2dir-mode)

Guake-terminal




F12を押すと上から降りてきて、もう一度F12を押すと戻っていくターミナル。

$ sudo apt-get install guake -y

でインストール。
次に、スタートボタンをクリックし、

「設定→設定マネージャー→セッションと起動→自動開始アプリケーション→追加」から、名前にguake、コマンドに「bash -c 'sleep 5s; guake'」と入力して、システム起動時に起動するようにする。


参考:Linuxmintでguake - 鶏口牛後

DropBox



公式サイトに行ってダウンロードし、インストールする。ついで、

$ dropbox start -i

とコマンドを打つと起動する。


Atom


Markdownをやるためにインスコする。


$ sudo add-apt-repository ppa:webupd8team/atom
$ sudo apt-get update
$ sudo apt-get install atom

参考:Ubuntu 15.04 LinuxMint 17 に Atomをインストールする - VariedTasteFinder

ranger




ターミナルで起動するファイラ。

まずは、ranger本体と必要なパッケージをインストールする。

$ sudo apt-get install ranger nkf w3m lynx highlight atool mediainfo xpdf caca-utils ranger --copy-config=all

次に、設定ファイルを作成する。

$ ranger --copy-config=all

scope.shを編集。テキストファイルが文字化けしないようにし、かつ枠の幅で折り返すようにする。nkfというコマンドとfoldというコマンドを使えばよさそう

#!/usr/bin/env sh
# ranger supports enhanced previews.  If the option "use_preview_script"
# is set to True and this file exists, this script will be called and its
# output is displayed in ranger.  ANSI color codes are supported.

# NOTES: This script is considered a configuration file.  If you upgrade
# ranger, it will be left untouched. (You must update it yourself.)
# Also, ranger disables STDIN here, so interactive scripts won't work properly

# Meanings of exit codes:
# code | meaning    | action of ranger
# -----+------------+-------------------------------------------
# 0    | success    | success. display stdout as preview
# 1    | no preview | failure. display no preview at all
# 2    | plain text | display the plain content of the file
# 3    | fix width  | success. Don't reload when width changes
# 4    | fix height | success. Don't reload when height changes
# 5    | fix both   | success. Don't ever reload

# Meaningful aliases for arguments:
path="$1"    # Full path of the selected file
width="$2"   # Width of the preview pane (number of fitting characters)
height="$3"  # Height of the preview pane (number of fitting characters)

maxln=200    # Stop after $maxln lines.  Can be used like ls | head -n $maxln

# Find out something about the file:
mimetype=$(file --mime-type -Lb "$path")
extension=${path##*.}

# Functions:
# runs a command and saves its output into $output.  Useful if you need
# the return value AND want to use the output in a pipe
try() { output=$(eval '"$@"'); }

# writes the output of the previouosly used "try" command
dump() { echo "$output"; }

# a common post-processing function used after most commands
trim() { head -n "$maxln"; }

# wraps highlight to treat exit code 141 (killed by SIGPIPE) as success
highlight() { command highlight "$@"; test $? = 0 -o $? = 141; }

case "$extension" in
    # Archive extensions:
    7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
    rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
        try als "$path" && { dump | trim; exit 0; }
        try acat "$path" && { dump | trim; exit 3; }
        try bsdtar -lf "$path" && { dump | trim; exit 0; }
        exit 1;;
    rar)
        try unrar -p- lt "$path" && { dump | trim; exit 0; } || exit 1;;
    # PDF documents:
    pdf)
        try pdftotext -l 10 -nopgbrk -q "$path" - && \
            { dump | trim | fmt -s -w $width; exit 0; } || exit 1;;
    # BitTorrent Files
    torrent)
        try transmission-show "$path" && { dump | trim; exit 5; } || exit 1;;
    # HTML Pages:
    htm|html|xhtml)
        try w3m    -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; }
        try lynx   -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; }
        try elinks -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; }
        ;; # fall back to highlight/cat if the text browsers fail
esac

case "$mimetype" in
    # Syntax highlight for text files:
    text/* | */xml)
        try nkf "$path" && { dump | trim | fold -b -w $width; exit 5; } || exit 2;;
    # Ascii-previews of images:
    image/*)
        img2txt --gamma=0.6 --width="$width" "$path" && exit 4 || exit 1;;
    # Display information about media files:
    video/* | audio/*)
        exiftool "$path" && exit 5
        # Use sed to remove spaces so the output fits into the narrow window
        try mediainfo "$path" && { dump | trim | sed 's/  \+:/: /;';  exit 5; } || exit 1;;
esac

exit 1

参考