2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4 # this gets sourced. shebang is just for file mode detection
11 source /a
/bin
/distro-setup
/path-add-function
13 # add this with absolute paths as needed for better security
14 #path-add --end /path/to/node_modules/.bin
16 # pip3 --user things go here:
17 path-add
--end ~
/.local
/bin
18 path-add
--ifexists --end /a
/work
/libremanage
19 path-add
--ifexists --end /a
/opt
/adt-bundle
*/tools
/a
/opt
/adt-bundle
*/platform-tools
20 path-add
--ifexists --end /a
/opt
/scancode-toolkit-3.0
.2
27 # generated instead of dynamic for the benefit of shellcheck
28 #for x in /a/bin/distro-functions/src/* /a/bin/!(githtml)/*-function?(s); do echo source $x ; done
29 source /a
/bin
/distro-functions
/src
/identify-distros
30 source /a
/bin
/distro-functions
/src
/package-manager-abstractions
31 source /a
/bin
/log-quiet
/logq-function
32 source /a
/bin
/small-misc-bash
/psg-function
33 # for x in /a/bin/bash_unpublished/source-!(.#*); do echo source $x; done
34 source /a
/bin
/bash_unpublished
/source-semi-priv
35 source /a
/bin
/bash_unpublished
/source-state
37 source /a
/bin
/log-quiet
/logq-function
46 complete
-F _longopt la lower low rlt rld rl lld ts ll dircp ex fcp fct fpst gr
50 if which anki
&>/dev
/null
; then
53 schroot
-c anki
-- anki
58 # pushd in case current directory has an ansible.cfg file
59 pushd /a
/xans
>/dev
/null
60 ansible-playbook
-v -l ${1:- $(hostname -f)} site.yml
64 pushd /a
/work
/ansible-configs
>/dev
/null
65 time ansible-playbook
-v -i inventory adhoc.yml
"$@"
69 pushd /a
/bin
/distro-setup
/a
>/dev
/null
70 ansible-playbook site.yml
75 # googling android emulator libGL error: failed to load driver: r600
76 # lead to http://stackoverflow.com/a/36625175/14456
77 export ANDROID_EMULATOR_USE_SYSTEM_LIBS
=1
78 /a
/opt
/android-studio
/bin
/studio.sh
"$@" &r
;
82 bbk
() { # btrbk wrapper
85 systemctl is-active btrbk.timer || active
=false
87 ser disable btrbk.timer
89 if systemctl is-active btrbk.service
; then
90 $active && ser
enable btrbk.timer
91 echo "cron btrbk is already running"
96 btrbk-run
"$@" | pee
cat "systemd-cat -t btrbk-run"
97 $active && ser
enable btrbk.timer
100 bfg
() { java
-jar /a
/opt
/bfg-1.12
.14.jar
"$@"; }
103 xclock
-digital -update 1 -face 'arial black-80:bold'
111 switch-mail-host
$1 $HOSTNAME | pee
cat "systemd-cat -t switch-mail-host"
118 switch-mail-host
$HOSTNAME $1 | pee
cat "systemd-cat -t switch-mail-host"
121 rsync $@
--delete-excluded -ahviSAXPH --specials --devices --delete --relative \
122 --exclude-from=/p
/c
/li-rsync-excludes
/a
/bin
/a
/exe
/a
/h
/a
/c
/p
/c
/machine_specific
/li
/a
/opt
/{emacs
,emacs-debianstable
,mu
} root@li
:/
125 rsync $@
--delete-excluded -ahviSAXPH --specials --devices --delete --relative \
126 --exclude-from=/p
/c
/li-rsync-excludes
/a
/bin
/a
/exe
/a
/h
/a
/c
/p
/c
/machine_specific
/li root@li
:/
131 local f
=/etc
/bitcoin
/bitcoin.conf
132 # importprivkey will timeout if using the default of 15 mins.
133 # upped it to 1 hour.
134 bitcoin-cli
-rpcclienttimeout=60000 -$
(s
grep rpcuser
= $f) -$
(s
grep rpcpassword
= $f) "$@"
137 btcusd
() { # $1 btc in usd
139 price
="$(curl -s https://api.coinbase.com/v2/prices/BTC-USD/spot | jq -r .data.amount)"
140 printf "$%s\n" "$price"
142 printf "$%.2f\n" "$(echo "scale
=4; $price * $1"| bc -l)"
145 usdbtc
() { # $1 usd in btc
147 price
="$(curl -s https://api.coinbase.com/v2/prices/BTC-USD/spot | jq -r .data.amount)"
148 printf "$%s\n" "$price"
150 # 100 mil satoshi / btc. 8 digits after the 1.
151 printf "%.8f btc\n" "$(echo "scale
=10; $1 / $price "| bc -l)"
154 satoshi
() { # $1 satoshi in usd
156 price
="$(curl -s https://api.coinbase.com/v2/prices/BTC-USD/spot | jq -r .data.amount)"
157 price
=$
(echo "scale=10; $price * 0.00000001"|
bc -l)
158 printf "$%f\n" "$price"
160 printf "$%.2f\n" "$(echo "scale
=10; $price * $1"| bc -l)"
166 cbfstool
() { /a
/opt
/coreboot
/build
/cbfstool
"$@"; }
172 cp /a
/bin
/data
/COPYING
"$@"
174 cp /a
/bin
/data
/COPYING .
181 cp /a
/bin
/data
/LICENSE
"$@"
183 cp /a
/bin
/data
/LICENSE .
188 if type -p chromium
&>/dev
/null
; then
192 cmd
="schroot -c stretch chromium"
193 CHROMIUM_FLAGS
='--enable-remote-extensions' $cmd &r
198 dat
() { # do all tee, for more complex scripts
199 tee >(ssh frodo bash
-l) >(bash
-l) >(ssh x2 bash
-l) >(ssh tp bash
-l)
204 for host in x2 tp kd
; do
205 ssh $host $
(printf "")
210 debian_pick_mirror
() {
211 # netselect-apt finds a fast mirror.
212 # but we need to replace the mirrors ourselves,
213 # because it doesnt do that. best it can do is
214 # output a basic sources file
215 # here we get the server it found, get the main server we use
216 # then substitute all instances of one for the other in the sources file
217 # and backup original to /etc/apt/sources.list-original.
218 # this is idempotent. the only way to identify debian sources is to
219 # note the original server, so we put it in a comment so we can
222 file=$
(mktemp
-d)/f
# safe way to get file name without creating one
223 sudo netselect-apt
-o "$file" ||
return 1
224 url
=$
(grep ^
\\w
$file |
head -n1 |
awk '{print $2}')
225 sudo
cp -f /etc
/apt
/sources.list
/etc
/apt
/sources.list-original
226 sudo
sed -ri "/http.us.debian.org/ s@( *[^ #]+ +)[^ ]+([^#]+).*@\1$url\2# http.us.debian.org@" /etc
/apt
/sources.list
232 envload
() { # load environment from a previous: export > file
233 local file=${1:-$HOME/.${USER}_env}
234 eval "$(export | sed 's/^declare -x/export -n/')"
235 while IFS
= read -r line
; do
236 # declare -x makes variables local to a function
237 eval ${line/#declare -x/export}
242 # one that comes with distros is too old for newer devices
244 /a
/opt
/android-platform-tools
/fastboot
"$@";
247 kdecd
() { /usr
/lib
/x86_64-linux-gnu
/libexec
/kdeconnectd
; }
249 # List of apps to install/update
250 # Create from existing manually installed apps by doing
252 # fdroidcl search -i, then manually removing
253 # automatically installed/preinstalled apps
256 # # my attempt at recovering from boot loop:
257 # # in that case, boot to recovery (volume up, home button, power, let go of power after samsun logo)
259 # mount /dev/block/mmcblk0p12 /data
261 # find -iname '*appname*'
263 # usually good enough to just rm -rf /data/app/APPNAME
266 # # causes replicant to crash
267 # org.quantumbadger.redreader
268 # org.kde.kdeconnect_tp
270 # not broke, but wont work without gps
271 #com.zoffcc.applications.zanavi
272 # not broke, but not using atm
273 #com.nutomic.syncthingandroid
274 # # doesn\'t work on replicant
275 #net.sourceforge.opencamera
278 de.marmaro.krt.ffupdater
279 me.ccrama.redditslide
280 org.fedorahosted.freeotp
282 com.alaskalinuxuser.justnotes
283 com.artifex.mupdf.viewer.app
284 com.danielkim.soundrecorder
286 com.ghostsq.commander
288 com.jmstudios.redmoon
290 org.kde.kdeconnect_tp
293 cz.martykan.forecastie
296 de.marmaro.krt.ffupdater
297 eu.siacs.conversations
299 im.vector.alpha
# riot
301 me.tripsit.tripmobile
303 net.minetest.minetest
308 org.smssecure.smssecure
310 sh.
ftp.rocketninelabs.meditationassistant.opensource
312 # https://forum.xda-developers.com/android/software-hacking/wip-selinux-capable-superuser-t3216394
317 local -A installed updated
320 if fdroidcl search
-u |
grep ^org.fdroid.fdroid
; then
321 fdroidcl
install org.fdroid.fdroid
325 for p
in $
(fdroidcl search
-i|
grep -o "^\S\+"); do
328 for p
in $
(fdroidcl search
-u|
grep -o "^\S\+"); do
331 for p
in ${fdroid_pkgs[@]}; do
332 if ! ${installed[$p]:-false}; then
334 # sleeps are just me being paranoid since replicant has a history of crashing when certain apps are installed
338 for p
in ${!installed[@]}; do
339 if ! ${updated[$p]:-true}; then
346 firefox-default-profile
() {
347 key
=Default value
=1 section
=$1
348 file=/p
/c
/subdir_files
/.mozilla
/firefox
/profiles.ini
349 sed -ri "/^ *$key/d" "$file"
350 sed -ri "/ *\[$section\]/,/^ *\[[^]]+\]/{/^\s*$key[[:space:]=]/d};/ *\[$section\]/a $key=$value" "$file"
352 fdhome
() { #firefox default home profile
353 firefox-default-profile Profile0
357 firefox-default-profile Profile4
361 if type -P firefox
&>/dev
/null
; then
371 firefox
-P alt
"$@" >/dev
/null
2>&1
377 local dname
="${PWD##*/}"
378 local m
="/a/tmp/$dname-missing"
379 local d
="/a/tmp/$dname-diff"
380 [[ -e $d ]] && rm "$d"
381 [[ -e $m ]] && rm "$m"
384 while read -r line
; do
386 if [[ -e "$fsfile" ]]; then
387 md5diff
"$line" "$fsfile" && tee -a "/a/tmp/$dname-diff" <<< "$fsfile $line"
393 done < <(find .
-type f
)
396 (( msize
<= 100 )) && cat $m
400 # expected output, with different tmp dirs
401 # /tmp/tmp.HDPbwMqdC9/c/d ./c/d
402 # /a/tmp/tmp.qLDkYxBYPM-missing
412 echo different
> $x/c
/d
417 # test whether missing files were renamed, generally for use with fsdiff
418 # $1 = fsdiff output file, $2 = directory to compare to. pwd = fsdiff dir
419 # echos non-renamed files
423 { sums
+=( "$(md5sum < "$x")" ) ; } 2>/dev
/null
425 while read -r line
; do
426 { missing_sum
=$
(md5sum < "$line") ; } 2>/dev
/null
428 for x
in "${sums[@]}"; do
429 if [[ $missing_sum == "$x" ]]; then
434 $renamed ||
echo "$line"
440 # F = fullscren, z = random, Z = auto zoom
441 command feh
-FzZ "$@"
447 firefox
-P default
"$@" >/dev
/null
2>&1
452 git config user.email ian@iankelling.org
456 # at least in flidas, things rely on gpg being gpg1
462 local email
=ian@iankelling.org
463 if readlink ~
/.mu |
grep fsf
&>/dev
/null
; then
466 git send-email
--notes "--envelope-sender=<$email>" \
467 --suppress-cc=self
"$@"
472 # do git status on published repos.
475 cd $
(readlink
-f $x)/..
476 status
=$
(i status
-s) ||
pwd
477 if [[ $status ]]; then
480 printf "%s\n" "$status"
488 /a
/opt
/idea-IC-163.7743
.44/bin
/idea.sh
"$@" &r
492 if type gvfs-open
&> /dev
/null
; then
497 # another alternative is run-mailcap
501 grep -Evi -e "^(\S+\s+){4}(sudo|sshd|cron)\[\S*:" \
502 -e "^(\S+\s+){4}systemd\[\S*: (starting|started) (btrfsmaintstop|dynamicipupdate|spamd dns bug fix cronjob|rss2email)\.*$"
505 journalctl
-n 10000 -f "$@" | jfilter
507 jr
() { journalctl
"$@" | jfilter |
less ; }
508 jrf
() { journalctl
-f "$@" | jfilter
; }
511 kff
() { # keyboardio firmware flash
512 pushd /a
/bin
/distro-setup
/Arduino
/Model01-Firmware
513 yes $
'\n' |
make flash
521 if [[ $1 == /* ]]; then
523 if mountpoint
/mnt
/$base; then
528 if ! sudo cryptsetup luksOpen
$l $base; then
532 sudo mkdir
-p /mnt
/$base
533 sudo mount
/dev
/mapper
/$base /mnt
/$base
534 sudo chown
$USER:$USER /mnt
/$base
537 sudo umount
/mnt
/$base
538 l
=$
(sudo cryptsetup status
/dev
/mapper
/$base|
sed -rn 's/^\s*device:\s*(.*)/\1/p')
539 sudo cryptsetup luksClose
/dev
/mapper
/$base ||
return 1
550 [[ -e $src ]] ||
{ set +x
; return 1; }
551 mv -T $src $dst ||
{ set +x
; return 1; }
554 mu index
--maildir=/m
/4e
562 [[ -e $src ]] ||
{ set +x
; return 1; }
563 if [[ -L $dst ]]; then rm $dst; fi
570 markdown
"$1" >/tmp
/mdtest.html
571 firefox
/tmp
/mdtest.html
576 mo
() { xset dpms force off
; } # monitor off
579 e
"lspci -nnk|gr -iA2 net"
580 lspci
-nnk|gr
-iA2 net
582 e
"s lshw -C network"
589 ser stop NetworkManager
591 s resolvconf
-d NetworkManager
597 ser start NetworkManager
603 oathtool
--totp -b "$@" | xclip
-selection clipboard
608 # from http://askubuntu.com/questions/456021/remove-vocals-from-mp3-and-get-only-instrumentals
609 pactl load-module module-ladspa-sink sink_name
=Karaoke master
=alsa_output.usb-Audioengine_Audioengine_D1-00.analog-stereo plugin
=karaoke_1409 label
=karaoke control
=-30
612 pfind
() { #find *$1* in $PATH
613 [[ $# != 1 ]] && { echo requires
1 argument
; return 1; }
615 IFS
=: pathArray
=($PATH); unset IFS
616 find "${pathArray[@]}" -iname "*$1*"
620 # trash-restore lists everything that has been trashed at or below CWD
621 # This picks out files just in CWD, not subdirectories,
622 # which also match grep $1, usually use $1 for a time string
623 # which you get from running restore-trash once first
626 # last condition is to not ask again for ones we skipped
627 while name
="$( echo | restore-trash | gr "$PWD/[^
/]\
+$
" | gr "$1" )" \
628 && [[ $name ]] && (( $
(wc -l <<<"$name") >= nth
)); do
629 name
="$(echo "$name" | head -n $nth | tail -n 1 )"
630 read -r -p "$name [Y/n] " ask
631 if [[ ! $ask ||
$ask == [Yy
] ]]; then
632 x
=$
( echo "$name" | gr
-o "^\s*[0-9]*" )
633 echo $x | restore-trash
> /dev
/null
634 elif [[ $ask == [Nn
] ]]; then
644 rld
/a
/h
/_site
/ li
:/var
/www
/iankelling.org
/html
649 # fixes the menu bar in xmonad. this won\'t be needed when xmonad
650 # packages catches up on some changes in future (this is written in
653 # geekosaur: so youll want to upgrade to xmonad 0.13 or else use a
654 # locally modified XMonad.Hooks.ManageDocks that doesnt set the
655 # work area; turns out it\'s impossible to set correctly if you are
656 # not a fully EWMH compliant desktop environment
658 # geekosaur: chrome shows one failure mode, qt/kde another, other
659 # gtk apps a third, ... I came up with a setting that works for me
660 # locally but apparently doesnt work for others, so we joined the
661 # other tiling window managers in giving up on setting it at all
663 xprop
-root -remove _NET_WORKAREA
667 # reviewboard, used at my old job
668 #rbpipe() { rbt post -o --diff-filename=- "$@"; }
669 #rbp() { rbt post -o "$@"; }
680 hr
; echo dnsmasq is $
(systemctl is-active dnsmasq
)
681 f
=/var
/run
/dnsmasq
/resolv.conf
682 hr
; echo $f:; ccat
$f
683 f
=/etc
/dnsmasq-servers.conf
684 hr
; echo $f:; ccat
$f
687 # only run on MAIL_HOST. simpler to keep this on one system.
688 r2eadd
() { # usage: name url
689 # initial setup of rss2email:
690 # r2e new r2e@iankelling.org
691 # that initializes files, and sets default email.
692 # symlink to the config doesnt work, so I copied it to /p/c
693 # and then use cli option to specify explicit path.
694 # Only option changed from default config is to set
697 # or else for a few feeds, the from address is set by the feed, and
698 # if I fail delivery, then I send a bounce message to that from
699 # address, which makes me be a spammer.
701 r2e add
$1 "$2" $1@r2e.iankelling.org
702 # get up to date and dont send old entries now:
705 r2e
() { command r2e
-d /p
/c
/rss2email.json
-c /p
/c
/rss2email.cfg
"$@"; }
707 rspicy
() { # usage: HOST DOMAIN
708 # connect to spice vm remote host. use vspicy for local host
710 # shellcheck disable=SC2087
712 sudo virsh dumpxml $2|grep "<graphics.*type='spice'" | \
713 sed -rn "s/.*port='([0-9]+).*/\1/p"
719 echo "error: no port found. check that the domain is running."
725 # s gem install scss-lint
726 pushd /a
/opt
/thoughtbot-guides
729 scss-lint
-c /a
/opt
/thoughtbot-guides
/style
/sass
/.scss-lint.yml
"$@"
736 script -t -c "mpv --no-config --no-resume-playback --no-terminal --no-audio-display '$1'" $tmp/typescript
2>$tmp/timing
737 # todo, the current sleep seems pretty good, but it
738 # would be nice to have an empirical measurement, or
739 # some better wait to sync up.
741 # note: --loop-file=no prevents it from hanging if you have that
742 # set to inf the mpv config.
743 # --loop=no prevents it from exit code 3 due to stdin if you
744 # had it set to inf in mpv config.
746 # args go to mpv, for example --volume=80, 50%
749 trap "trap - TERM && kill 0" INT TERM ERR; set -e
750 ( sleep .2; scriptreplay <( cat <<'EOF'
754 $(cat $tmp/typescript)
757 base64 -d - <<'EOF'| mpv --loop=no --loop-file=no --no-terminal --no-audio-display "\$@" -
766 smeld
() { # ssh meld usage host1 host2 file
767 meld
<(ssh $1 cat $3) <(ssh $2 cat $3)
771 PATH
=/usr
/local
/spdhackfix
:$PATH command spd
"$@"
778 # ssh, copy my universal config over if needed.
780 # inspired from https://github.com/Russell91/sshrc
783 local args info_date info_t
type now tmp old sshinfo
787 # ssh [-1246Antivivisectionist] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
788 # [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file] [-L address]
789 # [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-Q query_option]
790 # [-R address] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] [user@]hostname
795 -[1246AaCfGgKkMNnqsTtVvXxYy
])
798 -[bcDEeFIiLlmOopQRSWw
])
799 # -oOption etc is valid
800 if (( ${#1} >= 3 )); then
803 args
+=("$1" "$2"); shift 2
813 tmpa
=(/p
/sshinfo
/???????????
"$remote")
815 if [[ -e $sshinfo ]]; then
816 tmp
=${sshinfo[0]##*/}
818 type=${info_date: -1}
819 info_date
=${info_date::10}
820 info_sec
=$
(date -d @
$info_date +%s
)
822 #e $(( $(stat -c%Y /b/ds/brc) - $(date -d @$info_date +%s) ))
823 if (( $
(stat
-c%Y
/b
/ds
/brc
) > info_sec || $
(stat
-c%Y
/b
/ds
/.bashrc
) > info_sec
)); then
827 # use this weird yes thing to ensure we know ssh succeeded
828 tmp
=$
(command ssh "${args[@]}" "$remote" "if test -e /p/sshinfo; then echo yes; fi") ||
return
829 if [[ $tmp == yes ]]; then
836 if [[ $type == b
]]; then
838 RSYNC_RSH
="ssh ${args[*]}" rsync
-rptL /b
/ds
/.iank
"$remote":
840 sshinfo
=/p
/sshinfo
/$now$type"$remote"
846 # Theres a couple ways to do this. im not sure whats best,
847 # but relying on bash 4.4+ escape quoting seems most reliable.
849 command ssh -t "${args[@]}" "$remote" "INPUTRC=.iank/.inputrc bash --rcfile .iank/.bashrc -c ${@@Q}"
851 # command ssh -t "${args[@]}" "$remote" "printf \"%s; exit\" \"$*\" >.iank/brc2
852 #INPUTRC=.iank/.inputrc bash --rcfile .iank/.bashrc"
855 command ssh -t "${args[@]}" "$remote" "INPUTRC=.iank/.inputrc bash --rcfile .iank/.bashrc"
858 BASH_LOGIN_SHELL
=true
command ssh "$remote" "$@"
862 ssh -oControlMaster=no
-oControlPath=/ "$@"
864 # kill off old shared socket then ssh
867 while [[ $1 == -* ]]; do
871 m pkill
-f "^ssh: /tmp/ssh_mux_${USER}_${1#*@}_22_"
872 m
ssh "${opts[@]}" "$@"
876 BASH_LOGIN_SHELL
=true
command ssh "$@"
882 declare -gi _seq
; _seq
+=1
883 echo "test body" | m
mail -s "test mail from $HOSTNAME, $_seq" "${@:-root@localhost}"
884 # for testing to send from an external address, you can do for example
885 # -fian@iank.bid -aFrom:ian@iank.bid web-6fnbs@mail-tester.com
886 # note in exim, you can retry a deferred message
888 # MSG_ID is in /var/log/exim4/mainlog, looks like 1ccdnD-0001nh-EN
891 # to test sieve, use below command. for fsf mail, see offlineimap-sync script
892 # make modifications, then copy to live file, use -eW to actually modify mailbox
894 # Another option is to use sieve-test SCRIPT MAIL_FILE. note,
895 # sieve-test doesnt know about envelopes, Im not sure if sieve-filter does.
897 # sieve with output filter. arg is mailbox, like INBOX.
898 # This depends on dovecot conf, notably mail_location in /etc/dovecot/conf.d/10-mail.conf
901 sieve-filter
"$@" 2> >(head; tail) >/tmp
/testsieve.log
&& sed -rn '/^Performed actions:/,/^[^ ]/{/^ /p}' /tmp
/testsieve.log |
sort |
uniq -c
904 # always run this first, edit the test files, then run the following
906 _dosieve ~
/sieve
/maintest.sieve
${1:-INBOX} delete
909 c ~
/sieve
; cp personal
{test,}.sieve
; cp lists
{test,}.sieve
; cp personalend
{test,}.sieve
910 _dosieve ~
/sieve
/main.sieve
-eW ${1:-INBOX} delete
915 # testmail above calls sendmail, which is a link to exim/postfix.
916 # its docs dont say a way of adding an argument
917 # to sendmail to turn on debug output. We could make a wrapper, but
918 # that is a pain. Exim debug args are documented here:
919 # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
921 # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-building_and_installing_exim.html
922 # note, for exim daemon, you can turn on debug options by
923 # adding -d, etc to COMMONOPTIONS in
926 # to specify recipients other than those in to, cc, bcc, you can use the cli args, eg:
927 # exim -i 'test@zroe.org, t2@zroe.org' <<'EOF'
931 From: i@dmarctest.b8.nz
932 To: mailman@dev.fsf.org
934 Reply-to: rtest@iankelling.org
936 This is a test message.
943 # https://askubuntu.com/questions/160945/is-there-a-way-to-disable-a-laptops-internal-keyboard
944 id
=$
(xinput
--list --id-only 'AT Translated Set 2 keyboard')
945 if xinput list |
grep -F '∼ AT Translated Set 2 keyboard' &>/dev
/null
; then
946 echo enabling keyboard
947 # find the first slave keyboard number, they are all the same in my output.
948 # if they werent, worst case we would need to save the slave number somewhere
949 # when it got disabled.
950 slave
=$
(xinput list |
sed -n 's/.*slave \+keyboard (\([0-9]*\)).*/\1/p' |
head -n1)
951 xinput reattach
$id $slave
960 (sleep $
(calc
"$* * 60") && mpv
--no-config --volume 50 /a
/bin
/data
/alarm.mp3
) > /dev
/null
2>&1 &
963 trg
() { transmission-remote-gtk
&r
; }
965 # example, set global upload limit to 100 kilobytes:
967 TR_AUTH
=":$(jq -r .profiles[0].password ~/.config/transmission-remote-gtk/config.json)" transmission-remote transmission.lan
-ne "$@"
973 dir
="$(dirname "$1")"
974 if [[ -e $1 && ! -w $1 ||
! -w $
(dirname "$1") ]]; then
977 # full path for using in some initial setup steps
982 #m s nsenter -t $(pgrep -f "/usr/sbin/openvpn .* --config /etc/openvpn/.*pia.conf") -n -m "$@"
983 m s nsenter
-t $
(pgrep
-f "/usr/sbin/openvpn .* --config /etc/openvpn/.*client.conf") -n -m "$@"
986 vpncmd gksudo
-u iank
"firefox -no-remote -P vpn" &r
989 vpncmd gksudo
-u iank
"$*"
997 if [[ -e /lib
/systemd
/system
/openvpn-client@.service
]]; then
998 local vpn_service
=openvpn-client
1000 local vpn_service
=openvpn
1003 [[ $1 ]] ||
{ echo need arg
; return 1; }
1004 journalctl
--unit=$vpn_service@
$1 -f -n0 &
1005 s systemctl start
$vpn_service@
$1
1006 # sometimes the ask-password agent does not work and needs a delay.
1008 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=779240
1009 # noticed around 8-2017 after update from around stretch release
1010 # on debian testing, even though the bug is much older.
1011 s systemd-tty-ask-password-agent
1015 [[ $1 ]] ||
{ echo need arg
; return 1; }
1016 if [[ -e /lib
/systemd
/system
/openvpn-client@.service
]]; then
1017 local vpn_service
=openvpn-client
1019 local vpn_service
=openvpn
1021 s systemctl stop
$vpn_service@
$1
1027 vspicy
() { # usage: VIRSH_DOMAIN
1028 # connect to vms made with virt-install
1029 spicy
-p $
(sudo virsh dumpxml
"$1"|
grep "<graphics.*type='spice'"|\
1030 sed -r "s/.*port='([0-9]+).*/\1/")
1034 cat-new-files
/m
/4e
/INBOX
/new
1037 wtr
() { curl wttr.in
/boston
; }
1039 xevkb
() { xev
-event keyboard
; }
1043 # from curl cheat.sh/:bash_completion
1044 _cheatsh_complete_curl
()
1047 _get_comp_words_by_ref
-n : cur
1050 #cur="${COMP_WORDS[COMP_CWORD]}"
1051 prev
="${COMP_WORDS[COMP_CWORD-1]}"
1052 opts
="$(curl -s cheat.sh/:list | sed s@^@cheat.sh/@)"
1054 if [[ ${cur} == cheat.sh
/* ]] ; then
1055 COMPREPLY
=( $
(compgen
-W "${opts}" -- ${cur}) )
1056 __ltrim_colon_completions
"$cur"
1060 complete
-F _cheatsh_complete_curl curl
1066 # we also have a file in /a/c/...konsole...
1067 local f
=$HOME/.config
/konsolerc
1068 setini DefaultProfile profileian.profile
"Desktop Entry" $f
1069 setini Favorites profileian.profile
"Favorite Profiles" $f
1070 setini ShowMenuBarByDefault false KonsoleWindow
$f
1071 setini TabBarPosition Top TabBar
$f
1075 while -r read k v
; do
1076 # shellcheck disable=SC2154
1077 setini
$k $v sakura
/a
/c
/subdir_files
/.config
/sakura
/sakura.conf
1079 colorset1_back rgb(33,37,39
1083 disable_numbered_tabswitch true
1084 scroll_lines 10000000
1089 reset-xscreensaver
() {
1090 # except for spash, i set these by setting gui options in
1091 # xscreensaver-command -demo
1092 # then finding the corresponding option in .xscreensaver
1093 # spash, i happened to notice in .xscreensaver
1095 # dpmsOff, monitor doesnt come back on using old free software supported nvidia card
1096 cat > /home
/iank
/.xscreensaver
<<'EOF'
1099 dpmsStandby: 0:02:00
1100 dpmsSuspend: 0:03:00
1104 lockTimeout: 0:03:00
1111 # * stuff that makes sense to be at the end
1112 if [[ "$SUDOD" ]]; then
1115 elif [[ -d /a
]] && [[ $PWD == "$HOME" ]] && [[ $
- == *i
* ]]; then
1124 # for mitmproxy to get a newer python.
1125 # commented until i want to use it because it
1126 # noticably slows bash startup
1130 if [[ $EUID == 0 ||
! -e ~
/.pyenv
/bin
]]; then
1131 echo "error: dont be root. make sure pyenv is installed"
1134 export PATH
="$HOME/.pyenv/bin:$PATH"
1135 eval "$(pyenv init -)"
1136 eval "$(pyenv virtualenv-init -)"
1140 export GOPATH
=$HOME/go
1141 path-add
$GOPATH/bin
1142 path-add
/usr
/local
/go
/bin
1144 # I have the git repo and a release. either one should work.
1145 # I have both because I was trying to solve an issue that
1146 # turned out to be unrelated.
1147 # ARDUINO_PATH=/a/opt/Arduino/build/linux/work
1148 export ARDUINO_PATH
=/a
/opt
/arduino-1.8
.9
1150 # They want to be added to the start, but i think
1151 # that should be avoided unless we really need it.
1152 path-add
--end ~
/.npm-global
1154 path-add
--end $HOME/.cargo
/bin
1156 # taken from default changes to bashrc and bash_profile
1157 path-add
--end $HOME/.rvm
/bin
1158 path-add
--end $HOME/.gem
/ruby
/2.3.0/bin
1161 export BASEFILE_DIR
=/a
/bin
/fai-basefiles
1163 #export ANDROID_HOME=/a/opt/android-home
1164 # https://f-droid.org/en/docs/Installing_the_Server_and_Repo_Tools/
1165 #export USE_SDK_WRAPPER=yes
1166 #PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
1168 # didnt get drush working, if I did, this seems like the
1169 # only good thing to include for it.
1170 # Include Drush completion.
1171 # if [ -f "/home/ian/.drush/drush.complete.sh" ] ; then
1172 # source /home/ian/.drush/drush.complete.sh
1176 # https://wiki.archlinux.org/index.php/Xinitrc#Autostart_X_at_login
1177 # i added an extra condition as gentoo xorg guide says depending on
1178 # $DISPLAY is fragile.
1179 if [[ ! $DISPLAY && $XDG_VTNR == 1 ]] && shopt -q login_shell
&& isarch
; then
1184 # ensure no bad programs appending to this file will have an affect