- 1. IceWM
- 2. 変更点
1. IceWM
これは、「IceWM」の処理を行うモジュールです。
改めて。
「IceWM」のメニューファイルは
~/.icewm/menu
で、メニューの構造は
menu "カテゴリ名" アイコンファイル名 {
prog "アイテム名" アイコンファイル名 ロードモジュール
prog "アイテム名" アイコンファイル名 ロードモジュール
}
という形式になっています。
サブカテゴリを分ける場合は、「menu」をネストさせます。
「アイコンファイル名」は、オリジナルの「MenuMaker」では、カテゴリがすべて「folder」(フォルダのアイコン)となっており、「prog」の行はすべて省略形を示す「-」になっています。
「.png」も「.svg」も表示できるので、変換がないため、短いソースになります。
2. 変更点
長いソースですので、前回との変更点のみ・・・。
#####
# メニューの LibreOffice 行にアイコンを追加して、個別の実行文にする
# @param line 対象行
# @param nextline 対象行の次の行(本クラスでは使用しない)
# @param label 項目名
# @param exe_sentence 実行文
# @param icon アイコンファイル(拡張子なし)
def update_libreoffice(self, line, nextline, label, exe_sentence, icon):
line = line.replace('prog "'+label+'" - libreoffice', 'prog "'+label+'" '+icon+' '+exe_sentence)
return [line, nextline]
#####
# 終了メニュー設定
# @param env 環境変数クラス(本メソッドでは未使用)
# @param dic_exec_icon exec → icon 辞書
# @param lines メニューファイル全行
def set_end_menu(self, env, dic_exec_icon, lines):
try:
lines.append('menu "終了" '+dic_exec_icon['ice']+' {'+"\n")
lines.append(' prog "システム再起動" '+dic_exec_icon['reboot']+' sudo /sbin/reboot '+"\n")
lines.append(' prog "シャットダウン" '+dic_exec_icon['shutdown']+' sudo /sbin/poweroff '+"\n")
lines.append("}\n")
except:
pass
58~68行は、「LibreOffice」の個別のプログラム実行とアイコンを設定しています。
70~83行は、再起動・シャットダウンをメニューに追加しています。
#####
# @brief applications/*.desktop を検索して
# プログラム名 → アイコンファイル名の辞書を返す
# Fluxbox と違って png で良い
# @param env 環境変数クラス
# @param dic_exec_icon .desktop より取得した編集前の exec → icon 辞書
# @return exec → icon ファイル名フルパス の辞書
def get_dic_exec_icon(self, env, dic_exec_icon):
## 有効な拡張子、ディレクトリ(どちらも優先順位順)
を下記へ変更しました。
#####
# @brief applications/*.desktop を検索して
# プログラム名 → アイコンファイル名の辞書を返す
# Fluxbox と違って png で良い
# @param env 環境変数クラス
# @param dic_exec_icon .desktop より取得した編集前の exec → icon 辞書
# @return exec → icon ファイル名フルパス の辞書
def get_dic_exec_icon(self, env, dic_exec_icon):
########## box, update, reboot, shutdown のキーを辞書に追加しておく
dic_exec_icon['ice'] = 'ice'
dic_exec_icon['update'] = 'system-software-update'
dic_exec_icon['reboot'] = 'system-reboot'
dic_exec_icon['shutdown'] = 'system-shutdown'
## 有効な拡張子、ディレクトリ(どちらも優先順位順)
「ice」というアイコンの他、「更新」「再起動」「シャットダウン」のアイコンを取得するようにしました。
#####
# @brief icon をメニューに設定する
# @param line メニューの対象行
# @param nextline 対象行の次の行(IceWM では使用しない)
# @param dic_exec_icon exec → icon 辞書
# @return line 更新した行
def set_menu_icon(self, line, nextline, dic_exec_icon):
head, exeall = line.split('" - ') ##
exeall = exeall.split(' ')
を下記へ変更しました。
#####
# @brief icon をメニューに設定する
# @param line メニューの対象行
# @param nextline 対象行の次の行(IceWM では使用しない)
# @param dic_exec_icon exec → icon 辞書
# @return line 更新した行
def set_menu_icon(self, line, nextline, dic_exec_icon):
try:
head, exeall = line.split('" - ') ##
except:
return line
exeall = exeall.split(' ')
「-」で分割できない際に、こけないようにしています。
|