ログイン
編集不可のページディスカッション情報添付ファイル
"clear/misc"の差分

MMA
16と17のリビジョン間の差分
2011-11-30 10:44:53時点のリビジョン16
サイズ: 2986
編集者: clear
コメント:
2011-11-30 10:46:10時点のリビジョン17
サイズ: 2971
編集者: clear
コメント:
削除された箇所はこのように表示されます。 追加された箇所はこのように表示されます。
行 103: 行 103:
行 105: 行 106:
    echo $VGA: on
    echo set $VGA
$(echo $orientation | sed 's/-/ /g') $LCD
    echo $VGA: on($(echo $orientation | sed 's/-/ /g') $LCD)

小物類いろいろ

作りっぱなし置きっぱなし。

スクリーンショット

タイマー付き、画面全体

第一引数にファイル名、第2引数に待ち時間(指定しなければ0)を与える。すぐに制御を返す。

   1 #!/usr/local/bin/bash
   2 if [ $# -eq 2 ]; then
   3     sleeptime=$2
   4 else
   5     sleeptime=0
   6 fi
   7 (sleep $sleeptime; import -window root $1; echo "captured.")&

クリックしたウィンドウ

実行するとマウスポインタが十字になるのでスクリーンショットを撮りたいウィンドウをクリックする。

   1 #!/bin/sh
   2 id=$(xwininfo | grep "Window id:" | awk '{ print $4 }') && import -window $id $(date +"~/picture/scrnshot/scrnshot%y%m%d%H%M%S.png")

dwm用ステータスバー

環境や起動の仕方によってはdwmが終了しても生き残る場合があるので、そのような場合は生存確認をする。

pgrep -aU $(id -u) dwm
if [ $? -eq 1 ]; then
    exit 0
else
    sleep 30
fi

シンプルなバッテリ状態+時計

あまり画面に余裕のないラップトップ用。

   1 #!/bin/sh
   2 export LC_TIME=C # 曜日の表記のため
   3 while true; do
   4     b=$(acpi)
   5     state=$(echo $b | awk 'BEGIN{s=" "}/Discharging/{s="- "}/Charging/{s="+ "}END{print s}')
   6     remain=$(echo $b | awk '{print $4}'|tr -d '%,')
   7     xsetroot -name "$remain$state$(date +"%a %d %R")"
   8     sleep 30
   9 done

普通の時計

月日と曜日、時刻。

   1 #!/bin/sh
   2 while true; do
   3     xsetroot -name "$(date +"%m/%d(%a) %R")"
   4     sleep 30
   5 done

16色端末

   1 #!/usr/local/bin/bash
   2 reset="\033[0m"
   3 echo -e "\033[30mblack\t\033[1;30mbold black$reset"
   4 echo -e "\033[31mred\t\033[1;31mbold red$reset"
   5 echo -e "\033[32mgreen\t\033[1;32mbold green$reset"
   6 echo -e "\033[33myellow\t\033[1;33mbold yellow$reset"
   7 echo -e "\033[34mblue\t\033[1;34mbold blue$reset"
   8 echo -e "\033[35mmagenta\t\033[1;35mbold magenta$reset"
   9 echo -e "\033[36mcyan\t\033[1;36mbold cyan$reset"
  10 echo -e "\033[37mwhite\t\033[1;37mbold white$reset"

デュアルディスプレイ

   1 #!/bin/sh
   2 # vgaset.sh [l|r|t|b] on|off
   3 
   4 # monitor on the device
   5 LCD=LVDS1
   6 # external monitor
   7 VGA=VGA1
   8 
   9 orientation='-below'
  10 if [ $# -gt 1 ]; then
  11     case $1 in
  12     l)
  13         orientation='-left-of'
  14         ;;
  15     r)
  16         orientation='-right-of'
  17         ;;
  18     t)
  19         orientation='-upper'
  20         ;;
  21     b|*)
  22         orientation='-below'
  23         ;;
  24     esac
  25     op=$2
  26 else
  27     op=$1
  28 fi
  29 
  30 case $op in
  31 on)
  32     echo $VGA: on($(echo $orientation | sed 's/-/ /g') $LCD)
  33     xrandr --output $VGA --auto $orientation $LCD
  34     ;;
  35 off)
  36     echo $VGA: off
  37     xrandr --output $VGA --off
  38     ;;
  39 *)
  40     echo unknown option
  41     exit 1
  42     ;;
  43 esac

clear/misc (最終更新日時 2013-05-31 16:43:07 更新者 clear)