「Feh」の版間の差分
(→デスクトップの壁紙マネージャ: 情報を更新) |
(→ランダム壁紙画像: 同期) |
||
| 67行目: | 67行目: | ||
{{Pkg|imagemagick}} が必要です。 |
{{Pkg|imagemagick}} が必要です。 |
||
| − | == |
+ | == ランダム壁紙画像 == |
| + | |||
{{ic|--bg-foo}} オプションのどれかと {{ic|--randomize}} オプションを使うことでランダムに壁紙を feh で設定することができます、例えば: |
{{ic|--bg-foo}} オプションのどれかと {{ic|--randomize}} オプションを使うことでランダムに壁紙を feh で設定することができます、例えば: |
||
| 85行目: | 86行目: | ||
</nowiki>}} |
</nowiki>}} |
||
| − | 定期的に |
+ | {{Tip|壁紙を定期的に変更するには、スクリプト ([https://mywiki.wooledge.org/BashGuide/TestsAndConditionals#Conditional_Loops_.28while.2C_until_and_for.29 while loop] を参照)、[[cron]] ジョブ、または [[systemd/タイマー]] を使用し、必要な間隔でコマンドを実行します。}} |
| − | |||
| − | ==== スクリプトを使用 ==== |
||
| − | 壁紙をランダムに表示するには、以下のコードでスクリプトを作成します (例: {{ic|wallpaper.sh}})。スクリプトには実行可能属性を付与してください: |
||
| − | |||
| − | {{bc|$ chmod +x wallpaper.sh}} |
||
| − | |||
| − | {{ic|~/.xinitrc}} からスクリプトを呼び出して下さい。もしくは別のファイルを作らないで {{ic|~/.xinitrc}} に直接ソースを記述することもできます。 |
||
| − | |||
| − | {{ic|~/.wallpaper}} ディレクトリや {{Ic|15m}} という時間はを必要に応じて変更してください (オプションは {{Ic|man sleep}} を参照)。 |
||
| − | {{hc|wallpaper.sh|<nowiki> |
||
| − | #!/bin/sh |
||
| − | |||
| − | while true; do |
||
| − | find ~/.wallpaper -type f \( -name '*.jpg' -o -name '*.png' \) -print0 | |
||
| − | shuf -n1 -z | xargs -0 feh --bg-max |
||
| − | sleep 15m |
||
| − | done |
||
| − | </nowiki>}} |
||
| − | |||
| − | {{ic|find ~/.wallpaper}} を {{ic|find ~/.wallpaper/}} に変更する必要があるかもしれません。 |
||
| − | |||
| − | 以下のバージョンは大して変わっていませんが、ディレクトリを再帰的に検索しません: |
||
| − | {{hc|wallpaper.sh|<nowiki> |
||
| − | #!/bin/bash |
||
| − | |||
| − | shopt -s nullglob |
||
| − | cd ~/.wallpaper |
||
| − | |||
| − | while true; do |
||
| − | files=() |
||
| − | for i in *.jpg *.png; do |
||
| − | [[ -f $i ]] && files+=("$i") |
||
| − | done |
||
| − | range=${#files[@]} |
||
| − | |||
| − | ((range)) && feh --bg-scale "${files[RANDOM % range]}" |
||
| − | |||
| − | sleep 15m |
||
| − | done |
||
| − | </nowiki>}} |
||
| − | |||
| − | ===== xinerama 以外のデュアルスクリーン ===== |
||
| − | このスクリプトは nvidia twinview (など) のデュアルスクリーン環境で壁紙を追加できるように ''feh'' の実行を変えています。 |
||
| − | {{hc|wallpaper.sh|<nowiki> |
||
| − | #!/bin/sh |
||
| − | exec feh --bg-max --no-xinerama "$@" |
||
| − | </nowiki>}} |
||
| − | |||
| − | ==== cron ジョブを使用 ==== |
||
| − | [[cron]] ジョブを使うことで同じようなことができ、継続的にスクリプトを sleep させる必要はなくなります。 |
||
| − | |||
| − | {{ic|$ crontab -e}} を実行して以下を追加: |
||
| − | |||
| − | {{bc|<nowiki> |
||
| − | * * * * * DISPLAY=:0.0 feh --bg-max "$(find ~/.wallpaper/|shuf -n1)" |
||
| − | </nowiki>}} |
||
| − | |||
| − | ==== systemd ユーザーセッションを使用 ==== |
||
| − | {{Note|以下は systemd ユーザーセッションを使っている場合にのみ使うことができます。詳しくは [[Systemd/ユーザー]] を見て下さい。}} |
||
| − | |||
| − | ユニットサービスファイルを作成: |
||
| − | {{hc|$HOME/.config/systemd/user/feh-wallpaper.service|<nowiki> |
||
| − | [Unit] |
||
| − | Description=Random wallpaper with feh |
||
| − | |||
| − | [Service] |
||
| − | Type=oneshot |
||
| − | EnvironmentFile=%h/.wallpaper |
||
| − | ExecStart=/bin/bash -c '/usr/bin/feh --bg-max "$(find ${WALLPATH}|shuf|head -n 1)"' |
||
| − | |||
| − | [Install] |
||
| − | WantedBy=default.target |
||
| − | </nowiki>}} |
||
| − | そしてタイマーファイルを作成。時間は必要に応じて変更して下さい。この例では {{ic|15 seconds}} になっています。 |
||
| − | {{hc|$HOME/.config/systemd/user/feh-wallpaper.timer|<nowiki> |
||
| − | [Unit] |
||
| − | Description=Random wallpaper with feh |
||
| − | |||
| − | [Timer] |
||
| − | OnUnitActiveSec=</nowiki>''15s''<nowiki> |
||
| − | Unit=feh-wallpaper.service |
||
| − | |||
| − | [Install] |
||
| − | WantedBy=default.target |
||
| − | </nowiki>}} |
||
| − | この例ではホームディレクトリの隠しファイルで設定を行い、画像が保存されているディレクトリのパスを指定します。 |
||
| − | {{hc|$HOME/.wallpaper|<nowiki> |
||
| − | WALLPATH=</nowiki>''/home/user/.wallpaper/'' |
||
| − | }} |
||
| − | |||
| − | {{ic|feh-wallpaper.timer}} を有効化して下さい。詳しくは [[systemd/タイマー#管理]]を参照。 |
||
| − | |||
| − | {{Note|systemd ユーザーセッションでは、{{ic|systemctl}} で {{ic|--user}} フラグを使って下さい。}} |
||
2023年4月11日 (火) 21:09時点における版
feh は軽量かつ強力な画像ビューアであり、壁紙を管理する機能がないスタンドアロンのウィンドウマネージャの壁紙管理にも使えます。
インストール
使用法
feh は細かく設定することができます。オプションの完全なリストを見るには、feh --help を実行するか feh(1) man ページを参照してください。
画像ビューア
特定のディレクトリの画像をすばやく見るには、以下の引数をつけて feh を起動します:
$ feh -g 640x480 -d -S filename /path/to/directory
-gフラグは画像を強制的に 640x480 以下で表示します-dフラグはファイル名を表示します-S filenameフラグは画像をファイル名でソートします
これはほんの一例です。柔軟性を高めたい場合は、さらに多くのオプションを利用できます。
壁紙を設定する
feh は Openbox, Fluxbox, xmonad などのデスクトップ機能がないウィンドウマネージャの壁紙を管理するのに使えます。
以下のコマンドは最初の壁紙を設定する例です:
$ feh --bg-scale /path/to/image.file
他にも以下のようなスケーリングオプションがあります:
--bg-tile FILE --bg-center FILE --bg-max FILE --bg-fill FILE
次のセッション時に壁紙をまた設定するには、スタートアップファイルに以下を追加してください (例: ~/.xinitrc, ~/.config/openbox/autostart など):
~/.fehbg &
壁紙画像を変更するには、上記の feh --bg-scale /path/to/image.file コマンドを実行した後に作成される ~/.fehbg ファイルを編集してください。
--no-fehbg フラグを渡すことで、~/.fehbg の作成を明示的に無効にすることもできます。
異なるモニターに異なる壁紙をセットアップするには、使用可能なモニターの数と同じ数のファイル パスを渡す必要があります。たとえば、デュアルモニター設定の場合は次のようになります。
$ feh --bg-center path/to/file/for/first/monitor path/to/file/for/second/monitor
SVG 画像を開く
$ feh --conversion-timeout 1 file.svg
imagemagick が必要です。
ランダム壁紙画像
--bg-foo オプションのどれかと --randomize オプションを使うことでランダムに壁紙を feh で設定することができます、例えば:
$ feh --randomize --bg-fill ~/.wallpaper/*
上記のコマンドは ~/.wallpaper/ ディレクトリのファイルからランダムで画像を壁紙に設定します。もしくは、壁紙をサブフォルダに分割している場合は、再帰的に実行することもできます:
$ feh --recursive --randomize --bg-fill ~/.wallpaper
セッションごとに ~/.wallpaper から異なる壁紙をランダムに設定するには、以下を .xinitrc に追加します:
$ feh --bg-max --randomize ~/.wallpaper/* &
以下のように .fehbg を編集することでもランダムに壁紙を設定できます:
$HOME/.fehbg
feh --bg-max --randomize --no-fehbg ~/.wallpaper/*