diff options
| author | jason | 2024-04-02 18:05:33 -0600 |
|---|---|---|
| committer | jason | 2024-04-02 18:05:33 -0600 |
| commit | d165601ffa27ef399d66d8548b4f89af2388aefb (patch) | |
| tree | ba1d1518653d7e28b12c1b0b337a90dd559357fa /scripts | |
| parent | 542742f9e2a99fc2f9ca1d4bc6aeef4b4f57f054 (diff) | |
| download | dotfiles-d165601ffa27ef399d66d8548b4f89af2388aefb.tar.gz dotfiles-d165601ffa27ef399d66d8548b4f89af2388aefb.zip | |
add openbsd specific helper scripts
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/obsd_termbar | 69 | ||||
| -rwxr-xr-x | scripts/openbsd_firefox | 35 |
2 files changed, 104 insertions, 0 deletions
diff --git a/scripts/obsd_termbar b/scripts/obsd_termbar new file mode 100755 index 0000000..f1905b3 --- /dev/null +++ b/scripts/obsd_termbar | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | ## Debug | ||
| 4 | # set -x | ||
| 5 | |||
| 6 | # These will keep termbar running, but at the cost of leaving processes open | ||
| 7 | # when X dies. Helpful to use when tweaking | ||
| 8 | #trap 'exec $0' HUP # Restart itself | ||
| 9 | #trap 'tput cnorm; exit 1' INT QUIT TERM | ||
| 10 | |||
| 11 | clock() { | ||
| 12 | CLOCK=$(date '+%a %d %b %H:%M:%S') | ||
| 13 | } | ||
| 14 | |||
| 15 | workspace_id() { | ||
| 16 | WORKSPACE_ID=$(xprop -root 32c '\t$0' _NET_CURRENT_DESKTOP | cut -f 2) | ||
| 17 | } | ||
| 18 | |||
| 19 | convert_to_hours() { | ||
| 20 | h=$((${1}/60)) | ||
| 21 | m=$((${1}%60)) | ||
| 22 | |||
| 23 | printf "%02d:%02d" $h $m | ||
| 24 | } | ||
| 25 | bat() { | ||
| 26 | BAT_PCT=$(apm -l) | ||
| 27 | BAT_TIME=$(convert_to_hours $(apm -m)) | ||
| 28 | # ↯ ⋇ | ||
| 29 | |||
| 30 | if [ $(sysctl hw.sensors.acpiac0.indicator0 | grep -c On) -eq "1" ]; then | ||
| 31 | AC_STATUS=PWR | ||
| 32 | else | ||
| 33 | AC_STATUS=BAT | ||
| 34 | fi | ||
| 35 | |||
| 36 | } | ||
| 37 | |||
| 38 | mem() { | ||
| 39 | MEM=$(top -n | grep Memory | awk {'print $3'}) | ||
| 40 | } | ||
| 41 | |||
| 42 | cpu() { | ||
| 43 | _CPU_SPEED=$(sysctl hw.cpuspeed | cut -d "=" -f 2) | ||
| 44 | CPU_SPEED=$(bc -l -e scale=1 -e ${_CPU_SPEED}/1000 -e quit | awk '{printf "%.1f", $0}') | ||
| 45 | CPU_TEMP=$(sysctl hw.sensors.cpu0.temp0 | cut -d "=" -f 2 | cut -d "." -f 1) | ||
| 46 | } | ||
| 47 | |||
| 48 | vol() { | ||
| 49 | _VOL=$(sndioctl output.level | cut -d "=" -f 2) | ||
| 50 | VOL=$(bc -l -e scale=1 -e ${_VOL}*100 -e quit | awk '{printf "%.1f\n", $0}') | ||
| 51 | } | ||
| 52 | |||
| 53 | while true; do | ||
| 54 | clock | ||
| 55 | workspace_id | ||
| 56 | bat | ||
| 57 | cpu | ||
| 58 | mem | ||
| 59 | vol | ||
| 60 | |||
| 61 | # Overwrites the input | ||
| 62 | clear | ||
| 63 | #tput cup 1 0 # tput sometimes leaves trailing numbers | ||
| 64 | # cinema display 193.110 | ||
| 65 | |||
| 66 | printf "[${WORKSPACE_ID}] %188.110s CPU: ${CPU_SPEED}Ghz ${CPU_TEMP}C | MEM: ${MEM} | ${AC_STATUS} ${BAT_PCT}%% (${BAT_TIME}) | VOL: ${VOL}%% | ${CLOCK}" | ||
| 67 | |||
| 68 | sleep 5 | ||
| 69 | done | ||
diff --git a/scripts/openbsd_firefox b/scripts/openbsd_firefox new file mode 100755 index 0000000..a34abcb --- /dev/null +++ b/scripts/openbsd_firefox | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | DATASIZE="10485760" | ||
| 4 | OPENFILES="400" | ||
| 5 | |||
| 6 | xm_log() { | ||
| 7 | echo -n "$@\nDo you want to run Firefox anyway?\n\ | ||
| 8 | (If you don't increase these limits, Firefox might fail to work properly.)" | \ | ||
| 9 | xmessage -file - -center -buttons yes:0,no:1 -default no | ||
| 10 | } | ||
| 11 | |||
| 12 | |||
| 13 | # A stack overflow post said you also have to increase virtmem but that | ||
| 14 | # doesn't seem to be the case. If tabs start crashing then try increasing | ||
| 15 | # virtmem. | ||
| 16 | |||
| 17 | #if [ $(ulimit -Sv) -lt ${DATASIZE} ]; then | ||
| 18 | # ulimit -Sv ${DATASIZE} || \ | ||
| 19 | # xm_log "Cannot increase virtualmem-cur to at least ${DATASIZE}" | ||
| 20 | # [ $? -eq 0 ] || exit | ||
| 21 | #fi | ||
| 22 | |||
| 23 | if [ $(ulimit -Sd) -lt ${DATASIZE} ]; then | ||
| 24 | ulimit -Sd ${DATASIZE} || \ | ||
| 25 | xm_log "Cannot increase datasize-cur to at least ${DATASIZE}" | ||
| 26 | [ $? -eq 0 ] || exit | ||
| 27 | fi | ||
| 28 | |||
| 29 | if [ $(ulimit -Sn) -lt ${OPENFILES} ]; then | ||
| 30 | ulimit -Sn ${OPENFILES} || \ | ||
| 31 | xm_log "Cannot increase openfiles-cur to at least ${OPENFILES}" | ||
| 32 | [ $? -eq 0 ] || exit | ||
| 33 | fi | ||
| 34 | |||
| 35 | exec /usr/local/bin/firefox "${@}" | ||