From bacc4127b7da22c61671fe3ce0cef6db103884dd Mon Sep 17 00:00:00 2001 From: katherine Date: Sat, 1 Oct 2016 13:58:31 -0700 Subject: overhaul init system gen files now kept in gen directory. funcs now included in $PATH only if their funcreqs are successfully passed at login, making things cleaner and more system-independent --- .config/init/funcreqs/mpd-cover-convert | 2 + .config/init/funcreqs/mpd-sleep | 2 + .config/init/funcreqs/scap | 2 + .config/init/funcreqs/send | 2 + .config/init/funcs/mpd-cover-convert | 2 +- .config/init/funcs/mpd-sleep | 12 ++--- .config/init/funcs/scap | 26 +++++----- .config/init/funcs/send | 53 ++++++++++---------- .config/init/gen-bg-saved.sh | 5 -- .config/init/gen-urxvt-theme.sh | 52 -------------------- .config/init/gen-userChrome.sh | 87 --------------------------------- .config/init/gen-zathurarc.sh | 29 ----------- .config/init/gen/bg-saved.sh | 5 ++ .config/init/gen/urxvt-theme.sh | 52 ++++++++++++++++++++ .config/init/gen/userChrome.sh | 87 +++++++++++++++++++++++++++++++++ .config/init/gen/zathurarc.sh | 29 +++++++++++ .config/init/init.sh | 12 ++--- .zprofile | 33 ++++++++++++- 18 files changed, 265 insertions(+), 227 deletions(-) create mode 100644 .config/init/funcreqs/mpd-cover-convert create mode 100644 .config/init/funcreqs/mpd-sleep create mode 100644 .config/init/funcreqs/scap create mode 100644 .config/init/funcreqs/send delete mode 100644 .config/init/gen-bg-saved.sh delete mode 100644 .config/init/gen-urxvt-theme.sh delete mode 100644 .config/init/gen-userChrome.sh delete mode 100644 .config/init/gen-zathurarc.sh create mode 100644 .config/init/gen/bg-saved.sh create mode 100644 .config/init/gen/urxvt-theme.sh create mode 100644 .config/init/gen/userChrome.sh create mode 100644 .config/init/gen/zathurarc.sh diff --git a/.config/init/funcreqs/mpd-cover-convert b/.config/init/funcreqs/mpd-cover-convert new file mode 100644 index 0000000..31bbd05 --- /dev/null +++ b/.config/init/funcreqs/mpd-cover-convert @@ -0,0 +1,2 @@ +func_init_prereqs=(mpc) +func_init_checks=("stat $HOME/music") diff --git a/.config/init/funcreqs/mpd-sleep b/.config/init/funcreqs/mpd-sleep new file mode 100644 index 0000000..66ce754 --- /dev/null +++ b/.config/init/funcreqs/mpd-sleep @@ -0,0 +1,2 @@ +func_init_prereqs=(mpc poweroff) +func_init_checks=() diff --git a/.config/init/funcreqs/scap b/.config/init/funcreqs/scap new file mode 100644 index 0000000..1a58abc --- /dev/null +++ b/.config/init/funcreqs/scap @@ -0,0 +1,2 @@ +func_init_prereqs=(ffmpeg archey3) +func_init_checks=() diff --git a/.config/init/funcreqs/send b/.config/init/funcreqs/send new file mode 100644 index 0000000..85dd46c --- /dev/null +++ b/.config/init/funcreqs/send @@ -0,0 +1,2 @@ +func_init_prereqs=(scrot xclip scp ssh) +func_init_checks=() diff --git a/.config/init/funcs/mpd-cover-convert b/.config/init/funcs/mpd-cover-convert index cd3569a..e8359b7 100755 --- a/.config/init/funcs/mpd-cover-convert +++ b/.config/init/funcs/mpd-cover-convert @@ -1,4 +1,4 @@ -#!/bin/zsh +#!/usr/bin/env zsh # make small cover versions for mpc-notify.sh # leaks memory for some reason, so don't run on a clean library # or it'll crash everything diff --git a/.config/init/funcs/mpd-sleep b/.config/init/funcs/mpd-sleep index c01d734..d821572 100755 --- a/.config/init/funcs/mpd-sleep +++ b/.config/init/funcs/mpd-sleep @@ -1,10 +1,10 @@ -#!/bin/zsh +#!/usr/bin/env zsh +# power off after mpd stops playing -# power off after finishing mpd playlist mpc play > /dev/null while true; do - mpc idle player > /dev/null || return 1 - if [[ -z "$(mpc status | grep playing)" ]]; then - poweroff - fi + mpc idle player > /dev/null || return 1 + if [[ -z "$(mpc status | grep playing)" ]]; then + poweroff + fi done diff --git a/.config/init/funcs/scap b/.config/init/funcs/scap index 489f7b8..bf9c66d 100755 --- a/.config/init/funcs/scap +++ b/.config/init/funcs/scap @@ -1,18 +1,18 @@ -#!/bin/zsh - +#!/usr/bin/env zsh # capture webm -scap() { - archey3 - sleep .2 - if [[ -f '/tmp/cap.mp4' ]]; then - rm '/tmp/cap.mp4' - fi +xset q +[[ $? -ne 0 ]] && return 1 + +archey3 +sleep .2 - echo 'recording...' +if [[ -f '/tmp/cap.mp4' ]]; then + rm '/tmp/cap.mp4' +fi - ffmpeg -v panic -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 \ - -f pulse -ac 2 -i default -af aresample=async=1 \ - -c:v libx264 -q 0 -preset fast '/tmp/cap.mp4' -} +echo 'recording...' +ffmpeg -v panic -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 \ + -f pulse -ac 2 -i default -af aresample=async=1 \ + -c:v libx264 -q 0 -preset ultrafast '/tmp/cap.mp4' diff --git a/.config/init/funcs/send b/.config/init/funcs/send index e88c8aa..009c601 100755 --- a/.config/init/funcs/send +++ b/.config/init/funcs/send @@ -1,46 +1,47 @@ -#!/bin/zsh +#!/usr/bin/env zsh # quickly send a file to hosted /tmp/ dir +# attempt to copy its location to the x clipboard local name local basename local escapes typeset -A escapes escapes=(' ' '%20' '"' '%22' '#' '%23' '$' '%24' - '%' '%25' '&' '%26' "'" '%27' '+' '%2b' - ',' '%2c' '/' '%2f' ':' '%3a' ';' '%3b' - '<' '%3c' '=' '%3d' '>' '%3e' '?' '%3f' - '@' '%40' '[' '%5b' '\' '%5c' ']' '%5d' - '^' '%5e' '`' '%60' '{' '%7b' '|' '%7c' - '}' '%7d' '~' '%7e') + '%' '%25' '&' '%26' "'" '%27' '+' '%2b' + ',' '%2c' '/' '%2f' ':' '%3a' ';' '%3b' + '<' '%3c' '=' '%3d' '>' '%3e' '?' '%3f' + '@' '%40' '[' '%5b' '\' '%5c' ']' '%5d' + '^' '%5e' '`' '%60' '{' '%7b' '|' '%7c' + '}' '%7d' '~' '%7e') [[ "$1" ]] \ - || { echo "please specify at least one file to send"; return 1 } + || { echo "please specify at least one file to send"; return 1 } for i in "$@"; do - [[ -f "$i" ]] \ - || { echo "file '$i' not found"; return 1 } + [[ -f "$i" ]] \ + || { echo "file '$i' not found"; return 1 } done scp "$@" shmibbles.me:http/tmp/ 2>/dev/null \ - || { echo "sending files failed"; return 1 } + || { echo "sending files failed"; return 1 } for name in "$@" do - basename=${name:t} + basename=${name:t} - ssh shmibbles.me "cd http/tmp; chmod o+r \"${basename//\"/\\\"}\"" \ - || { echo "making '$name' readable failed"; return 1 } + ssh shmibbles.me "cd http/tmp; chmod o+r \"${basename//\"/\\\"}\"" \ + || { echo "making '$name' readable failed"; return 1 } - { - printf "%s" 'https://shmibbles.me/tmp/' - for c in "${(s::)basename}"; do - if [[ "${escapes[$c]}" == "" ]]; then - printf "%s" "$c" - else - printf "%s" "${escapes[$c]}" - fi - done - } | tee \ - >(xclip -i -selection clipboard) \ - >(xclip -i -selection primary) >/dev/null + { + printf "%s" 'https://shmibbles.me/tmp/' + for c in "${(s::)basename}"; do + if [[ "${escapes[$c]}" == "" ]]; then + printf "%s" "$c" + else + printf "%s" "${escapes[$c]}" + fi + done + } | tee \ + >(xclip -i -selection clipboard) \ + >(xclip -i -selection primary) >/dev/null done diff --git a/.config/init/gen-bg-saved.sh b/.config/init/gen-bg-saved.sh deleted file mode 100644 index bf2d7cc..0000000 --- a/.config/init/gen-bg-saved.sh +++ /dev/null @@ -1,5 +0,0 @@ -echo "\ -[:0.0] -file=$HOME/backdrops/shadowed/$wallpaper -mode=4 -bgcolor=#000000" > /tmp/bg-saved.cfg diff --git a/.config/init/gen-urxvt-theme.sh b/.config/init/gen-urxvt-theme.sh deleted file mode 100644 index 40e986b..0000000 --- a/.config/init/gen-urxvt-theme.sh +++ /dev/null @@ -1,52 +0,0 @@ -{ -echo "\ -! Use the specified colour as the windows background colour [default White]; option -bg. -URxvt*background: $bg_normal - -! Use the specified colour as the windows foreground colour [default Black]; option -fg. -URxvt*foreground: $fg_normal - -! black -URxvt*color0: $std_black -! light black -URxvt*color8: $light_black -! red -URxvt*color1: $std_red -! light red -URxvt*color9: $light_red -! green -URxvt*color2: $std_green -! light green -URxvt*color10: $light_green -! yellow -URxvt*color3: $std_yellow -! light yellow -URxvt*color11: $light_yellow -! blue -URxvt*color4: $std_blue -! light blue -URxvt*color12: $light_blue -! magenta -URxvt*color5: $std_magenta -! light magenta -URxvt*color13: $light_magenta -! cyan -URxvt*color6: $std_cyan -! light cyan -URxvt*color14: $light_cyan -! white -URxvt*color7: $std_white -! light white -URxvt*color15: $light_white -" - -# Select the fonts to be used. This is a comma separated list of font names that are checked in order when trying to find glyphs for characters. The first font -echo -n "URxvt*font: " -echo -n "xft:${mfont}:size=${mfont_size}, " -echo -n "xft:${jfont}:size=${jfont_size}, " -echo "xft:${bkfont}:size=${bkfont_size}" - -} > /tmp/urxvt-theme - -xrdb -merge /tmp/urxvt-theme - diff --git a/.config/init/gen-userChrome.sh b/.config/init/gen-userChrome.sh deleted file mode 100644 index 44fb6a9..0000000 --- a/.config/init/gen-userChrome.sh +++ /dev/null @@ -1,87 +0,0 @@ -echo "\ -@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); - -@-moz-document url-prefix(about:blank) {*{background-color:${bg_normal};}} - -#TabsToolbar:not(:-moz-lwtheme)::after {display: none;} -/* Remove the following line if you want the text color of unselected tabs to be black (Firefox default) */ -#TabsToolbar .tabbrowser-tab:not([selected]) {color: rgba(255,255,255,0.9);} - -#TabsToolbar { - background: rgb(50,50,50) !important; - margin-bottom: 0 !important; -} - -#TabsToolbar .tabbrowser-tabs { - min-height: ${bheight}px !important; - margin-top: 0px !important; - margin-bottom: 0px !important; - margin-left: -15px !important; - margin-right: -15px !important; -} - -#tabbrowser-tabs tab .tab-close-button { - display: none !important; -} - -.tabbrowser-tab:not([pinned]) .tab-icon-image { - display: none !important; -} - - -#TabsToolbar .tabbrowser-tab { - -moz-border-top-colors: none !important; - -moz-border-left-colors: none !important; - -moz-border-right-colors: none !important; - -moz-border-bottom-colors: none !important; - padding-top: 1px !important; - padding-right: 0 !important; - border-radius: 0px !important; - background: ${bg_normal} !important; - background-clip: padding-box !important; - margin-left: 0px !important; - color: ${fg_normal} !important; - font-family: '${bfont}' !important; - min-height: ${bheight}px !important; -} - -#TabsToolbar .tabs-newtab-button { - display: none !important; -} - -#TabsToolbar .tabbrowser-tab[selected] { - color: ${fg_focus} !important; - background: ${bg_focus} !important; - background-clip: padding-box !important; -} - -#TabsToolbar .tab-background { - margin: 0 !important; - background: transparent !important; -} - -#TabsToolbar .tab-background-start, -#TabsToolbar .tab-background-end { - display: none !important; -} - -#TabsToolbar .tab-background-middle { - margin: -4px -2px !important; - background: transparent !important; -} - -#TabsToolbar .tabbrowser-tab:after, -#TabsToolbar .tabbrowser-tab:before { - display: none !important; -} - -#TabsToolbar .tabs-newtab-button { - display: none !important; -} - -.scrollbutton-up, .scrollbutton-down, #alltabs-button { - display: none !important; -} - -" > /tmp/userChrome.css - diff --git a/.config/init/gen-zathurarc.sh b/.config/init/gen-zathurarc.sh deleted file mode 100644 index 387b1e3..0000000 --- a/.config/init/gen-zathurarc.sh +++ /dev/null @@ -1,29 +0,0 @@ -{ - -echo "\ -set font \"$mfont $mfont_size\" - -set highlight-color \"$bg_normal\" -set highlight-active-color \"$bg_focus\" - -set scroll-page-aware true -set window-title-basename true -set selection-clipboard clipboard -set selection-notification false -set statusbar-home-tilde true -" - -normal=(completion default index inputbar statusbar notification-warning) -focus=(completion-highlight index-active notification-error) - -for i in ${normal[@]}; do - echo "set $i-fg \"$fg_normal\"" - echo "set $i-bg \"$bg_normal\"" -done - -for i in ${focus[@]}; do - echo "set $i-fg \"$fg_focus\"" - echo "set $i-bg \"$bg_focus\"" -done - -} > /tmp/zathurarc diff --git a/.config/init/gen/bg-saved.sh b/.config/init/gen/bg-saved.sh new file mode 100644 index 0000000..bf2d7cc --- /dev/null +++ b/.config/init/gen/bg-saved.sh @@ -0,0 +1,5 @@ +echo "\ +[:0.0] +file=$HOME/backdrops/shadowed/$wallpaper +mode=4 +bgcolor=#000000" > /tmp/bg-saved.cfg diff --git a/.config/init/gen/urxvt-theme.sh b/.config/init/gen/urxvt-theme.sh new file mode 100644 index 0000000..40e986b --- /dev/null +++ b/.config/init/gen/urxvt-theme.sh @@ -0,0 +1,52 @@ +{ +echo "\ +! Use the specified colour as the windows background colour [default White]; option -bg. +URxvt*background: $bg_normal + +! Use the specified colour as the windows foreground colour [default Black]; option -fg. +URxvt*foreground: $fg_normal + +! black +URxvt*color0: $std_black +! light black +URxvt*color8: $light_black +! red +URxvt*color1: $std_red +! light red +URxvt*color9: $light_red +! green +URxvt*color2: $std_green +! light green +URxvt*color10: $light_green +! yellow +URxvt*color3: $std_yellow +! light yellow +URxvt*color11: $light_yellow +! blue +URxvt*color4: $std_blue +! light blue +URxvt*color12: $light_blue +! magenta +URxvt*color5: $std_magenta +! light magenta +URxvt*color13: $light_magenta +! cyan +URxvt*color6: $std_cyan +! light cyan +URxvt*color14: $light_cyan +! white +URxvt*color7: $std_white +! light white +URxvt*color15: $light_white +" + +# Select the fonts to be used. This is a comma separated list of font names that are checked in order when trying to find glyphs for characters. The first font +echo -n "URxvt*font: " +echo -n "xft:${mfont}:size=${mfont_size}, " +echo -n "xft:${jfont}:size=${jfont_size}, " +echo "xft:${bkfont}:size=${bkfont_size}" + +} > /tmp/urxvt-theme + +xrdb -merge /tmp/urxvt-theme + diff --git a/.config/init/gen/userChrome.sh b/.config/init/gen/userChrome.sh new file mode 100644 index 0000000..44fb6a9 --- /dev/null +++ b/.config/init/gen/userChrome.sh @@ -0,0 +1,87 @@ +echo "\ +@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); + +@-moz-document url-prefix(about:blank) {*{background-color:${bg_normal};}} + +#TabsToolbar:not(:-moz-lwtheme)::after {display: none;} +/* Remove the following line if you want the text color of unselected tabs to be black (Firefox default) */ +#TabsToolbar .tabbrowser-tab:not([selected]) {color: rgba(255,255,255,0.9);} + +#TabsToolbar { + background: rgb(50,50,50) !important; + margin-bottom: 0 !important; +} + +#TabsToolbar .tabbrowser-tabs { + min-height: ${bheight}px !important; + margin-top: 0px !important; + margin-bottom: 0px !important; + margin-left: -15px !important; + margin-right: -15px !important; +} + +#tabbrowser-tabs tab .tab-close-button { + display: none !important; +} + +.tabbrowser-tab:not([pinned]) .tab-icon-image { + display: none !important; +} + + +#TabsToolbar .tabbrowser-tab { + -moz-border-top-colors: none !important; + -moz-border-left-colors: none !important; + -moz-border-right-colors: none !important; + -moz-border-bottom-colors: none !important; + padding-top: 1px !important; + padding-right: 0 !important; + border-radius: 0px !important; + background: ${bg_normal} !important; + background-clip: padding-box !important; + margin-left: 0px !important; + color: ${fg_normal} !important; + font-family: '${bfont}' !important; + min-height: ${bheight}px !important; +} + +#TabsToolbar .tabs-newtab-button { + display: none !important; +} + +#TabsToolbar .tabbrowser-tab[selected] { + color: ${fg_focus} !important; + background: ${bg_focus} !important; + background-clip: padding-box !important; +} + +#TabsToolbar .tab-background { + margin: 0 !important; + background: transparent !important; +} + +#TabsToolbar .tab-background-start, +#TabsToolbar .tab-background-end { + display: none !important; +} + +#TabsToolbar .tab-background-middle { + margin: -4px -2px !important; + background: transparent !important; +} + +#TabsToolbar .tabbrowser-tab:after, +#TabsToolbar .tabbrowser-tab:before { + display: none !important; +} + +#TabsToolbar .tabs-newtab-button { + display: none !important; +} + +.scrollbutton-up, .scrollbutton-down, #alltabs-button { + display: none !important; +} + +" > /tmp/userChrome.css + diff --git a/.config/init/gen/zathurarc.sh b/.config/init/gen/zathurarc.sh new file mode 100644 index 0000000..387b1e3 --- /dev/null +++ b/.config/init/gen/zathurarc.sh @@ -0,0 +1,29 @@ +{ + +echo "\ +set font \"$mfont $mfont_size\" + +set highlight-color \"$bg_normal\" +set highlight-active-color \"$bg_focus\" + +set scroll-page-aware true +set window-title-basename true +set selection-clipboard clipboard +set selection-notification false +set statusbar-home-tilde true +" + +normal=(completion default index inputbar statusbar notification-warning) +focus=(completion-highlight index-active notification-error) + +for i in ${normal[@]}; do + echo "set $i-fg \"$fg_normal\"" + echo "set $i-bg \"$bg_normal\"" +done + +for i in ${focus[@]}; do + echo "set $i-fg \"$fg_focus\"" + echo "set $i-bg \"$bg_focus\"" +done + +} > /tmp/zathurarc diff --git a/.config/init/init.sh b/.config/init/init.sh index 9b45f62..6a21763 100755 --- a/.config/init/init.sh +++ b/.config/init/init.sh @@ -1,7 +1,7 @@ -#!/bin/bash -source ~/.config/init/vars +#!/bin/zsh -source ~/.config/init/gen-zathurarc.sh -source ~/.config/init/gen-urxvt-theme.sh -source ~/.config/init/gen-userChrome.sh -source ~/.config/init/gen-bg-saved.sh +source $HOME/.config/init/vars + +for f in $HOME/.config/init/gen/*; do + source "$f" +done diff --git a/.zprofile b/.zprofile index 75606b2..5607a06 100644 --- a/.zprofile +++ b/.zprofile @@ -7,8 +7,37 @@ export QT_STYLE_OVERRIDE=gtk PATH=$PATH:~/.cabal/bin ########## MAKE USER FUNCS AVAILABLE ########## -[[ -d ~/.config/init/funcs/ ]] && \ - PATH="$PATH:$HOME/.config/init/funcs" +func_init_checkreq() { + local func_init_state=0 + for e in "$@"; do + if [[ $func_init_state -eq 0 ]]; then + if [[ "$e" == ',' ]]; then + func_init_state=1 + else + whence $e >/dev/null + [[ $? -eq 0 ]] || return 1 + fi + else + local cmd + echo "$e" | read -A cmd + $cmd 2>/dev/null 1>&2 + [[ $? -eq 0 ]] || return 1 + fi + done + return 0 +} + +if [[ -d ~/.config/init/funcs/ && -d ~/.config/init/funcreqs ]]; then + rm -r /tmp/funcs + mkdir -p /tmp/funcs + PATH=$PATH:/tmp/funcs + for f in $HOME/.config/init/funcreqs/*; do + source "$f" + func_init_checkreq $func_init_prereqs , $func_init_checks + [[ $? -eq 0 ]] && \ + ln -s $HOME/.config/init/funcs/${f:t} /tmp/funcs/${f:t} + done +fi ############# CONNECTING OVER SSH ############# [[ -f ~/.zprofile-dtach ]] && \ -- cgit v1.2.3