diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/.bashrc | 74 | ||||
-rw-r--r-- | misc/.config/i3/config | 6 | ||||
-rw-r--r-- | misc/.config/i3status/config | 8 | ||||
-rw-r--r-- | misc/.config/mimeapps.list | 11 | ||||
-rw-r--r-- | misc/.config/mpv/input.conf | 3 | ||||
-rw-r--r-- | misc/.config/mpv/mpv.conf | 31 | ||||
-rw-r--r-- | misc/.config/rofi/config.rasi | 2 | ||||
-rw-r--r-- | misc/.gdbinit | 6 | ||||
-rw-r--r-- | misc/.inputrc | 12 | ||||
-rw-r--r-- | misc/.kodi/userdata/playercorefactory.xml | 14 | ||||
-rw-r--r-- | misc/.local/share/applications/emacsclient-web.desktop | 20 | ||||
-rw-r--r-- | misc/.screenrc | 7 | ||||
-rwxr-xr-x | misc/bin/check-ovpn.sh | 12 | ||||
-rwxr-xr-x | misc/bin/display_toggle.sh | 20 | ||||
-rwxr-xr-x | misc/bin/switch-display.sh | 35 | ||||
-rwxr-xr-x | misc/bin/unzipall.sh | 8 | ||||
-rwxr-xr-x | misc/bin/zipall.sh | 9 |
17 files changed, 258 insertions, 20 deletions
diff --git a/misc/.bashrc b/misc/.bashrc index 5f8c3cf..2d44565 100644 --- a/misc/.bashrc +++ b/misc/.bashrc @@ -18,7 +18,9 @@ _checkexec () } # Machine-specific and personal settings -source ~/.bashrc_local +if [[ -f ~/.bashrc_local ]]; then + source ~/.bashrc_local +fi ## prompts # git prompt @@ -26,6 +28,8 @@ if [[ -f /usr/share/git/completion/git-prompt.sh ]]; then source /usr/share/git/completion/git-prompt.sh elif [[ -f /etc/bash_completion.d/git-prompt ]]; then source /etc/bash_completion.d/git-prompt +elif [[ -f /usr/share/git-core/contrib/completion/git-prompt.sh ]]; then + source /usr/share/git-core/contrib/completion/git-prompt.sh fi # prompt @@ -63,7 +67,9 @@ then fi # from ~/.bashrc_local, adding more to PATH -my_local_add_path +if [[ $(type -t my_local_add_path) == function ]]; then + my_local_add_path +fi export PATH @@ -109,7 +115,7 @@ export HISTCONTROL=ignoreboth # aliases test -s ~/.alias && . ~/.alias || true alias shutdown='sudo /sbin/shutdown -hP now' -alias reboot='sudo /sbin/reboot' +alias reboot='sudo reboot' alias wifi-menu='sudo /usr/bin/wifi-menu' alias cd-='cd -' alias cd#='cd ~' @@ -125,6 +131,8 @@ alias updatedb='sudo updatedb' alias wgets="wget -O- 2>/dev/null" # get url behind one redirection alias wgre="wget --spider --max-redirect=0" +# wget with spoofing googlebot +alias wggb='wget --header="X-Forwarded-For: 66.249.66.1" --user-agent="Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"' # this allows to open an url with tor-browser from within emacs, see # `my-browse-url-tor-browser' alias tor-browser="tor-browser --allow-remote" @@ -177,6 +185,7 @@ then alias pQi="pacman -Qi" # local package details alias pQl="pacman -Ql" # local package file lists alias pQo="pacman -Qo" # which package owns this file + alias pQc="pacman -Qc" # show changelog # Remove packages alias pRs="sudo pacman -Rs" # remove package @@ -187,10 +196,28 @@ then # Clear cache alias pcache1="sudo paccache -rk 1" # remove cache except last item alias pcache0="sudo paccache -ruk0" # remove all cache + + # make an aur package + paur () { + pkg_name="${1%.tar.gz}" + tar xvf "$pkg_name.tar.gz" + cd "$pkg_name" + makepkg + } fi +alias systart="sudo systemctl start" +alias systop="sudo systemctl stop" +alias sysnow="sudo systemctl enable --now" +alias sysdis="sudo systemctl disable" +alias systat="systemctl status" +alias sysres="sudo systemctl restart" +alias sysrelo="sudo systemctl reload" + # from ~/.bashrc_local, more aliases -my_local_aliases +if [[ $(type -t my_local_aliases) == function ]]; then + my_local_aliases +fi #ibus export GTK_IM_MODULE=ibus @@ -200,6 +227,26 @@ export QT_IM_MODULE=ibus #fix small vlc interface export QT_AUTO_SCREEN_SCALE_FACTOR=0 +# ensure $XDG_RUNTIME_DIR is set +if [ -z "$XDG_RUNTIME_DIR" ]; then # It's not already set + XDG_RUNTIME_DIR=/run/user/$UID # Try systemd created path + if [ ! -d "$XDG_RUNTIME_DIR" ]; then + # systemd-created directory doesn't exist + XDG_RUNTIME_DIR=/tmp/$USER-runtime + if [ ! -d "$XDG_RUNTIME_DIR" ]; then # Doesn't already exist + mkdir -m 0700 "$XDG_RUNTIME_DIR" + fi + fi +fi +# Check dir has got the correct type, ownership, and permissions +if ! [[ -d "$XDG_RUNTIME_DIR" && -O "$XDG_RUNTIME_DIR" && + "$(stat -c '%a' "$XDG_RUNTIME_DIR")" = 700 ]]; then + echo "\$XDG_RUNTIME_DIR: permissions problem with $XDG_RUNTIME_DIR:" >&2 + ls -ld "$XDG_RUNTIME_DIR" >&2 + XDG_RUNTIME_DIR=$(mktemp -d /tmp/"$USER"-runtime-XXXXXX) + echo "Set \$XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR" >&2 +fi + # start the agent automatically and make sure that only one # ssh-agent process runs at a time if ! pgrep -u "$USER" ssh-agent > /dev/null; then @@ -220,4 +267,21 @@ export CCACHE_EXEC=/usr/bin/ccache export CVS_RSH="ssh" # from ~/.bashrc_local, export more stuff -my_local_export +if [[ $(type -t my_local_export) == function ]]; then + my_local_export +fi + +# ghostscript, extract pages into a new file +# gs-extract 4 11 page-4-thru-11.pdf original.pdf +gs-extract() { + gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=$1 -dLastPage=$2 \ + -sOutputFile="$3" "$4" +} + +# ghostscript, merge files: gs-merge merged.pdf 1.pdf 2.pdf +gs-merge() { + gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="$@" +} + +# dptrp1 +alias quaderno="dptrp1 --addr $QUADERNO_IP" diff --git a/misc/.config/i3/config b/misc/.config/i3/config index 1fd7942..803dcd1 100644 --- a/misc/.config/i3/config +++ b/misc/.config/i3/config @@ -13,7 +13,7 @@ set $mod Mod4 # Font for window titles. Will also be used by the bar unless a different font # is used in the bar {} block below. -font pango:monospace 8 +font pango:Ubuntu Mono Bold 9 # This font is widely installed, provides lots of unicode glyphs, right-to-left # text rendering and scalability on retina/hidpi displays (thanks to pango). @@ -175,6 +175,9 @@ bindsym $mod+Up exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% bindsym $mod+Down exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% # Sreen brightness controls +# may need to add rule for users in video group to do without sudo: +# /etc/udev/rules.d/backlight.rules: +# ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chgrp video $sys$devpath/brightness", RUN+="/bin/chmod g+w $sys$devpath/brightness" bindsym XF86MonBrightnessUp exec xbacklight -inc 20 # increase screen brightness bindsym XF86MonBrightnessDown exec xbacklight -dec 20 # decrease screen brightness @@ -208,3 +211,4 @@ bindsym $mod+minus exec dunstctl close exec ibus-daemon exec redshift-gtk exec --no-startup-id i3-msg 'workspace $ws1; exec urxvt' +exec xscreensaver -no-splash & diff --git a/misc/.config/i3status/config b/misc/.config/i3status/config index a276e19..4b7725a 100644 --- a/misc/.config/i3status/config +++ b/misc/.config/i3status/config @@ -13,6 +13,7 @@ general { order += "read_file emms" order += "wireless _first_" +order += "read_file VPN" order += "battery all" order += "disk /" order += "disk /home" @@ -38,6 +39,13 @@ ethernet _first_ { format_down = "E: down" } +# in collaboration with check-ovpn.sh +read_file VPN { + format = "VPN: %content" + format_bad = "VPN: NO" + path = "~/.local/ovpn-up" +} + battery all { format = "%status %percentage %remaining" } diff --git a/misc/.config/mimeapps.list b/misc/.config/mimeapps.list index 7648543..413a9f5 100644 --- a/misc/.config/mimeapps.list +++ b/misc/.config/mimeapps.list @@ -20,10 +20,10 @@ application/x-extension-xhtml=firefox.desktop application/xhtml+xml=firefox.desktop application/xml=emacsclient.desktop application/zip=emacsclient.desktop -image/png=geeqie.desktop -image/jpeg=geeqie.desktop +image/png=org.geeqie.Geeqie.desktop +image/jpeg=org.geeqie.Geeqie.desktop inode/directory=emacsclient.desktop -image/webp=geeqie.desktop +image/webp=org.geeqie.Geeqie.desktop message/rfc822=emacsclient-mail.desktop text/csv=libreoffice-calc.desktop text/html=firefox.desktop @@ -36,8 +36,8 @@ video/quicktime=vlc.desktop video/x-msvideo=mpv.desktop x-scheme-handler/chrome=firefox.desktop x-scheme-handler/ftp=filezilla.desktop -x-scheme-handler/http=firefox.desktop -x-scheme-handler/https=firefox.desktop +x-scheme-handler/http=emacsclient-web.desktop +x-scheme-handler/https=emacsclient-web.desktop x-scheme-handler/mailto=emacsclient-mail.desktop x-scheme-handler/sgnl=signal-desktop.desktop x-scheme-handler/org-protocol=emacsclient-org-protocol.desktop @@ -45,3 +45,4 @@ x-scheme-handler/org-protocol=emacsclient-org-protocol.desktop [Added Associations] application/pdf=org.pwmt.zathura-pdf-poppler.desktop;firefox.desktop text/csv=emacsclient.desktop +image/heif=org.geeqie.Geeqie.desktop; diff --git a/misc/.config/mpv/input.conf b/misc/.config/mpv/input.conf new file mode 100644 index 0000000..0238138 --- /dev/null +++ b/misc/.config/mpv/input.conf @@ -0,0 +1,3 @@ +PREV seek -15 +NEXT stop +a vf toggle hflip diff --git a/misc/.config/mpv/mpv.conf b/misc/.config/mpv/mpv.conf new file mode 100644 index 0000000..3b49398 --- /dev/null +++ b/misc/.config/mpv/mpv.conf @@ -0,0 +1,31 @@ +save-position-on-quit +# Uncomment this line to load the profile by default +# Otherwise, use `--profile=emacsconf-talks` +# profile=emacsconf-talks + +script-opts=ytdl_hook-ytdl_path=/usr/bin/yt-dlp +ytdl-format="bestvideo[height<=?720]+bestaudio/best" +osc=no +stop-screensaver = "yes" + +[emacsconf-talks] +# Positioning +video-zoom=-0.15 +video-pan-y=-0.055 +sub-use-margins=yes +sub-scale-by-window=yes +sub-pos=103 +sub-margin-x=150 +sub-margin-y=40 +# Style +sub-font="Clear Sans Bold" +sub-color="1/0.82/0" +sub-blur=0.2 +sub-scale=0.9 +sub-font-size=40 +sub-border-size=0 +sub-border-color=0/1 +sub-shadow-color=0/1 +sub-shadow-offset=1.2 +sub-ass-force-style=Kerning=yes +sub-ass-line-spacing=0 diff --git a/misc/.config/rofi/config.rasi b/misc/.config/rofi/config.rasi index aab83de..041b095 100644 --- a/misc/.config/rofi/config.rasi +++ b/misc/.config/rofi/config.rasi @@ -33,7 +33,7 @@ configuration { /* parse-hosts: false;*/ /* parse-known-hosts: true;*/ combi-modes: "run,drun"; - matching: "glob"; + matching: "prefix"; /* tokenize: true;*/ /* m: "-5";*/ /* filter: ;*/ diff --git a/misc/.gdbinit b/misc/.gdbinit index b2c8a1f..b06bc7f 100644 --- a/misc/.gdbinit +++ b/misc/.gdbinit @@ -1,3 +1,5 @@ +set debuginfod enabled on +set max-completions 20 set print static-members off set print frame-arguments all # unlimited print string length @@ -19,6 +21,10 @@ alias wl = watch -l alias awl = awatch -l alias rwl = rwatch -l alias rt = restart +define bc + b $arg0 + c +end # Print backtrace of all threads alias abt = thread apply all bt set history save on diff --git a/misc/.inputrc b/misc/.inputrc new file mode 100644 index 0000000..9ef6cbc --- /dev/null +++ b/misc/.inputrc @@ -0,0 +1,12 @@ +# Reduce tab completion key presses and show suggestions +set show-all-if-ambiguous on +# Color files by types +set colored-stats On +# Append char to indicate type +set visible-stats On +# Mark symlinked directories +set mark-symlinked-directories On +# Color the common prefix +set colored-completion-prefix On +# Color the common prefix in menu-complete +set menu-complete-display-prefix On diff --git a/misc/.kodi/userdata/playercorefactory.xml b/misc/.kodi/userdata/playercorefactory.xml new file mode 100644 index 0000000..ef9d7e4 --- /dev/null +++ b/misc/.kodi/userdata/playercorefactory.xml @@ -0,0 +1,14 @@ +<playercorefactory> + <players> + <player name="VLC" type="ExternalPlayer" audio="false" video="true"> + <filename>/usr/bin/vlc</filename> + <args>"{1}" -f --video-on-top</args> + <hidexbmc>true</hidexbmc> + <warpcursor>none</warpcursor> + </player> + </players> + + <rules action="prepend"> + <rule name="Playtype" filetype="mkv|mp4|avi|webm|ogv" player="VLC"/> + </rules> +</playercorefactory> diff --git a/misc/.local/share/applications/emacsclient-web.desktop b/misc/.local/share/applications/emacsclient-web.desktop new file mode 100644 index 0000000..5beb0f3 --- /dev/null +++ b/misc/.local/share/applications/emacsclient-web.desktop @@ -0,0 +1,20 @@ +[Desktop Entry] +Categories=Network;Web; +Comment=GNU Emacs is an extensible, customizable text editor - and more +Exec=/usr/bin/emacsclient -n %u +Icon=emacs +Name=Emacs (Web Browser, Client) +MimeType=x-scheme-handler/http;x-scheme-handler/https; +NoDisplay=true +Terminal=false +Type=Application +Keywords=emacsclient; +Actions=new-window;new-instance; + +[Desktop Action new-window] +Name=New Window +Exec=/usr/bin/emacsclient --create-frame -n %u + +[Desktop Action new-instance] +Name=New Instance +Exec=emacs -f browse-url %u diff --git a/misc/.screenrc b/misc/.screenrc new file mode 100644 index 0000000..934d3af --- /dev/null +++ b/misc/.screenrc @@ -0,0 +1,7 @@ +autodetach on +startup_message off +hardstatus alwayslastline +shelltitle 'bash' + +hardstatus string '%{gk}[%{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= w}%?%+Lw%?%? %{g}][%{d}%l%{g}][ %{= w}%Y/%m/%d %0C:%s%a%{g} ]%{W}' +escape ^\\\ diff --git a/misc/bin/check-ovpn.sh b/misc/bin/check-ovpn.sh new file mode 100755 index 0000000..9669190 --- /dev/null +++ b/misc/bin/check-ovpn.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Check that the vpn is up. Check every 5 seconds for 11 times - for +# use as a minutely cron task +for i in $(seq 1 11); do + if ifconfig | grep -q "00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00"; then + echo YES > ~/.local/ovpn-up + else + rm -f ~/.local/ovpn-up + fi + sleep 5 +done diff --git a/misc/bin/display_toggle.sh b/misc/bin/display_toggle.sh index b2c7e5c..e7dfcf5 100755 --- a/misc/bin/display_toggle.sh +++ b/misc/bin/display_toggle.sh @@ -1,11 +1,14 @@ #!/bin/bash -# Assuming there are two displays. A small one (e.g. laptop) and a big -# one (e.g. monitor). Identify the displays, and toggle between 3 -# states: small one only -> both with the big one to the left of the -# small one -> big one only -# small one: <20 inch -# big one: >20 inch +# toggle display arrangements. + +# If there is only one monitor, then run xrandr --auto + +# Otherwise assume there are two displays. A small one (e.g. laptop) +# and a big one (e.g. monitor). Identify the displays, and toggle +# between 3 states: small one only -> both with the big one to the +# left of the small one -> big one only small one: <20 inch big one: +# >20 inch # Make sure the variables from pipe can be assigned # https://stackoverflow.com/questions/42963395/bash-assign-variable-from-pipe @@ -21,9 +24,10 @@ xrandr | grep " connected " | while IFS=$'\n' read -r line; do fi done +# Only one monitor: run xrandr --auto if (( i == 1 )); then - echo "Only one connected display" - exit 1 + xrandr --auto + exit 0 fi regex="^.*/([0-9]+)x.*/([0-9]+).* ([^ ]+)$" diff --git a/misc/bin/switch-display.sh b/misc/bin/switch-display.sh new file mode 100755 index 0000000..4c3cba6 --- /dev/null +++ b/misc/bin/switch-display.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +logger "$1" "$2" "$3" +# Switch to the biggest display available. for use as an acpid hook + +# Make sure the variables from pipe can be assigned +# https://stackoverflow.com/questions/42963395/bash-assign-variable-from-pipe +shopt -s lastpipe + +# enable all monitors so that they show up in xrandr +# --listactivemonitors output. somehow this output is identical to +# that of xrandr --listmonitors +xrandr --auto + +# find the widest monitor +regex="^.*/([0-9]+)x.*/([0-9]+).* ([^ ]+)$" +widest=0 +widest_name="" +xrandr --listactivemonitors | while IFS=$'\n' read -r line; do + if [[ $line =~ $regex ]]; then + if (( "${BASH_REMATCH[1]}" > "$widest" )); then + widest="${BASH_REMATCH[1]}" + widest_name="${BASH_REMATCH[3]}" + fi + fi +done + +# turn off all other monitors +xrandr --listactivemonitors | while IFS=$'\n' read -r line; do + if [[ $line =~ $regex ]]; then + if [[ "${BASH_REMATCH[3]}" != "$widest_name" ]]; then + xrandr --output "${BASH_REMATCH[3]}" --off + fi + fi +done diff --git a/misc/bin/unzipall.sh b/misc/bin/unzipall.sh new file mode 100755 index 0000000..2d654f0 --- /dev/null +++ b/misc/bin/unzipall.sh @@ -0,0 +1,8 @@ +#/bin/bash + +# unzip all zip/7z files with 7z in pwd +for f in ./*; do + ext=${f##*.} + if test "$ext" = zip; then 7z e "$f"; fi; + if test "$ext" = 7z; then 7z e "$f"; fi; +done diff --git a/misc/bin/zipall.sh b/misc/bin/zipall.sh new file mode 100755 index 0000000..0a244c2 --- /dev/null +++ b/misc/bin/zipall.sh @@ -0,0 +1,9 @@ +#/bin/bash + +# zip all non-7z and non-zip files with 7z in pwd and delete the original +for f in ./*; do + ext=${f##*.} + if test "$ext" = zip; then continue; fi; + if test "$ext" = 7z; then continue; fi; + 7z a -sdel "$f.7z" "$f" +done |