From 8cc927e930d5b6aafe3e9862a61e81705479a1b4 Mon Sep 17 00:00:00 2001 From: Vito Graffagnino Date: Tue, 8 Sep 2020 13:31:02 +0100 Subject: Initial commit. .z* files added --- .zshfunc | 5970 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 5970 insertions(+) create mode 100644 .zshfunc (limited to '.zshfunc') diff --git a/.zshfunc b/.zshfunc new file mode 100644 index 0000000..b9a888e --- /dev/null +++ b/.zshfunc @@ -0,0 +1,5970 @@ +########################################################### +# +# #-------- Functions #-------- {{{ +# +########################################################### +########################################################### +#------------Network {{{ +# +# Identify ethernet device, typically eth0, but when the interface +# is defined by udev this will be different (eg. enp2s0f0). The interfaces +# can be found in /proc/net/dev +# + +ip_geteif(){ + export ETHERNET_IF=`{cat /proc/net/dev | awk 'NR>2' | awk '/e/' | awk -F: '{gsub(/ /,"",$1);print $1}' ; }` +} +# Identify wireless device, typically wlan0, but when the interface +# is defined by udev this will be different (eg. wlp3s0b1). The interfaces +# can be found in /proc/net/dev +# + +ip_getwif(){ + export WIRELESS_IF=`{cat /proc/net/dev | awk 'NR>2' | awk '/w/' | awk -F: '{gsub(/ /,"",$1);print $1}' ; }` +} + +# Check to see if you have external connection and if so get the ip address. +# +ip_chkextnw(){ + if ping -q -c 1 -W 1 8.8.8.8 > /dev/null ; then + echo -e "$1 : External:\t `wget -qO - http://icanhazip.com`" ; + else + echo -e "$1 : No External Network...\n"; + fi +} + +# Check to see if the interface is up and if so obtain the internal ip address +ip_ifup(){ + unset operstateFile ; + operstateFile="/sys/class/net/$1/operstate" ; + if [[ $(cat $operstateFile ) == "up" ]] ; + then + # check to see if external network is available + ip_chkextnw $1 ; + echo -e "$1 : Internal:\t `ip addr show $1 | grep inet\ | awk '{print $2}' | awk -F/ '{print $1}'`" ; + else + echo -e "$1 : No Network...\n"; + fi +} + +# Display the network information +# +ip_show(){ + ip_geteif ; + ip_getwif ; + + ip_ifup $ETHERNET_IF ; + ip_ifup $WIRELESS_IF ; +} +# +# --- }}} +########################################################### +#------------Start up Message - Disk Size {{{ +# Print out a table of disk usage at start up +startup_diskUsage(){ + +df -hl | grep /dev/sda | sort -k6 | awk '!/efi/' | awk '{printf("%-12s\t:%5s /%5s free (%4s used)\n",$6,$4,$2,$5)}' ; + +} +# +# --- }}} +########################################################### +# ----------- VPNs {{{ +# + +mlvn-up(){ + nmcli radio wifi on && + nmcli con up id VM1835498 && + vpn-up 80 ; +} + +mlvn-dn(){ + vpn-dn 80 && + nmcli con down id VM1835498 && + nmcli radio wifi off ; +} + +car-wlan-up(){ + nmcli con up id car-wlan ; +} + +car-wlan-dn(){ + nmcli con down id car-wlan ; +} + +eduroam-up(){ + nmcli con up id eduroam ; +} + +eduroam-dn(){ + nmcli con down id eduroam ; +} + +# +# +vpn-import(){ +# create a new vpn connection and import an .ovpn file +#for FILE1 in ~/AirVPN-OVPN/*.ovpn ; do FILE2=`basename -s .ovpn $FILE1` ; nm-import-openvpn $FILE1 $FILE2; done + FILE1="$1" + FILE2=`basename -s .ovpn $FILE1` ; + nm-import-openvpn $FILE1 $FILE2 ; + sudo cp $FILE2 /etc/NetworkManager/system-connections/ ; + sudo chmod 600 /etc/NetworkManager/system-connections/$FILE2 ; + sudo nmcli con load /etc/NetworkManager/system-connections/$FILE2 ; +} +# +# + +vpn_list_avail(){ + nmcli con show | awk '/vpn/ {print NR, $1}' ; } +vpn_list_AT(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_AT|_Austria/ {print NR, $1}' ; } +vpn_list_BE(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_BE|_Belgium/ {print NR, $1}' ; } +vpn_list_BG(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_BG|_Bulgaria/ {print NR, $1}' ; } +vpn_list_CA(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_CA|_Canada/ {print NR, $1}' ; } +vpn_list_CH(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_CH|_Switzerland/ {print NR, $1}' ; } +vpn_list_CZ(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_CZ|_Czech-Republic/ {print NR, $1}' ; } +vpn_list_DE(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_DE|_Germany/ {print NR, $1}' ; } +vpn_list_ES(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_ES|_Spain/ {print NR, $1}' ; } +vpn_list_FR(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_FR/ {print NR, $1}' ; } +vpn_list_GB(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_GB|_United-Kingdom/ {print NR, $1}' ; } +vpn_list_HK(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_HK|_Hong-Kong/ {print NR, $1}' ; } +vpn_list_LT(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_LT|_Lithuania/ {print NR, $1}' ; } +vpn_list_LV(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_LV|_Latvia/ {print NR, $1}' ; } +vpn_list_NL(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_NL|_Netherlands/ {print NR, $1}' ; } +vpn_list_RO(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_RO|_Romania/ {print NR, $1}' ; } +vpn_list_SE(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_SE|_Sweden/ {print NR, $1}' ; } +vpn_list_SG(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_SG|_Singapore/ {print NR, $1}' ; } +vpn_list_UA(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_UA|_Ukraine/ {print NR, $1}' ; } +vpn_list_US(){ + nmcli con show | awk '/vpn/ {print $1}' | awk '/_US|_United-States/ {print NR, $1}' ; } + +vpn_select(){ + nmcli con show | awk '/vpn/ {print $1}' | awk -v var1=$1 'NR==var1 {print $1}' ; } + +vpn-up(){ + if [ $# -lt 1 ]; then + echo -e "Before you can connect to the required vpn location, use vpn_list_avail to list all available vpns." + echo -e "Alternatively you can use one of the country specific vpn lists, eg: vpn_list_GB or vpn_list_US, etc." + echo -e "Note the index number for the required vpn." + echo -e "vpn-up will then connect to the selected location" + echo -e "\n\nUsage:\n$0 " + echo -e "\nExample:\n$0 76\n" + return 1 + fi + + vpn_select $1 | awk '{system("nmcli con up id " $1)}' ; } + +vpn-dn(){ + nmcli con show --active | awk '/vpn/ {print $1}' | awk '{system("nmcli con down id " $1)}' ; } + +vpn_am-up(){ + nmcli con up id AirVPN_America_UDP-443 } +vpn_am-dn(){ + nmcli con down id AirVPN_America_UDP-443 } +vpn_as-up(){ + nmcli con up id AirVPN_Asia_UDP-443 } +vpn_as-dn(){ + nmcli con down id AirVPN_Asia_UDP-443 } +vpn_cato-up(){ + nmcli con up id AirVPN_CA-Toronto-Ontario_Agena_UDP-443 } +vpn_cato-dn(){ + nmcli con down id AirVPN_CA-Toronto-Ontario_Agena_UDP-443 } +vpn_eu-up(){ + nmcli con up id AirVPN_Europe_UDP-443 } +vpn_eu-dn(){ + nmcli con down id AirVPN_Europe_UDP-443 } +vpn_gblon1-up(){ + nmcli con up id AirVPN_GB-London_Bellatrix_UDP-443 } +vpn_gblon1-dn(){ + nmcli con down id AirVPN_GB-London_Bellatrix_UDP-443 } +vpn_gblon2-up(){ + nmcli con up id AirVPN_GB-London_Algedi_UDP-443 } +vpn_gblon2-dn(){ + nmcli con down id AirVPN_GB-London_Algedi_UDP-443 } +vpn_gblon3-up(){ + nmcli con up id AirVPN_GB-London_Alshain_UDP-443 } +vpn_gblon3-dn(){ + nmcli con down id AirVPN_GB-London_Alshain_UDP-443 } +vpn_gblon4-up(){ + nmcli con up id AirVPN_GB-London_Asterion_UDP-443 } +vpn_gblon4-dn(){ + nmcli con down id AirVPN_GB-London_Asterion_UDP-443 } +vpn_gbmdh-up(){ + nmcli con up id AirVPN_GB-Maidenhead_Carinae_UDP-443 } +vpn_gbmdh-dn(){ + nmcli con down id AirVPN_GB-Maidenhead_Carinae_UDP-443 } +vpn_gbman-up(){ + nmcli con up id AirVPN_GB-Manchester_Nashira_UDP-443 } +vpn_gbman-dn(){ + nmcli con down id AirVPN_GB-Manchester_Nashira_UDP-443 } +vpn_hk-up(){ + nmcli con up id AirVPN_HK-HongKong_Yed_UDP-443 } +vpn_hk-dn(){ + nmcli con down id AirVPN_HK-HongKong_Yed_UDP-443 } +vpn_us-up(){ + nmcli con up id AirVPN_United-States_UDP-443 } +vpn_us-dn(){ + nmcli con down id AirVPN_United-States_UDP-443 } +vpn_usla-up(){ + nmcli con up id AirVPN_US-LosAngeles_Sabik_UDP-443 } +vpn_usla-dn(){ + nmcli con down id AirVPN_US-LosAngeles_Sabik_UDP-443 } + +# --- }}} +############################################################ +#------------ Login / Shell {{{ +prompt_bash() { + export PS1="${Color_off}\ + [${Cyan}\u${Color_off}@${Yellow}\h${Color_off}] \ + ${BBlue}\w${Color_off}\\$ " } +# --- }}} +############################################################ +#--- macfanctld--- {{{ +# +macf(){ + sudo /usr/sbin/macfanctld; + sudo /usr/sbin/thermald; + sudo systemctl start tlp; + sudo tlp start ; } +# --- }}} +############################################################ +#--- compile neomutt--- {{{ +# shell function to compile neomutt: + + compile_neomutt () { + #./configure prefix=/usr/local/bin -enable-pop -enable-imap -enable-smtp -with-curses \ + ./configure prefix=/usr/local/bin -enable-pop -enable-imap -enable-smtp -with-slang \ + -enable-sidebar -enable-notmuch -enable-nntp -enable-compressed \ + -enable-hcache -with-tokyocabinet -with-ssl -with-gnutls -with-idn -with-included-gettext \ + -with-regex -enable-locales-fix -disable-dependency-tracking } + +# --- }}} +############################################################ +#--- zsh history fix--- {{{ +# +zsh_hist_fix(){ + cd $HOME; mv -f .zsh_history .zsh_history_bad; + strings .zsh_history_bad > .zsh_history; + fc -R .zsh_history; rm -f .zsh_history_bad + } + +# --- }}} +############################################################ +#--- simple note taking function --- {{{ +# +notes(){ + if [ ! -z "$1" ]; then + echo $(date +"%Y%m%d-%H%M%S") $@ >> "$HOME/vimwiki/TempNotes.md" + else + cat - >> "$HOME/vimwiki/TempNotes.md" + fi + } + +# --- }}} +############################################################ +#--- KeepassX command line interface --- {{{ +# +kpcli(){ + /bin/kpcli --kdb $HOME/Documents/20151120.kdbx + } + +# --- }}} +########################################################### +#-------- Transmission CLI {{{ +# this is notes for video: http://www.youtube.com/watch?v=ee4XzWuapsE +#------------------------------------------------------ +# lightweight torrent daemon, has option for cli, webui, ncurses, and gui frontend +# demo video: http://www.youtube.com/watch?v=ee4XzWuapsE +# WebUI: http://localhost:9091/transmission/web/ +# http://192.168.1.xxx:9091/transmission/web/ +tsm-clearcompleted() { + transmission-remote -l | grep 100% | grep Done | \ + awk '{print $1}' | xargs -n 1 -I % transmission-remote -t % -r ;} +tsm() { transmission-remote --list ;} + # numbers of ip being blocked by the blocklist +# credit: smw from irc #transmission +tsm-count() { echo "Blocklist rules:" $(curl -s --data \ +'{"method": "session-get"}' localhost:9091/transmission/rpc -H \ +"$(curl -s -D - localhost:9091/transmission/rpc | grep X-Transmission-Session-Id)" \ +| cut -d: -f 11 | cut -d, -f1) ;} +# demo video: http://www.youtube.com/watch?v=TyDX50_dC0M +tsm-blocklist() { $PATH_SCRIPTS/blocklist.sh ;} # update blocklist +tsm-daemon() { transmission-daemon ;} +tsm-quit() { killall transmission-daemon ;} +tsm-altspeedenable() { transmission-remote --alt-speed ;} # limit bandwidth +tsm-altspeeddisable() { transmission-remote --no-alt-speed ;} # dont limit bandwidth +tsm-add() { transmission-remote --add "$1" ;} +tsm-askmorepeers() { transmission-remote -t"$1" --reannounce ;} +tsm-pause() { transmission-remote -t"$1" --stop ;} # or all +tsm-start() { transmission-remote -t"$1" --start ;} # or all +tsm-purge() { transmission-remote -t"$1" --remove-and-delete ;} # delete data also +tsm-remove() { transmission-remote -t"$1" --remove ;} # leaves data alone +tsm-info() { transmission-remote -t"$1" --info ;} +tsm-speed() { while true;do clear; transmission-remote -t"$1" -i | grep Speed;sleep 1;done ;} +tsm-verify() { transmission-remote -t"$1" --verify ;} # verify a torrent + +# https://github.com/fagga/transmission-remote-cli +# demo video: http://www.youtube.com/watch?v=hLz7ditUwY8 +tsm-ncurse() { tremc ;} +#extract torrent files from magnet link +tsm-m2t(){ aria2c --bt-metadata-only=true --bt-save-metadata=true "$1"} + +# --- }}} +############################################################ +#-------- Firefox profile{{{ +firefox_J() { /usr/bin/firefox -no-remote -P Jupyter > /dev/null 2>&1 & } +firefox_Y() { /usr/bin/firefox -no-remote -P Youtube & } +firefox_T() { /usr/bin/firefox -no-remote -P Torrent & } +# --- }}} +############################################################ +#-------- DVD playback{{{ +dvd_play() { mplayer dvdnav:// -mouse-movements \ + -dvd-device /dev/dvd ;} +# --- }}} +############################################################ +#-------- DVD rip{{{ +dvd_rip() { + rawout=$(HandBrakeCLI -i /dev/dvd -t 0 2>&1 >/dev/null); + count=$(echo $rawout | grep -Eao "\\+ title [0-9]+:" | wc -l); + for i in $(seq $count); do HandBrakeCLI -i /dev/dvd -t $i -Z "Very Fast 720p30" -a 2 -o ${1}.mp4 ; done + } +# --- }}} +############################################################ +#-------- Configurations {{{ +#------------------------------------------------------ +cfg-afewrc() { $EDITOR ~/.config/afew/config ;} +cfg-alacritty() { $EDITOR ~/.config/alacritty/alacritty.yml;} +cfg-bashrc() { $EDITOR $HOME/.bashrc ;} +cfg-castero() { $EDITOR ~/.config/castero/castero.conf ;} +cfg-conkyrc() { $EDITOR $HOME/.conkyrc ;} +cfg-dotalias() { $EDITOR $HOME/.bashrc.d/02aliases.bash.linux ;} +cfg-dotenvs() { $EDITOR $HOME/.bashrc.d/01environ.bash.linux ;} +cfg-dotfuncs() { $EDITOR $HOME/.bashrc.d/03functions.bash.linux ;} +cfg-dotopts() { $EDITOR $HOME/.bashrc.d/04options.bash.linux ;} +cfg-dunstrc() { $EDITOR $XDG_CONFIG_HOME/dunst/dunstrc ;} +cfg-fstab() { sudo $EDITOR /etc/fstab ;} +cfg-group() { sudo $EDITOR /etc/group ;} +cfg-grub() { sudo $EDITOR /etc/default/grub ;} +cfg-hosts() { sudo $EDITOR /etc/hosts ;} +cfg-i3wm() { $EDITOR ~/.i3/config ;} +cfg-i3blocks() { $EDITOR ~/.i3/i3blocks.conf ;} +cfg-inputrc() { $EDITOR ~/.inputrc ;} +cfg-livestreamer() { $EDITOR ~/.livestreamerrc ;} +cfg-mbsyncrc() { $EDITOR ~/.mbsyncrc ;} +cfg-mc() { $EDITOR ~/.config/mc/ini ;} +cfg-mcomix() { $EDITOR ~/.config/mcomix/keybindings.conf ;} +cfg-mpds() { sudo $EDITOR /etc/mpd.conf ;} +cfg-mpd() { $EDITOR ~/.config/mpd/mpd.conf ;} +cfg-mplayer() { $EDITOR ~/.config/mplayer/config ;} +cfg-mpv() { $EDITOR ~/.config/mpv/input.conf ;} +cfg-msmtprc() { $EDITOR ~/.config/msmtp/config ;} +cfg-muttrc() { $EDITOR ~/.config/mutt/muttrc ;} +cfg-muttrc-h() { $EDITOR ~/.config/mutt/accounts/1-herts.muttrc ;} +cfg-muttrc-b() { $EDITOR ~/.config/mutt/accounts/2-bt.muttrc ;} +cfg-muttrc-bo() { $EDITOR ~/.config/mutt/accounts/3-bt-offline.muttrc ;} +#cfg-mutt-g1() { $EDITOR ~/.mutt/account.com.gmail.gfgm ;} +#cfg-mutt-g2() { $EDITOR ~/.mutt/account.com.gmail.vggm ;} +cfg-nanorc() { $EDITOR ~/.nanorc;} +cfg-ncmpcpp() { $EDITOR ~/.config/ncmpcpp/config ;} +cfg-ncmpcpp-bindings() { $EDITOR ~/.config/ncmpcpp/bindings ;} +cfg-newsboat() { $EDITOR ~/.newsboat/config ;} +cfg-newsboat-queue() { $EDITOR ~/.newsboat/queue ;} +cfg-newsboat-urls() { $EDITOR ~/.newsboat/urls ;} +cfg-notmuchrc() { $EDITOR ~/.notmuch-config ;} +cfg-nvim() { $EDITOR ~/.config/nvim/init.vim ;} +cfg-offlineimap() { $EDITOR $XDG_CONFIG_HOME/offlineimap/config ;} +cfg-profile() { $EDITOR ~/.profile ;} +cfg-pulseaudio() { sudo $EDITOR /etc/pulse/default.pa ;} +cfg-pyload() { $EDITOR ~/.pyload/pyload.conf ;} +cfg-pyradio() { $EDITOR ~/.pyradio.csv ;} +cfg-qutebrowser() { $EDITOR ~/.config/qutebrowser/config.py ;} +#cfg-qutebrowser() { $EDITOR ~/.config/qutebrowser/qutebrowser.conf ;} +cfg-qutebrowser-keys() { $EDITOR ~/.config/qutebrowser/keys.conf ;} +cfg-ranger() { $EDITOR ~/.config/ranger/rc.conf ;} +cfg-ranger-rifle() { $EDITOR ~/.config/ranger/rifle.conf ;} +cfg-ranger-scope() { $EDITOR ~/.config/ranger/scope.sh ;} +cfg-rofi() { $EDITOR ~/bin/scripts/rofi-scripts-collection/rofi-bangs.sh ;} +cfg-ssh-client() { sudo $EDITOR /etc/ssh/ssh_config ;} +cfg-ssh-daemon() { sudo $EDITOR /etc/ssh/sshd_config ;} +cfg-sudoers() { sudo $EDITOR /etc/sudoers ;} +cfg-termite() { $EDITOR ~/.config/termite/config ;} +cfg-tmuxrc() { $EDITOR ~/.tmux.conf ;} +cfg-torrc() { sudo $EDITOR /etc/tor/torrc ;} +cfg-tpb() { $EDITOR $HOME/bin/scripts/torrshellscripts-master/thepiratebay_se/tpb.sh ;} +cfg-transmission-daemon() { $EDITOR ~/.config/transmission-daemon/settings.json ;} +cfg-transmission-ncurse() { $EDITOR ~/.config/transmission-remote-cli/settings.cfg ;} +cfg-trz() { $EDITOR $HOME/bin/scripts/torrshellscripts-master/torrentz_eu/torrentz_eu.sh ;} +cfg-tridactyl() { $EDITOR $HOME/.config/tridactyl/tridactylrc ;} +cfg-urlview() { $EDITOR ~/.urlview ;} +cfg-updatedb() { sudo $EDITOR /etc/updatedb.conf ;} +cfg-vifmrc() { $EDITOR ~/.vifmrc ;} +cfg-vimrc() { $EDITOR ~/.vimrc ;} +cfg-w3m() { $EDITOR ~/.w3m/config ;} +cfg-weechat() { $EDITOR ~/.weechat/weechat.conf ;} +cfg-w3m-keymap() { $EDITOR ~/.w3m/keymap ;} +cfg-xdefaults() { $EDITOR ~/.Xdefaults ;} +cfg-xresources() { $EDITOR ~/.Xresources ;} +cfg-ytdl() { $EDITOR $XDG_CONFIG_HOME/youtube-dl/config ;} +cfg-zshrc() { $EDITOR ~/.zshrc ;} +cfg-zurlrc() { $EDITOR ~/.zurlrc ;} +cfg-i3keylist(){ +echo " \$mod+{}" +echo " =======" +echo " \$mod+a focus parent" +echo " \$mod+b split h" +echo " \$mod+d exec --no-startup-id dmenu_run" +echo " \$mod+e exec --no-startup-id $term -e \"mutt -F ~/.muttrc\"" +echo " \$mod+f fullscreen toggle" +echo " \$mod+h focus left" +echo " \$mod+j focus down" +echo " \$mod+k focus up" +echo " \$mod+l focus right" +echo " \$mod+m exec --no-startup-id /usr/bin/mplayer " +echo " \$mod+n border normal" +echo " \$mod+r exec --no-startup-id $term -e ranger" +echo " \$mod+t layout toggle split" +echo " \$mod+u border none" +echo " \$mod+v split v" +echo " \$mod+w exec --no-startup-id $browser" +echo " \$mod+y border pixel 2" +echo " \$mod+z split v, layout stacking" +echo " \$mod+space focus mode_toggle" +echo " \$mod+Return exec --no-startup-id " +echo " \$mod+grave exec --no-startup-id $HOME/bin/scripts/any_term_dropdown.sh" +echo " \$mod+F11 exec --no-startup-id amixer set Master 5%-" +echo " \$mod+F12 exec --no-startup-id amixer set Master 5%+" +echo " \$mod+F1 exec --no-startup-id xbacklight -dec 5 " +echo " \$mod+F2 exec --no-startup-id xbacklight -inc 5 " +echo " \$mod+F4 mode \"$mode_system\"" +echo "" +echo " =======" +echo " \$mod+Shift+{}" +echo " =======" +echo " \$mod+Shift+c reload" +echo " \$mod+Shift+d exec --no-startup-id rofi -show run -lines 10 -eh 2 -width 80 " +echo " -padding \$(($(xwininfo -root | awk '/Height/ {print $2}')/4)) " +echo " -opacity \"75\" -bw 0 -bc \"\$base02\" -bg \"$base02\" -fg \"$base03\" " +echo " -hlbg \"\$base02\" -hlfg \"#9575cd\" -font \"System San Francisco Display 12\"" +echo " \$mod+Shift+e exec --no-startup-id \"i3-nagbar -t warning -m 'You pressed the exit shortcut.\"" +echo " Do you really want to exit i3? This will end your X session.' -b \ " +echo " 'Yes, exit i3' 'i3-msg exit'" +echo " \$mod+Shift+f exec --no-startup-id /usr/bin/firefox -no-remote -P default" +echo " \$mod+Shift+h move left" +echo " \$mod+Shift+i exec --no-startup-id /usr/bin/firefox -no-remote -P Jupyter" +echo " \$mod+Shift+j move down" +echo " \$mod+Shift+k move up" +echo " \$mod+Shift+l move right" +echo " \$mod+Shift+m exec --no-startup-id /usr/bin/mpv" +echo " \$mod+Shift+n exec --no-startup-id /usr/bin/nm-applet" +echo " \$mod+Shift+q kill" +echo " \$mod+Shift+r restart" +echo " \$mod+Shift+t exec --no-startup-id /usr/bin/firefox -private-window -no-remote -P Torrent " +echo " \$mod+Shift+u resize shrink height 10 px or 10 ppt" +echo " \$mod+Shift+w exec --no-startup-id /usr/local/bin/eclipse/eclipse " +echo " \$mod+Shift+y exec --no-startup-id /usr/bin/firefox -no-remote -P Youtube" +echo " \$mod+Shift+space floating toggle" +echo " \$mod+Shift+Return exec --no-startup-id $term -e tmux" +echo "" +echo " =======" +echo " \$mod+Ctrl+{}" +echo " =======" +echo " \$mod+Ctrl+r mode \"resize\" " +echo " \$mod+Ctrl+d gaps inner current set 0; gaps outer current set 0" +echo " \$mod+Ctrl+t gaps inner current set 15; gaps outer current set 15" +echo "" +echo " \$mod+Ctrl+i resize grow height 10 px or 10 ppt" +echo " \$mod+Ctrl+o resize grow width 10 px or 10 ppt" +echo " \$mod+Ctrl+u resize shrink height 10 px or 10 ppt" +echo " \$mod+Ctrl+y resize shrink width 10 px or 10ppt" +echo "" +echo " \$mod+Ctrl+h gaps inner current plus 5" +echo " \$mod+Ctrl+j gaps outer current minus 5" +echo " \$mod+Ctrl+k gaps outer current plus 5" +echo " \$mod+Ctrl+l gaps inner current minus 5" +echo " \$mod+Ctrl+space exec --no-startup-id $HOME/bin/scripts/rofi-scripts-collection/rofi-bangs.sh \"" +echo " -font \"System San Francisco Display 12\" " +echo " \$mod+Ctrl+Return exec --no-startup-id guake" +echo "" +echo " =======" + + +##################################################### +# +# --- }}} +} +# --- }}} +########################################################### +#-------- Configurations Reload {{{ +#------------------------------------------------------ +rld-bashrc() { source ~/.bashrc ;} +rld-font() { fc-cache -v -f ;} +rld-grub() { sudo grub-mkconfig -o /boot/grub/grub.cfg ;} +rld-updatedb() { sudo updatedb ;} +rld-xdefaults() { xrdb ~/.Xdefaults ;} +rld-xmodmap() { xmodmap ~/.Xmodmap ;} +rld-xresources() { xrdb -load ~/.Xresources ;} +rld-zshrc() { source ~/.zshrc ;} +# }}} +########################################################### +#-------- IPlayer {{{ + +get_iplayer-list(){ clear ; for FILE in `cat ToDownloadList`; do URI=$FILE; echo "Downloading $URI"; ${HOME}/bin/get_iplayer --modes=flashhigh,hlshigh --url $URI; done} +tvlist(){ clear; + +echo "bbc1" +echo "bbc2" +echo "bbc3" +echo "bbc4" +echo "bbcn" +echo "cbbc" +echo "cbeebies" +echo "itv" +echo "itv2" +echo "itv3" +echo "itv4" +echo "citv" +echo "ch4" +echo "e4" +echo "more4" +echo "film4" +echo "film4+1" +echo "ch5" +echo "5star" +echo "5star+1" +echo "5usa" +echo "5usa+1" +echo "dave" +echo "spike" +echo "universal" +echo "syfy" +echo "sony" +echo "discovery" +echo "vice" +echo "natgeo" +echo "eurosport1" +echo "eurosport2" +echo "boxnation" +echo "nickelodeon" +echo "nickjr" +echo "cartoonnetwork" +echo "boomerang" + +echo "rai1" +echo "rai2" +echo "rai3" +echo "rai4" +echo "rai5" +echo "raipremium" +echo "raimovie" +echo "raisport" +echo "rainews24" +echo "padrepio" + +echo "ewtn" +} + +livemass(){ mpv http://34.232.8.78:1935/live/live/chunklist_w398967804.m3u8 } +bbc1(){ streamlink https://tvplayer.com/watch/bbcone 2>&1 & } +bbc2(){ streamlink https://tvplayer.com/watch/bbctwo 2>&1 & } +bbc4(){ streamlink https://tvplayer.com/watch/bbcfour 2>&1 & } +bbcn(){ streamlink https://tvplayer.com/watch/bbcone 2>&1 & } +cbeebies(){ streamlink https://tvplayer.com/watch/cbeebies 2>&1 & } +cbbc(){ streamlink https://tvplayer.com/watch/cbbc 2>&1 & } +itv(){ streamlink https://tvplayer.com/watch/itv 2>&1 & } +itv2(){ streamlink https://tvplayer.com/watch/itv2 2>&1 & } +itv3(){ streamlink https://tvplayer.com/watch/itv3 2>&1 & } +itv4(){ streamlink https://tvplayer.com/watch/itv4 2>&1 & } +citv(){ streamlink https://tvplayer.com/watch/citv 2>&1 & } +ch4(){ streamlink https://tvplayer.com/watch/channel4 2>&1 & } +more4(){ streamlink https://tvplayer.com/watch/more4 2>&1 & } +#e4(){mpv http://46.249.60.210:15099/play/a00h &> /dev/null & } +film4(){mpv http://195.189.203.18:8080/play/a01c &> /dev/null & } +film4_plus1(){mpv http://195.189.203.18:8080/play/a01d &> /dev/null & } +ch5(){ streamlink https://tvplayer.com/watch/five 2>&1 & } +5star(){ streamlink https://tvplayer.com/watch/5star 2>&1 & } +5star_plus1(){mpv http://46.249.60.210:15099/play/a01s &> /dev/null & } +5usa(){mpv http://46.249.60.210:15099/play/a01o &> /dev/null & } +5usa_plus1(){mpv http://46.249.60.210:15099/play/a01p &> /dev/null & } +dave(){ streamlink https://tvplayer.com/watch/dave 2>&1 & } +spike(){ streamlink https://tvplayer.com/watch/spike 2>&1 & } +universal(){ streamlink https://tvplayer.com/watch/universalchannel 2>&1 & } +syfy(){ streamlink https://tvplayer.com/watch/syfy 2>&1 & } +sony(){ streamlink https://tvplayer.com/watch/sonyentertainment 2>&1 & } +discovery(){ streamlink https://tvplayer.com/watch/discovery 2>&1 & } +vice(){ streamlink https://tvplayer.com/watch/viceland 2>&1 & } +natgeo(){ streamlink https://tvplayer.com/watch/nationalgeographic 2>&1 & } +eurosport1(){ streamlink https://tvplayer.com/watch/eurosport1 2>&1 & } +eurosport2(){ streamlink https://tvplayer.com/watch/eurosport2 2>&1 & } +boxnation(){ streamlink https://tvplayer.com/watch/boxnation 2>&1 & } +nickelodeon(){ streamlink https://tvplayer.com/watch/nickelodeon 2>&1 & } +nickjr(){ streamlink https://tvplayer.com/watch/nickjr 2>&1 & } +cartoonnetwork(){ streamlink https://tvplayer.com/watch/cartoonnetwork 2>&1 & } +boomerang(){ streamlink https://tvplayer.com/watch/boomerang 2>&1 & } + +rai1(){ streamlink http://www.raiplay.it/dirette/rai1 2>&1 & } +rai2(){ streamlink http://www.raiplay.it/dirette/rai2 2>&1 & } +rai3(){ streamlink http://www.raiplay.it/dirette/rai3 2>&1 & } +rai4(){ streamlink http://www.raiplay.it/dirette/rai4 2>&1 & } +rainews24(){ streamlink http://www.raiplay.it/dirette/rainews24 2>&1 & } +raisport(){ streamlink http://www.raiplay.it/dirette/raisport 2>&1 & } +raimovie(){ streamlink http://www.raiplay.it/dirette/raimovie 2>&1 & } +raipremium(){ streamlink http://www.raiplay.it/dirette/raipremium 2>&1 & } + +padrepio(){mpv http://5.255.90.175:3000/play/a05l &> /dev/null & } + +ewtn(){mpv http://ewtnmmd.mmdlive.lldns.net/ewtnmmd/42a5a390e56f40d7a5ae90ccd36ce775/playlist.m3u8 &> /dev/null &} + +# }}} +########################################################### +#-------- Novacom {{{ +nova-up(){ echo "nova-up:...:"; sudo -E novacomd -d; } +nova-down(){sudo -E kill -9 $(echo `ps aux | grep novacomd | awk '/root/{print $2}'`); echo "nova-down:...completed:"; } +pre2(){ novacom -d roadrunner-linux -t open tty://; } +pre3(){ novacom -d mantaray-linux -t open tty:// ;} +touchpad(){ novacom -d topaz-linux -t open tty:// ;} +tptoolbox() { sh /home/archlinux/vgg/Computing/Palm/webos/Homebrew/Tools/07-tptoolbox_v42/tptb_v42_nix.sh ;} +veer(){ novacom -d broadway-linux -t open tty:// ;} +preftp(){ ftp preanon@webosftp.qualitis.hu ;} +preweb(){ w3m ftp://preanon@webosftp.qualitis.hu ;} +# }}} +########################################################### +#-------- Racoon {{{ +racoon() {java -jar /home/archlinux/vgg/bin/raccoon-4.15.0.jar & >/dev/null } +# }}} +########################################################### +#-------- VirtualBox {{{ + +vbx-list(){ # List available vms + +vboxmanage list vms ; } + +vbx-info(){ # Display info about vm + + if [ $# -lt 1 ]; then + echo -e "Display info for available VirtualBox vms." + echo -e "\nUsage:\n$0 " + echo -e "\nExample:\n$0 UbuntuVM\n" + return 1 + fi + + vboxmanage showvminfo $1 ; +} + +vbx-Start(){ # Start up the vm + + if [ $# -lt 1 ]; then + echo -e "Start up the VirtualBox vm." + echo -e "\nUsage:\n$0 " + echo -e "\nExample:\n$0 UbuntuVM\n" + return 1 + fi + + vboxmanage startvm $1 ; +} + +vbx-start(){ # Start up the vm (headless) + + if [ $# -lt 1 ]; then + echo -e "Start up the VirtualBox vm in headless mode." + echo -e "\nUsage:\n$0 " + echo -e "\nExample:\n$0 UbuntuVM\n" + return 1 + fi + + vboxmanage startvm $1 --type headless ; +} + +vbx-save(){ # Save the state of the vm and then close it down + + if [ $# -lt 1 ]; then + echo -e "Save the state of the Virtual Box vm and then close it down" + echo -e "\nUsage:\n$0 " + echo -e "\nExample:\n$0 UbuntuVM\n" + return 1 + fi + + vboxmanage controlvm $1 savestate ; +} + +vbx-stop(){ # Stop/power down the vm + + if [ $# -lt 1 ]; then + echo -e "Stop/Power down the VirtualBox vm." + echo -e "\nUsage:\n$0 " + echo -e "\nExample:\n$0 UbuntuVM\n" + return 1 + fi + + vboxmanage controlvm $1 poweroff ; +} + +vbx-del(){ # Delete and unregister the vm. Also removes all hard disk images, machine xml file, log files and machine directory. + # Machine should already be powered off. + + if [ $# -lt 1 ]; then + echo -e "Delete and unregister the Virtual Box vm." + echo -e "Virtual Box vm should already be powered off." + echo -e "\nUsage:\n$0 " + echo -e "\nExample:\n$0 UbuntuVM\n" + return 1 + fi + + vboxmanage unregistervm --delete $1 ; +} + +vbx-sl7(){ ssh -p 3022 vgg@127.0.0.1 ; } # ssh into sl7 vm. +vbx-sl7x(){ ssh -X -p 3022 vgg@127.0.0.1 ; } # ssh into sl7 vm. +vbx-cr8sl7(){ sh ${HOME}/bin/VirtualBoxTest/createvm.sh ; } # Create SL7 vm +vbx-edt-cr8sl7(){ $EDITOR ${HOME}/bin/VirtualBoxTest/createvm.sh ; } # Edit the creation script for SL7 vm + +# }}} +########################################################### +#-------- VMWare {{{ + +#vmw-list(){ # List available vms + +#vboxmanage list vms ; } + +#vmw-info(){ # Display info about vm + + #if [ $# -lt 1 ]; then + #echo -e "Display info for available VirtualBox vms." + #echo -e "\nUsage:\n$0 " + #echo -e "\nExample:\n$0 UbuntuVM\n" + #return 1 + #fi + + #vboxmanage showvminfo $1 ; +#} + +#vmw-Start(){ # Start up the vm + + #if [ $# -lt 1 ]; then + #echo -e "Start up the VirtualBox vm." + #echo -e "\nUsage:\n$0 " + #echo -e "\nExample:\n$0 UbuntuVM\n" + #return 1 + #fi + + #vboxmanage startvm $1 ; +#} + +#vmw-start(){ # Start up the vm (headless) + + #if [ $# -lt 1 ]; then + #echo -e "Start up the VirtualBox vm in headless mode." + #echo -e "\nUsage:\n$0 " + #echo -e "\nExample:\n$0 UbuntuVM\n" + #return 1 + #fi + + #vboxmanage startvm $1 --type headless ; +#} + +#vmw-save(){ # Save the state of the vm and then close it down + + #if [ $# -lt 1 ]; then + #echo -e "Save the state of the Virtual Box vm and then close it down" + #echo -e "\nUsage:\n$0 " + #echo -e "\nExample:\n$0 UbuntuVM\n" + #return 1 + #fi + + #vboxmanage controlvm $1 savestate ; +#} + +#vmw-stop(){ # Stop/power down the vm + + #if [ $# -lt 1 ]; then + #echo -e "Stop/Power down the VirtualBox vm." + #echo -e "\nUsage:\n$0 " + #echo -e "\nExample:\n$0 UbuntuVM\n" + #return 1 + #fi + + #vboxmanage controlvm $1 poweroff ; +#} + +#vmw-del(){ # Delete and unregister the vm. Also removes all hard disk images, machine xml file, log files and machine directory. + ## Machine should already be powered off. + + #if [ $# -lt 1 ]; then + #echo -e "Delete and unregister the Virtual Box vm." + #echo -e "Virtual Box vm should already be powered off." + #echo -e "\nUsage:\n$0 " + #echo -e "\nExample:\n$0 UbuntuVM\n" + #return 1 + #fi + + #vboxmanage unregistervm --delete $1 ; +#} + +#vmw-sl7(){ ssh -p 3022 vgg@127.0.0.1 ; } # ssh into sl7 vm. +#vmw-sl7x(){ ssh -X -p 3022 vgg@127.0.0.1 ; } # ssh into sl7 vm. +#vmw-cr8sl7(){ sh ${HOME}/bin/VirtualBoxTest/createvm.sh ; } # Create SL7 vm +#vmw-edt-cr8sl7(){ $EDITOR ${HOME}/bin/VirtualBoxTest/createvm.sh ; } # Edit the creation script for SL7 vm + +# }}} +########################################################### +#-------- Tmux Sessions {{{ +#------------------------------------------------------ +# tmux helps preventing crashes +# when running vim/nvim from within tmux. +# (https://github.com/tmux/tmux/issues/1593) +#------------------------------------------------------ +# +tmx-main() { + TERM="screen-256color" tmux new-session -s 'WongFeiHong' -d ; + TERM="screen-256color" tmux new-window -n 'Ranger' -c $HOME ; + TERM="screen-256color" tmux send-keys 'ranger' 'Enter' ; + TERM="screen-256color" tmux new-window -n 'Email' -c $HOME ; + TERM="screen-256color" tmux send-keys 'mutt' 'Enter' ; + TERM="screen-256color" tmux new-window -n 'RSS' -c $HOME ; + TERM="screen-256color" tmux send-keys 'newsboat' 'Enter' ; + TERM="screen-256color" tmux new-window -n 'www' -c $HOME; + TERM="screen-256color" tmux send-keys 'w3m -B' 'Enter' ; + TERM="screen-256color" tmux new-window -n 'Torr' -c $HOME ; +# TERM="screen-256color" tmux send-keys 'source activate transmission-py27' 'Enter' ; + TERM="screen-256color" tmux send-keys 'tsm-daemon' 'Enter' ; + TERM="screen-256color" tmux send-keys 'tsm-ncurse' 'Enter' ; + TERM="screen-256color" tmux split-window -v -p 40 ; + #TERM="screen-256color" tmux send-keys 'clear' 'Enter' ; + TERM="screen-256color" tmux select-pane -t 1 ; + #TERM="screen-256color" tmux send-keys 'clear' 'Enter' ; + TERM="screen-256color" tmux split-window -h -p 50 -t 1 ; + TERM="screen-256color" tmux send-keys 'mpsyt user gotbletu' 'Enter'; + TERM="screen-256color" tmux select-pane -t 3 ; + TERM="screen-256color" tmux select-window -t 1 ; + TERM="screen-256color" tmux -2 attach-session -d ; + +} +tmx-ipy() { + TERM="screen-256color" tmux new-session -n 'IPython' -d 'nvim'; + TERM="screen-256color" tmux split-window -h 'ipython'; + TERM="screen-256color" tmux -2 attach-session -d ; +} + +# }}} +########################################################### +#-------- System Information {{{ +#------------------------------------------------------ +m-sound() { arecord -L && arecord -l && cat /proc/asound/pcm ;} #List audio capture card/mic +m-distro() { uname -a && lsb_release -a ;} +m-connectip() { + echo "--------------- Connected Devices -----------------" + nmap -sn $(netstat -rn | awk 'FNR == 3 {print $2}')/24 + echo "---------------------------------------------------" + +} + +# uses ip or ifconfig, good on older or newer system +m-ip() { + echo "--------------- Network Information ---------------" + # show router ip +echo "router ip:" $(netstat -rn | awk 'FNR == 3 {print $2}') +## newer system like archlinux +#ip addr | awk '/global/ {print $1,$2}' | cut -d\/ -f1 +#ip addr | awk '/global/ {print $3,$4}' +#ip addr | awk '/ether/ {print $1,$2}' +#ip addr | awk '/scope link/ {print $1,$2}' | cut -d\/ -f1 +## older system like debian +# #ifconfig | awk '/inet addr/ {print $1,$2}' | awk -F: '{print $1,$2}' +# #ifconfig | awk '/Bcast/ {print $3}' | awk -F: '{print $1,$2}' +# #ifconfig | awk '/inet addr/ {print $4}' | awk -F: '{print $1,$2}' +# #ifconfig | awk '/HWaddr/ {print $4,$5}' +# #ifconfig | awk '/Scope:Link/ {print $1,$3}' | cut -d\/ -f1 +## echo External IP $(curl -s http://checkip.dyndns.org/ | grep -o "[[:digit:].]\+") +echo External IP: $(curl -s http://ipecho.net/plain) + echo "---------------------------------------------------" +} +# +#}}} +########################################################### +#-------- PulseAudio Switcher CLI v2 {{{ +#------------------------------------------------------ +# DEMO: https://www.youtube.com/watch?v=jhv-2pNWfr4 +# DESC: switch audio stream to different output (HDMI, Headphone, Speakers ...etc) +# REF: http://askubuntu.com/a/18210 + +pa-global() { + if [ $# -lt 1 ]; then + echo -e "pulseaudio redirect audio of all running app to another device" + echo -e "\nUsage:\n$0 " + echo -e "\nExample:\n$0 0 \n" + echo "===============" + echo "Sound Devices" + pacmd list-sinks | awk '/index/ || /name:/' + return 1 + fi + + # list all apps in playback tab (ex: cmus, mplayer, vlc) + inputs=($(pacmd list-sink-inputs | awk '/index/ {print $2}')) +# set the default output device + pacmd set-default-sink $1 &> /dev/null +# apply the changes to all running apps to use the new output device + for i in ${inputs[*]}; do pacmd move-sink-input $i $1 &> /dev/null; done + +} +pa-solo() { + if [ $# -lt 2 ]; then + echo -e "pulseaudio redirect audio of one running app to another device" + echo -e "\nUsage:\n$0 " + echo -e "\nExample:\n$0 2302 0 \n" + echo "===============" + echo "Running Apps" + pacmd list-sink-inputs | awk '/index/ || /application.name /' + echo "===============" + echo "Sound Devices" + pacmd list-sinks | awk '/index/ || /name:/' + return 1 + fi + + # set the default output device + pacmd set-default-sink "$2" &> /dev/null +# apply changes to one running app to use the new output device + pacmd move-sink-input "$1" "$2" &> /dev/null +# +} +pa-c(){ + pulseaudio -vv --check +} +pa-s(){ + pulseaudio -vv --start +} +pa-k(){ + pulseaudio -vv --kill +} +pa-ps(){ + ps aux | grep -i pulseaudio +} + +#}}} +########################################################### +#-------- Calibre CLI v3 {{{ +#------------------------------------------------------ +# DEMO: http://www.youtube.com/watch?v=FeoVsC4U_0A +# DESC: ebook manager supports many formats and devices; interfaces with cli, webui, gui +# URL: http://manual.calibre-ebook.com/cli/calibredb.html + +cmx-list() { + if [ $# -lt 1 ]; then + echo -e "calibredb list files of a library" + echo -e "\nUsage:\n$0 " + echo -e "\nExample:\n$0 \$cbcomic\n" + return 1 + fi + + calibredb list -f authors,title,tags,rating --library-path "$1" +# +} + +cmx-search() { + if [ $# -lt 2 ]; then + echo -e "calibredb search files of a library" + echo -e "\nUsage:\n$0 " + echo -e "\nExample:\n$0 \$cbcomic marvel" + echo -e "$0 \$cbcomic 'the walking dead'\n" + return 1 +fi + + calibredb list -s "${@:2}" -f authors,title,tags,rating --library-path "$1" +# +} + +cmx-add() { + if [ $# -lt 2 ]; then + echo -e "calibredb add new files to a library" + echo -e "\nUsage:\n$0 " + echo -e "\nExample:\n$0 \$cbcomic file.cbz" + echo -e "$0 \$cbcomic file1.cbz file2.cbz" + echo -e "$0 \$cbcomic file.epub file2.pdf file3.cbr\n" + return 1 + fi + + calibredb add "${@:2}" --library-path "$1" + +} + +cmx-remove() { + if [ $# -lt 2 ]; then + echo -e "calibredb remove files from a library" + echo -e "\nUsage:\n$0 " + echo -e "$0 " + echo -e "\nExample:\n$0 \$cbcomic 100" + echo -e "$0 \$cbcomic 50-55" + echo -e "$0 \$cbcomic 100,120-127" + return 1 + fi + + calibredb remove "${@:2}" --library-path "$1" +# +} + +cmx-show() { + if [ $# -lt 2 ]; then + echo -e "calibredb show file metadata from a library" + echo -e "\nUsage:\n$0 " + echo -e "\nExample:\n$0 \$cbcomic 16" + return 1 + fi + + calibredb show_metadata "${@:2}" --library-path "$1" | html2text +# +} + + +cmx-recipes() { ebook-convert --list-recipes | less ;} + +# WebUI content server +# http://manual.calibre-ebook.com/cli/calibre-server.html +# http://192.168.1.xxx:port +cmx-quit() { kill $(ps -ef | grep -i '[C]alibre-server' | awk '{print $2}') ;} +cmx-server() { + # start all content server on different ports +calibre-server -p 57770 --daemonize --with-library "$CMX_CALIBRE" +calibre-server -p 57771 --daemonize --with-library "$CMX_COMICS" +calibre-server -p 57772 --daemonize --with-library "$CMX_MAGS" + +} +cmx-bkv(){ + if [ $# -lt 2 ]; then + echo -e "launch ebook-viewer with a particular book from a library" + echo -e "\nUsage:\n$0 " + echo -e "\nExample:\n$0 \$cbcomic 16" + return 1 + fi + + BKDIR=`find ${CMX_CALIBRE} -name "*$2*"` + find $BKDIR -type f \( -name "*.epub" -o -name "*.mobi" -o -name "*.pdf" \) -exec /usr/bin/ebook-viewer {} \; & +} + +calibre-update(){ + sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.py | \ + sudo python -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()" +} + +#}}} +########################################################### +#-------- YouTube download MP3 {{{ + +ytdl-mp3(){ + if [ $# -lt 1 ]; then + echo -e "This uses youtube-dl to download a music video from youtube" + echo -e "and then convert it to an mp3 file." + echo -e " " + echo -e "\n\nUsage:\n$0 " + echo -e "\nExample:\n$0 input.file\n" + return 1 + fi + + YTrequest $1 ; + +} +# }}} +########################################################### +########################################################### +#-------- Convert to Audio {{{ +#------------------------------------------------------ +# https://trac.ffmpeg.org/wiki/Encode/MP3 +# https://trac.ffmpeg.org/wiki/Encode/AAC +# https://trac.ffmpeg.org/wiki/TheoraVorbisEncodingGuide + +convert2audio_mp3() { + if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.m4a" + echo -e "\nmultiple: $0 file1.m4a file2.m4a file3.m4a" + echo -e "\nwildcard: $0 *.m4a" + return 1 + fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-audiotrack.mp3 ] + do + ffmpeg -i "$arg" -codec:a libmp3lame -qscale:a 2 "${arg%.*}"-audiotrack.mp3 + done + done +} + +convert2audio_m4a() { + if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.mp3" + echo -e "\nmultiple: $0 file1.mp3 file2.mp3 file3.mp3" + echo -e "\nwildcard: $0 *.mp3" + return 1 + fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-audiotrack.m4a ] + do + ffmpeg -i "$arg" -codec:a aac -qscale:a 6 -strict experimental "${arg%.*}"-audiotrack.m4a + done + done +} +convert2audio_ogg() { + if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.mp3" + echo -e "\nmultiple: $0 file1.mp3 file2.mp3 file3.mp3" + echo -e "\nwildcard: $0 *.mp3" + return 1 + fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-audiotrack.ogg ] + do + ffmpeg -i "$arg" -codec:a libvorbis -qscale:a 5 -vn "${arg%.*}"-audiotrack.ogg + done + done +} + +convert2audio_wav() { + if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.mp3" + echo -e "\nmultiple: $0 file1.mp3 file2.mp3 file3.mp3" + echo -e "\nwildcard: $0 *.mp3" + return 1 + fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-audiotrack.wav ] + do + ffmpeg -i "$arg" "${arg%.*}"-audiotrack.wav + done + done +} + +convert2audio_webm() { + if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.mp3" + echo -e "\nmultiple: $0 file1.mp3 file2.mp3 file3.mp3" + echo -e "\nwildcard: $0 *.mp3" + return 1 + fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-audiotrack.webm ] + do + ffmpeg -i "$arg" -codec:a libvorbis -qscale:a 5 -vn "${arg%.*}"-audiotrack.webm + done + done +} + +convert2audio_wavmono() { + if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.mp3" + echo -e "\nmultiple: $0 file1.mp3 file2.mp3 file3.mp3" + echo -e "\nwildcard: $0 *.mp3" + return 1 + fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-monoaudiotrack.wav ] + do + ffmpeg -i "$arg" -codec:a pcm_mulaw -ar 8000 -ac 1 "${arg%.*}"-monoaudiotrack.wav + done + done +} + +convert2audio_wma() { +if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.mp3" + echo -e "\nmultiple: $0 file1.mp3 file2.mp3 file3.mp3" + echo -e "\nwildcard: $0 *.mp3" + return 1 +fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-audiotrack.wma ] + do + ffmpeg -i "$arg" -codec:a wmav2 -b:a 128k "${arg%.*}"-audiotrack.wma + done + done +} + +# }}} +########################################################### +#-------- Convert to Audio {{{ +#------------------------------------------------------ +# https://trac.ffmpeg.org/wiki/Encode/MP3 +# https://trac.ffmpeg.org/wiki/Encode/AAC +# https://trac.ffmpeg.org/wiki/TheoraVorbisEncodingGuide + +convert2audio_mp3() { + if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.m4a" + echo -e "\nmultiple: $0 file1.m4a file2.m4a file3.m4a" + echo -e "\nwildcard: $0 *.m4a" + return 1 + fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-audiotrack.mp3 ] + do + ffmpeg -i "$arg" -codec:a libmp3lame -qscale:a 2 "${arg%.*}"-audiotrack.mp3 + done + done +} + +convert2audio_m4a() { + if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.mp3" + echo -e "\nmultiple: $0 file1.mp3 file2.mp3 file3.mp3" + echo -e "\nwildcard: $0 *.mp3" + return 1 + fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-audiotrack.m4a ] + do + ffmpeg -i "$arg" -codec:a aac -qscale:a 6 -strict experimental "${arg%.*}"-audiotrack.m4a + done + done +} +convert2audio_ogg() { + if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.mp3" + echo -e "\nmultiple: $0 file1.mp3 file2.mp3 file3.mp3" + echo -e "\nwildcard: $0 *.mp3" + return 1 + fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-audiotrack.ogg ] + do + ffmpeg -i "$arg" -codec:a libvorbis -qscale:a 5 -vn "${arg%.*}"-audiotrack.ogg + done + done +} + +convert2audio_wav() { + if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.mp3" + echo -e "\nmultiple: $0 file1.mp3 file2.mp3 file3.mp3" + echo -e "\nwildcard: $0 *.mp3" + return 1 + fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-audiotrack.wav ] + do + ffmpeg -i "$arg" "${arg%.*}"-audiotrack.wav + done + done +} + +convert2audio_webm() { + if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.mp3" + echo -e "\nmultiple: $0 file1.mp3 file2.mp3 file3.mp3" + echo -e "\nwildcard: $0 *.mp3" + return 1 + fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-audiotrack.webm ] + do + ffmpeg -i "$arg" -codec:a libvorbis -qscale:a 5 -vn "${arg%.*}"-audiotrack.webm + done + done +} + +convert2audio_wavmono() { + if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.mp3" + echo -e "\nmultiple: $0 file1.mp3 file2.mp3 file3.mp3" + echo -e "\nwildcard: $0 *.mp3" + return 1 + fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-monoaudiotrack.wav ] + do + ffmpeg -i "$arg" -codec:a pcm_mulaw -ar 8000 -ac 1 "${arg%.*}"-monoaudiotrack.wav + done + done +} + +convert2audio_wma() { +if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.mp3" + echo -e "\nmultiple: $0 file1.mp3 file2.mp3 file3.mp3" + echo -e "\nwildcard: $0 *.mp3" + return 1 +fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-audiotrack.wma ] + do + ffmpeg -i "$arg" -codec:a wmav2 -b:a 128k "${arg%.*}"-audiotrack.wma + done + done +} + +flac2mp3(){ +for a in ./*.flac; do + < /dev/null ffmpeg -i "$a" -qscale:a 0 "${a[@]/%flac/mp3}" +done +} +# }}} +########################################################### +#-------- Simple HTTP Server {{{ +#------------------------------------------------------ +# DEMO: http://www.youtube.com/watch?v=FFIjMYzkHhc +# DESC: python http server, host files and folders + +SimpleHTTPserver() { + if which python2 >/dev/null; then + python2 -m SimpleHTTPServer "${1:-8000}" + else + python3 -m http.server "${1:-8000}" + fi +} +#}}} +########################################################### +#-------- Kiwix Server {{{ +#------------------------------------------------------ +# DEMO: https://www.youtube.com/watch?v=267WxnPEckM&t=81s +# DESC: kiwix-serve -- Offline Wiki Viewer - Linux WEBUI + +offlinewiki-daemon() { kiwix-serve --port 49849 --daemon /MacOSX-Data1/Computing/wiki/*.zim ; } +offlinewiki-quit() { kill $(ps -ef | grep -i '[K]iwix-serve' | awk '{print $2}') ;} + +#}}} +########################################################### +#-------- Bluetooth Headset {{{ +bt-st() { systemctl status -l bluetooth; } +bt-up() { sudo systemctl start bluetooth; } +bt-re() { sudo systemctl restart bluetooth; } +bt-dn() { sudo systemctl stop bluetooth; } +betron-on() { ${HOME}/bin/scripts/expect/bt-on-Betron.exp ;} +betron-off() { ${HOME}/bin/scripts/expect/bt-off-Betron.exp ;} +jvc-on() { ${HOME}/bin/scripts/expect/bt-on-JVC.exp ;} +jvc-off() { ${HOME}/bin/scripts/expect/bt-off-JVC.exp ;} +qy7-on() { ${HOME}/bin/scripts/expect/bt-on-QY7.exp ;} +qy7-off() { ${HOME}/bin/scripts/expect/bt-off-QY7.exp ;} +pb-on() { ${HOME}/bin/scripts/expect/bt-on-PocketBoom.exp ;} +pb-off() { ${HOME}/bin/scripts/expect/bt-off-PocketBoom.exp ;} +ssx-on() { ${HOME}/bin/scripts/expect/bt-on-ssx.exp ;} +ssx-off() { ${HOME}/bin/scripts/expect/bt-off-ssx.exp ;} +xg5-on() { ${HOME}/bin/scripts/expect/bt-on-xg5.exp ;} +xg5-off() { ${HOME}/bin/scripts/expect/bt-off-xg5.exp ;} +# }}} +########################################################### +#-------- Wget Batch Retrieve Files From The Web {{{ +## http://stackoverflow.com/a/18709707 +#-------------------------------------- +wget-ext-url() { + if [ $# -lt 2 ]; then + echo -e "Download all extension on a webpage" + echo -e "\nUsage: $0 " + echo -e "\nExample: $0 mp3 http://example.com/files/" + echo -e "\nGoogle: http://lmgtfy.com/?q=intitle%3Aindex.of+mp3+-html+-htm+-php+-asp+-txt+-pls+madonna" + return 1 + fi + + savepath=~/Downloads + outputdir_name=$(echo "$2" | rev | cut -d\/ -f2 | rev) + + mkdir -pv "$savepath/$outputdir_name" + cd "$savepath/$outputdir_name" && wget -r -l1 -H -t1 -nd -N -np -A "$1" -erobots=off "$2" +} +# }}} +########################################################### +#-------- Fuzzy Finder {{{ +#------------------------------------------------------ +# DEMO: https://www.youtube.com/playlist?list=PLqv94xWU9zZ2fMsMMDF4PjtNHCeBFbggD +# DESC: interactive fuzzy string matching +# URL: https://github.com/junegunn/fzf +# +fzf-dmenu() { + # note: xdg-open has a bug with .desktop files, so we cant use that + selected="$(ls /usr/share/applications | fzf -e -i )" + nohup `grep '^Exec' "/usr/share/applications/$selected" | tail -1 | sed 's/^Exec=//' | sed 's/%.//'` >/dev/null 2>&1& + # disown if exit 0 successfully + if [[ $? = 0 ]] ; then disown; fi +}; +zle -N fzf_dmenu; bindkey -s '^O' "fzf-dmenu\n" +# +fzf-surfraw() { sr "$(cat ~/.config/surfraw/bookmarks | sed '/^$/d' | sort -n | fzf -e -i )" ;} +zle -N fzf-surfraw; bindkey -s '^B' "fzf-surfraw\n" + +# +fzf-locate() { + xdg-open "$(locate "*" | fzf -e -i )" + +# # some programs require a longer time to load + sleep 1.5 +# +# # if cancel or fail then exit + if [ $? -ne 0 ] + then + exit + fi +} +# ZSH keybinding example; ~/.zshrc + +fzf_history() { zle -I; eval $(history | fzf +s | sed 's/ *[0-9]* *//') ; }; zle -N fzf_history; bindkey '^F' fzf_history + +fzf_killps() { zle -I; ps -ef | sed 1d | fzf -m | awk '{print $2}' | xargs kill -${1:-9} ; }; zle -N fzf_killps; bindkey '^Q' fzf_killps + +fzf_cd() { zle -I; DIR=$(find ${1:-*} -path '*/\.*' -prune -o -type d -print 2> /dev/null | fzf) && cd "$DIR" ; }; zle -N fzf_cd; bindkey '^E' fzf_cd + + +# +#fzf-playonlinux() { playonlinux --run '$(ls ~/.PlayOnLinux/shortcuts | fzf -e -i )' ;} +# +## http://www.reddit.com/r/commandline/comments/3abtup/fzfr_fzf_bash_function/ +#fzfr() { fzf -m -x | xargs -d'\n' -r "$@" ; } +# +## edit single line snippet +cfg-snippetrc() { $EDITOR ~/.snippetrc ;} +cfg-multisnippetrc() { $EDITOR ~/.multisnippet/"$(ls ~/.multisnippet | fzf -e -i)" ;} +multisnippet() { $EDITOR ~/.multisnippet/"$1" ;} +fzf-snippet() { + selected="$(cat ~/.snippetrc | sed '/^$/d' | sort -n | fzf -e -i )" + # remove tags, leading and trailing spaces, also no newline + echo "$selected" | sed -e s/\;\;\.\*\$// | sed 's/^[ \t]*//;s/[ \t]*$//' | tr -d '\n' | xclip -selection clipboard +} +fzf-multisnippet() { + # location of snippets + dir=~/.multisnippet + + # merge filename and tags into single line + results=$(for FILE in $dir/* + do + getname=$(basename $FILE) + gettags=$(head -n 1 $FILE) + echo "$getname \t $gettags" + done) + + # copy content into clipboard without tags + filename=$(echo "$(echo $results | fzf -e -i )" | cut -d' ' -f 1) + sed 1d $dir/$filename | xclip -selection clipboard +} +fzf_open() { + fd -t f -H -I | fzf -m --preview="xdg-mime query default {}" | xargs - ro -d "\n" xdg-open 2>&- + } +cd_with_fzf() { + cd $HOME && cd "$(fd -t d -t l | fzf --preview="tree -L 1 {}" --bind="space:toggle-preview" --preview-window=:hidden)" && echo "$PWD" && tree -L 2 } + +##}}} +########################################################### +#-------- Task Spooler {{{ +# TestFunc TS queue +tsp-output_header(){ + echo "Running $0"; + echo "$1 arguments...." ; +} +tsp-ytdl() { + + case $# in + 0) TS_SOCKET=/tmp/youtube-dl ts ;; + 1) case $1 in + "-C") TS_SOCKET=/tmp/youtube-dl ts -C ;; + "-r") TS_SOCKET=/tmp/youtube-dl ts -r ;; + "-o") TS_SOCKET=/tmp/youtube-dl ts -o ;; + "-f") TS_SOCKET=/tmp/youtube-dl ts youtube-dl -f $1 $2 $3 ;; + *) TS_SOCKET=/tmp/youtube-dl ts youtube-dl $1 ;; + esac ;; + 2) TS_SOCKET=/tmp/youtube-dl ts $* ;; + esac +} +# Youtube-dl TS queue +tsp-ytdl.orig() { + if [ $# -lt 1 ] ; then + echo "Running $0" + TS_SOCKET=/tmp/youtube-dl ts ; + else + if [[ "$1" == "-C" ]] ; then + TS_SOCKET=/tmp/youtube-dl ts -C ; + else + TS_SOCKET=/tmp/youtube-dl ts youtube-dl $1 ; + fi + fi +} +# MPV TS queue +tsp-mpv() { + if [ $# -lt 1 ] ; then + TS_SOCKET=/tmp/mpv-q ts ; + else + if [ "$1" == "-C" ] ; then + TS_SOCKET=/tmp/mpv-q ts -C ; + else + TS_SOCKET=/tmp/mpv-q ts mpv $1 ; + fi + fi +} +# }}} +########################################################### +#-------- Sci-Hub {{{ +# Sci-Hub download + +shdl(){ curl -O $(curl -s http://sci-hub.tw/"$@" | grep location.href | grep -o http.*pdf); } + +# }}} +########################################################### +#-------- BibTex Functions {{{ +#doi2bib(){ + #echo >> bib.bib; + #curl -s "http://api.crossref.org/works/$1/transform/application/x-bibtex" >> bib.bib; + #echo >> bib.bib; +#} +# }}} +########################################################### +#-------- fast-p {{{ +# Quickly find and open a pdf among a collection of thousands of unsorted pdfs through fzf +# https://github.com/bellecp/fast-p + +p() { + open=xdg-open + ag -U -g ".pdf$" \ + | fast-p \ + | fzf --read0 --reverse -e -d $'\t' \ + --preview-window down:80% --preview ' + v=$(echo {q} | tr " " "|"); + echo -e {1}"\n"{2} | grep -E "^|$v" -i --color=always; + ' \ + | cut -z -f 1 -d $'\t' | tr -d '\n' | xargs -r --null $open > /dev/null 2> /dev/null + } + +# }}} +########################################################### + +############################## +####### B. WAITING LIST ###### +############################## + +########################################################### +#-------- FFMPEG X11GRAB Screencasting {{{ +#------------------------------------------------------ +# record desktop using ffmpeg +# tutorial video: http://www.youtube.com/watch?v=mNz5Lrc06_s +# http://ubuntuforums.org/showthread.php?t=1392026 +# https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu +# https://trac.ffmpeg.org/wiki/Capture/ALSA +# https://trac.ffmpeg.org/wiki/Capture/Desktop +# http://nowardev.wordpress.com/2011/05/23/how-to-screencast/ +# https://dl.dropboxusercontent.com/u/28788188/cast.sh (Xpander69) +# https://www.youtube.com/watch?v=mEV2O8C272g +# https://github.com/gotbletu/wikimd/blob/master/ffmpeg-compile.md + +# ffmpeg location +# FF_RECORDER=/usr/bin/ffmpeg +#FF_RECORDER=~/Compile/ffmpeg/bin/ffmpeg + +# use "arecord -l" or "arecord -L" to find mic +# pavucontrol if using pulseaudio +# FF_MIC=pulse +# FF_MIC=hw:4,0 +#FF_MIC=front:CARD=Snowball + +# scale down resolution if needed +# ${FF_SCALE[*]} +# FF_SCALE=(-vf scale=1280:720) + + +#FF_OUTPUT_MOVIE=~/Public/screencast/mm_movie_baking.mkv +#FF_OUTPUT_VIDEO=~/Public/screencast/vv_video_baking.mkv +#FF_OUTPUT_AUDIO=~/Public/screencast/aa_audio_baking.mp3 + +# movie = video and audio +# videotrack = video only +# audiotrack = audio only +#ffcast_fullscreen_movie() { +# $FF_RECORDER -f alsa -ac 1 -i $FF_MIC -async 1 -f x11grab -r 30 \ +#-s $(xwininfo -root | grep 'geometry' |awk '{print $2;}' | cut -d\+ -f1) \ +#-i :0.0 -vcodec libx264 -pix_fmt yuv444p -preset ultrafast -crf 0 \ +#-acodec libmp3lame -ab 320k -threads 0 -y $FF_OUTPUT_MOVIE +# + +#ffcast_fullscreen_videotrack() { +# $FF_RECORDER -f x11grab -r 30 \ +#-s $(xwininfo -root | grep 'geometry' |awk '{print $2;}' | cut -d\+ -f1) \ +#-i :0.0 -vcodec libx264 -pix_fmt yuv444p -preset ultrafast -crf 0 \ +#-threads 0 -y $FF_OUTPUT_VIDEO +# + +#ffcast_audiotrack() { +# $FF_RECORDER -f alsa -ac 1 -i $FF_MIC \ +#-acodec libmp3lame -ab 320k \ +#-threads 0 -y $FF_OUTPUT_AUDIO +# + +# single window: select a window with mouse cursor to record +#ffcast_window_movie() { +# INFO=$(xwininfo -frame) +#WIN_GEO=$(echo $INFO | grep -oEe 'geometry [0-9]+x[0-9]+' | grep -oEe '[0-9]+x[0-9]+') +#WIN_XY=$(echo $INFO | grep -oEe 'Corners:\s+\+[0-9]+\+[0-9]+' | grep -oEe '[0-9]+\+[0-9]+' | sed -e 's/\+/,/' ) + +# $FF_RECORDER -f alsa -ac 1 -i $FF_MIC -async 1 -f x11grab -r 30 \ +#-s $WIN_GEO -i :0.0+$WIN_XY -vcodec libx264 -pix_fmt yuv444p \ +#-preset ultrafast -crf 0 -acodec libmp3lame -ab 320k \ +#-threads 0 -y $FF_OUTPUT_MOVIE +# + +#ffcast_window_videotrack() { +# INFO=$(xwininfo -frame) +#WIN_GEO=$(echo $INFO | grep -oEe 'geometry [0-9]+x[0-9]+' | grep -oEe '[0-9]+x[0-9]+') +#WIN_XY=$(echo $INFO | grep -oEe 'Corners:\s+\+[0-9]+\+[0-9]+' | grep -oEe '[0-9]+\+[0-9]+' | sed -e 's/\+/,/' ) + +# $FF_RECORDER -f x11grab -r 30 \ +#-s $WIN_GEO -i :0.0+$WIN_XY -vcodec libx264 -pix_fmt yuv444p \ +#-preset ultrafast -crf 0 \ +#-threads 0 -y $FF_OUTPUT_VIDEO +# + + +# example references +# worked well on ffmpeg 0.11.1 +# ffmpeg -f pulse -ac 1 -i hw:3,0 -async 1 -f x11grab -r 30 -s $(xwininfo -root | grep 'geometry' |awk '{print $2;}' | cut -d\+ -f1) -i :0.0 -vcodec libx264 -pix_fmt yuv444p -preset ultrafast -crf 0 -acodec libmp3lame -ab 128k -threads 0 -y ~/Public/screencast/aa_screencast_baking.mkv + +# --- }}} +########################################################### +#-------- FFMPEG X11GRAB Screencasting v2 (Multiple Inputs) {{{ +#------------------------------------------------------ +# DESC: record desktop using ffmpeg X11grab + +# REFF: +# MrWhat record mic & speakers: https://www.youtube.com/watch?v=mEV2O8C272g +# MrWhat keep audio sync: https://www.youtube.com/watch?v=Xbzh-T2kfJk +# https://ask.fedoraproject.org/en/question/65662/recording-audio-from-mic-and-speakers-from-commandline/ + +# list all audio sources +pa-sources() { pactl list sources | awk '/Source #/ ||/Name:/ || /Description:/ || /Sample Specification:/' ;} + +# ffmpeg location +# FFX_RECORDER=/usr/bin/ffmpeg +#FFX_RECORDER=~/Compile/ffmpeg/bin/ffmpeg +# FFX_RECORDER=/usr/bin/avconv + +# speakers audio source (PC speakers or Headphones) +# note: using headphones since pc speakers will have audio feedback to mic +# FFX_SPEAKER="alsa_output.pci-0000_00_14.2.analog-stereo.monitor" +# FFX_SPEAKER_CH="2" +# FFX_SPEAKER_FREQ="44100" +#FFX_SPEAKER="alsa_output.usb-NA_Lenovo_Wireless_Headset_W770-00.analog-stereo.monitor" +#FFX_SPEAKER_CH="2" +#FFX_SPEAKER_FREQ="32000" + +# mic audio source +# note: when routed to pulseaudio the mic is very low +# so open pavucontrol > input device > [name of mic] +# then slide volume all the way to the right +# example: http://i.imgur.com/GFkifqB.png +#FFX_MIC="alsa_input.usb-BLUE_MICROPHONES_Blue_Snowball-00.analog-mono" +#FFX_MIC_CH="1" +#FFX_MIC_FREQ="44100" + +# sound system +#FFX_SOUNDSYS="pulse" +# FFX_SOUNDSYS="alsa" + +# resolution +#FFX_RESO_FULL=$(xwininfo -root | grep 'geometry' |awk '{print $2;}' | cut -d\+ -f1) + +# output location +#FFX_OUTPUT_MOVIE=~/Public/screencast/mm_movie_baking.mkv +#FFX_OUTPUT_VIDEO=~/Public/screencast/vv_video_baking.mkv +#FFX_OUTPUT_AUDIO=~/Public/screencast/aa_audio_baking.mp3 + +#ffxcast_fullscreen_movie() { +# $FFX_RECORDER \ +#-f $FFX_SOUNDSYS -ac $FFX_SPEAKER_CH -ar $FFX_SPEAKER_FREQ -i $FFX_SPEAKER \ +#-f $FFX_SOUNDSYS -ac $FFX_MIC_CH -ar $FFX_MIC_FREQ -i $FFX_MIC \ +#-f x11grab -r 30 -s $FFX_RESO_FULL -i :0.0 \ +#-filter_complex \ +#"[0]asyncts[spkr], \ +#[1]asyncts[mic], \ +#[spkr][mic]amix=inputs=2" \ +#-c:v libx264 -pix_fmt yuv420p -preset ultrafast -crf 0 \ +#-c:a libmp3lame -ac 2 -ar 44100 -b:a 320k \ +#-y $FFX_OUTPUT_MOVIE +# +# +## -vcodec libx264 -pix_fmt yuv444p -preset ultrafast -crf 0 \ +## -acodec libmp3lame -ab 128k -ar 44100 -threads 0 -y $FF_OUTPUT_MOVIE +# +## ffmpeg \ +## -f pulse -ac 2 -ar 44100 -i alsa_input.usb-BLUE_MICROPHONE_Blue_Snow­ball_201306-00-Snowball.analog-stereo \ +## -f pulse -ac 2 -ar 44100 -i alsa_output.pci-0000_00_1b.0.analog-ster­eo.monitor \ +## -f pulse -ac 2 -ar 44100 -i alsa_output.usb-Logitech_Inc_Logitech_US­B_Headset_H540_00000000-00-H540.iec958-s­tereo.monitor \ +## -f x11grab -framerate 30 -video_size 1920x1080 -i :0 \ +## -filter_complex \ +## "[0]asyncts[m], \ +## [1]asyncts[d], \ +## [2]asyncts[h], \ +## [m][d][h]amix=inputs=3" \ +## -c:v libx264 -preset veryfast -crf 18 -pix_fmt yuv420p \ +## -c:a libmp3lame -ac 2 -ar 44100 -b:a 320k \ +## /home/b/Videos/AudioSync/AsyncTS_20150206.mkv +# +## different PRESET +## 1. -c:v libx264 -preset ultrafast -crf 18: Produced a 120.9 MB file at ~34-48% CPU load +## 2. -c:v libx264 -preset superfast -crf 18: Produced a 40.4 MB file at ~48-53% CPU load +## 3. -c:v libx264 -preset veryfast -crf 18: Produced a 26.1 MB file at ~62-78% CPU load +# +## different CRF +## 1. -c:v libx264 -preset ultrafast -crf 0 (Lossless): Produced a 471.7 MB file at ~32-50% CPU load +## 2. -c:v libx264 -preset ultrafast -crf 18: Produced a 120.9 MB file at ~34-48% CPU load +## 3. -c:v libx264 -preset ultrafast -crf 23: Produced a 67.1 MB file at ~32-45% CPU load +## 4. -c:v libx264 -preset ultrafast -crf 28: Produced a 31.1 MB file at ~30-40% CPU load +# +## image quality each setting produces (images are zoomed to in 285%) +## https://imgur.com/XF6t2Cv +# +# +## }}} +########################################################### +##-------- Alias Custom {{{ +##------------------------------------------------------ +## alias ps="ps aux | grep -v grep | grep " +#alias t="todo.sh" +#alias f="find . |grep " +#alias p="ps aux |grep " +## alias o="xdg-open " +# +## For emergencies +#alias asdf='setxkbmap fr bepo' +# +alias xclipin='xclip -sel c -in <' +alias xclipout='xclip -sel c -out >' +alias ..="cd .." +alias ...="cd ../.." +alias ....="cd ../../.." +alias .....="cd ../../../.." +alias ......="cd ../../../../.." +alias empty='gvfs-trash --empty' # empty trash globally (all partitions) +alias garbage='gvfs-trash -f' +alias garbage-list='gvfs-ls -h trash://' +alias garbage-empty='gvfs-trash --empty' # empty trash globally (all partitions) +alias psg='ps aux|grep -v grep|grep -i ' +psgrep() { ps axuf | grep -v grep | grep "$@" -i --color=auto; } +alias sshxforwarding='ssh -XCc blowfish-cbc,arcfour' +alias sshxtrusted='ssh -Y' +alias stackexchange='lynx http://column80.com' # lookup information +alias trash='trash-put -v' +alias xev-keycode="xev | grep 'keycode\|button'" +alias weechat='weechat-curses' +alias lsd='ls -1d */' # ls folders only +alias l='ls -l' +alias lsf='ls --color=always -p | grep -v '/$'' # ls files only +alias lsa='ls -GghA' +alias lsx='ls -lX' +## list and grep +lsg() { + keyword=$(echo "$@" | sed 's/ /.*/g') + ls -GgthrA | grep -iE $keyword +} +# +## ls recent items at bottom with green TODAY yellow YESTERDAY substituted +## https://www.reddit.com/r/archlinux/comments/41s1w4/what_is_your_favorite_one_liner_to_use/cz50y1m +lst() { + ls -vAFq --color=yes -got --si --time-style=long-iso "$@" \ + | sed "s/$(date +%Y-%m-%d)/\x1b[32m TODAY\x1b[m/;s/$(date +'%Y-%m-%d' -d yesterday)/\x1b[33m YESTERDAY\x1b[m/" | tac +} +## alias lst='ls -Ggthrc' # ls by time/changes, newest at bottom +# +# +# +## }}} +########################################################### +##-------- Functions {{{ +##------------------------------------------------------ +# +################################################################################ +## IPlayer +## +################################################################################ +# +#gip-setplayer() { export PLAYER="$1" ;} +#gip-cbbc() { get_iplayer --stream --type=livetv "CBBC" --player="$PLAYER -" ;} +#gip-cbbs() { get_iplayer --stream --type=livetv "CBeebies" --player="$PLAYER -" ;} +#gip-bbcn() { get_iplayer --stream --type=livetv "BBC News" --player="$PLAYER -" ;} +#gip-bbc1() { get_iplayer --stream --type=livetv "BBC One" --player="$PLAYER -" ;} +#gip-bbc2() { get_iplayer --stream --type=livetv "BBC Two" --player="$PLAYER -" ;} +#gip-bbc3() { get_iplayer --stream --type=livetv "BBC Three" --player="$PLAYER -" ;} +#gip-bbc4() { get_iplayer --stream --type=livetv "BBC Four" --player="$PLAYER -" ;} +#gip-bbcr1x() { get_iplayer --stream --type=liveradio "BBC 1xtra" --player="$PLAYER -" ;} +#gip-bbcr1() { get_iplayer --stream --type=liveradio "BBC Radio 1" --player="$PLAYER -" ;} +#gip-bbcr2() { get_iplayer --stream --type=liveradio "BBC Radio 2" --player="$PLAYER -" ;} +#gip-bbcr3() { get_iplayer --stream --type=liveradio "BBC Radio 3" --player="$PLAYER -" ;} +#gip-bbcr4() { get_iplayer --stream --type=liveradio "BBC Radio 4 FM" --player="$PLAYER -" ;} +#gip-bbcr4x() { get_iplayer --stream --type=liveradio "BBC Radio 4 Extra" --player="$PLAYER -" ;} +#gip-bbcr5() { get_iplayer --stream --type=liveradio "BBC Radio 5 live" --player="$PLAYER -" ;} +#gip-bbcr5x() { get_iplayer --stream --type=liveradio "BBC 5 live Sports Extra" --player="$PLAYER -" ;} +# +#unlock() { keepassc -d ~/.keepass/masterlock.kdb ;} +# +#mkdircd() { mkdir -p -v $1; cd $1 ;} # create folder then cd into it +#cpbak() { cp $1{,.bak} ;} # create backup copy +#open() { xdg-open "$@" > /dev/null 2>&1 ;} # open gui apps w/o error msg +#nohup-command() { nohup "$@" >/dev/null 2>&1& } #background a process w/o error msg +#update-grub() { sudo grub-mkconfig -o /boot/grub/grub.cfg ;} +#grub-list() { +# RED='\033[0;31m' +# sudo grep "menuentry '" /boot/grub/grub.cfg | less -N +# echo -e "${RED} REMINDER: GRUB number starts at zero not one" +#} +# +# +## color the manpages +## tutorial video: http://www.youtube.com/watch?v=9BFaLAa428k +## https://wiki.archlinux.org/index.php/Man_page#Colored_man_pages +#man() { +# env LESS_TERMCAP_mb=$'\E[01;31m' \ +# LESS_TERMCAP_md=$'\E[01;31m' \ +# LESS_TERMCAP_me=$'\E[0m' \ +# LESS_TERMCAP_se=$'\E[0m' \ +# LESS_TERMCAP_so=$'\E[01;44;33m' \ +# LESS_TERMCAP_ue=$'\E[0m' \ +# LESS_TERMCAP_us=$'\E[01;32m' \ +# man "$@" +#} +# +## view markdown as manpages +## http://blog.metamatt.com/blog/2013/01/09/previewing-markdown-files-from-the-terminal/ +mdless(){ pandoc -s -f markdown -t man "$*" | groff -T utf8 -man | less ;} +## view markdown within lynx +## https://tosbourn.com/view-markdown-files-terminal/ +#rmd(){ pandoc "$*" | lynx -stdin ;} +## view markdown within w3m +rmd(){ pandoc "$*" | w3m -T text/html ;} +# +## quickly cd out of directories using numbers, example: up 2 +up() { local x='';for i in $(seq ${1:-1});do x="$x../"; done;cd $x; } +# +## list all file access permission +#lsp() { stat --format "%a %n" * ;} +# +## show file access permission +## http://unix.stackexchange.com/a/46921 +#file-permission() { stat --format '%a %n' "$@" ;} +# +## display mime of file application/zip, application/x-tar +#file-type() { file --mime-type -b "$@" ;} +# +# call vim help page from shell prompt +function :h { vim +":h $1" +'wincmd o' +'nnoremap q :q!' ;} +# +# call vim Info page from shell prompt +function viminfo () { vim -c "Info $1" -c "bdelete 1"; } +alias info=viminfo +# +## searches for manual locally or online +#manned() { +# for arg in "$@"; do man $arg 2> /dev/null \ +# || $arg -H 2> /dev/null || $arg -h 2> /dev/null \ +# || $arg --help-all 2> /dev/null || $arg --help 2> /dev/null \ +# || help $arg 2> /dev/null \ +# || $BROWSERCLI "http://manned.org/browse/search?q=$@" 2> /dev/null \ +# || $BROWSER "http://manned.org/browse/search?q=$@" 2> /dev/null \ +# || open "http://manned.org/browse/search?q=$@" 2> /dev/null \ +# || xdg-open "http://manned.org/browse/search?q=$@" +# done +#} +# +## python calculator +## press Ctrl+D to quit +## http://docs.python.org/library/math.html +## tutorial video: http://www.youtube.com/watch?v=JkyodHenTuc +#calc() { +# if which python2 >/dev/null; then +# python2 -ic "from __future__ import division; from math import *; from random import *" +# else +# python3 -ic "from math import *; import cmath" +# fi +#} +# +## change font size (guake terminal) +## tutorial video: http://www.youtube.com/watch?v=i9aKFgxOjwQ +chfontsize() { + # guake + gconftool-2 --set '/apps/guake/style/font/style' --type string "Monospace ${1:-16}" +# +# #gnome-terminal +# dconf write /org/gnome/terminal/legacy/profiles:/$(dconf list /org/gnome/terminal/legacy/profiles:/)font "'Monospace ${1:-16}'" +} +# +## Use podboat as download manager + +#podqueue() { + #if [ $# -lt 1 ] + #then + #echo -e "Add links to Podboat, Use Podboat as a TUI Download Manager." + #echo -e "\nUsage: $0 " + #echo -e "\n\nExample:\n$0 http://abcxyz.com/filename.mp3" + #return 1 + #fi + #URL="$1" + #SAVE_PATH="${HOME}/Downloads" + #GET_FILENAME="($(echo $1)" | rev | cut -d\/ -f1 | rev | sed -e 's@\%20@\_@g' )" + #echo "$URL" "$SAVE_PATH/$GET_FILENAME" >> ${HOME}/.newsboat/queue +#} +## search commandlinefu.com + +cmdfu() { curl "http://www.commandlinefu.com/commands/matching/$(echo "$@" \ + | sed 's/ /-/g')/$(echo -n $@ | base64)/plaintext" ;} +# +# +## display one random command from commandlinefu.com +#cmdfu-random() { echo -e "`curl -sL http://www.commandlinefu.com/commands/random/json|sed -re 's/.*,"command":"(.*)","summary":"([^"]+).*/\\x1b[1;32m\2\\n\\n\\x1b[1;33m\1\\x1b[0m/g'`\n" ;} +# +## check if a website is down +## usage: down4me google.com +#down4me() { curl -s "http://www.downforeveryoneorjustme.com/$1" | sed '/just you/!d;s/<[^>]*>//g';} +# +## convert doc/docx to pdf (dont upload sensitive data) +## tutorial video: http://www.youtube.com/watch?v=r90IdQwF-hs +#doc2pdf() { curl -# -F inputDocument=@"$1" http://www.doc2pdf.net/convert/document.pdf > "${1%.*}.pdf" ;} +# +## w3m browser with inline images +## https://plus.google.com/102499719144563443986/posts/Vja8W69iHoi +## tutorial video: http://www.youtube.com/watch?v=R2bMUtCOGko + +w3mimg() { w3m -o imgdisplay=/usr/lib64/w3m/w3mimgdisplay $1 ;} + +# +## mplayer to display webcam +## hit 's' to take screenshot, will save in current folder +## hit 'S' to take series of screenshot, will save in current folder +## hit 'f' to toggle fullscreen +## hit 'T' to toggle stay-on-top +## hit 'q' or 'Esc' to quit +## https://wiki.archlinux.org/index.php/Webcam_Setup#MPlayer +#webcam-list() { v4l2-ctl --list-formats-ext && v4l2-ctl --list-devices ;} +# +#webcam-mplayer() { mplayer tv:// -tv driver=v4l2:width=640:height=360:device=/dev/video0 -fps 30 -vf screenshot -ontop -geometry "99%:95%" ;} +# +#webcam-mplayer-noborder() { mplayer tv:// -tv driver=v4l2:width=640:height=360:device=/dev/video0 -fps 30 -vf screenshot -geometry "98%:98%" -ontop -noborder ;} +# +#webcam-mplayer-screenshot() { mplayer tv:// -tv driver=v4l2:width=1920:height=1080:device=/dev/video0 -fps 30 -vf screenshot -ontop ;} +# +##}}} +########################################################### +##-------- Gotbletu Universal Package Manager {{{ +##------------------------------------------------------ +## DEMO: https://www.youtube.com/watch?v=N8CZhlIssdk +## DESC: auto detect package manager and loads proper alias for it +# +## legends# {{{ +## https://wiki.archlinux.org/index.php/Pacman_Rosetta +## http://old-en.opensuse.org/Software_Management_Command_Line_Comparison +## https://bbs.archlinux.org/viewtopic.php?pid=1281605#p1281605 +## Arch -- pacman, yaourt +## Debian/Ubuntu -- apt-get(apt), aptitude, dpkg +## Gentoo -- eclean, emerge, equery, layman +## OpenSuse -- zypper +## Red Hat/Fedora -- package-cleanup, rpm, yum +## Suse -- rug +## Not finish, only tested on Debian, Arch, Fedora so far +# +## cleanold; removes certain packages that can no longer be downloaded +## cleanall; remove all local cached packages +## list; show the content of an installed package +## localinstall; install package manually such as deb, rpm files downloaded +## own; find a command a package belongs to; ex: pkm-own convert +## purge; uninstall package and purge configuration files (not in /home) +## query; search for an already installed package +## refresh; update repository list +## upgrade; install the newest version from the repositories +## hold/unhold; stop/allow a package from being update +## +## missing +## emerge: autoclean, purge, list, query +## rug: pkm-info, clean, autoremove, autoclean, purge, list, query +## zypper: pkm-info, autoremove, autoclean, purge, list, query +## yum: autoclean, purge +## }}} +# +find_pkm() { for i;do which "$i" >/dev/null && { echo "$i"; return 0;};done;return 1; } +export PKMGR=$(find_pkm yaourt pacman apt-get yum zypper emerge aptitude ) +#export PKMGR=$(find_pkm zypper ) + +# {{{ apt-get +if [ "$PKMGR" = "apt-get" ]; then + pkm-cleanallall() { sudo apt-get clean ;} + pkm-cleanallold() { sudo apt-get autoclean ;} + pkm-dependsreverse() { apt-cache rdepends "$@" ;} + pkm-download() { wget $(apt-get --print-uris -y install "$@" | grep ^\'| cut -d\' -f2) ;} + pkm-extract() { ar vx "$@" | tar -zxvf data.tar.gz ;} + # same as; echo "pkgname hold" | dpkg --set-selections + pkm-hold() { sudo apt-mark hold "$@" ;} + pkm-hold-status() { dpkg --get-selections | awk "/${@:-hold}/" ;} + pkm-info() { apt-cache show "$@" ;} + pkm-install() { sudo apt-get install --no-install-recommends "$@" ;} + pkm-list() { dpkg -L "$@" ;} + pkm-listcache() { ls -1 /var/cache/apt/archives "$@" && \ + echo "pwd: /var/cache/apt/archives" ;} + pkm-localinstall() { sudo dpkg -i "$@" ;} + pkm-own() { dpkg -S $(which "$@") ;} + pkm-pkgsearch() { apt-file search "$@" ;} + pkm-purge() { sudo apt-get purge "$@" ;} + pkm-query() { dpkg --get-selections | grep "$@" ;} + pkm-refresh() { sudo apt-get update ;} + pkm-remove() { sudo apt-get remove "$@" ;} + pkm-remove-orphans() { sudo apt-get autoclean ;} + pkm-search() { apt-cache search "$@" ;} + pkm-unhold() { sudo apt-mark unhold "$@" ;} + pkm-upgrade() { sudo apt-get update && sudo apt-get upgrade ;} + # PPA on ubuntu base distro (not compatible with debian) + ppa-add() { sudo add-apt-repository $@ ;} + ppa-del() { sudo add-apt-repository -r $@ ;} + ppa-key() { sudo apt-key add $@ ;} + ppa-list() { ls /etc/apt/sources.list.d ;} + ppa-purge() { sudo ppa-purge $@ ;} + # auto get missing gpg keys from launchpad + ppa-autokey() { sudo apt-get update 2> /tmp/keymissing; \ + for key in $(grep "NO_PUBKEY" /tmp/keymissing |sed "s/.*NO_PUBKEY //"); \ + do echo -e "\nProcessing key: $key"; gpg --keyserver pool.sks-keyservers.net \ + --recv $key && gpg --export --armor $key | sudo apt-key add -; done ;} + # these are extra servers, just replace it if one is down + # keyserver.ubuntu.com + # pool.sks-keyservers.net + # subkeys.pgp.net + # pgp.mit.edu + # keys.nayr.net + # keys.gnupg.net + # wwwkeys.en.pgp.net #(replace with your country code fr, en, de,etc) + # }}} +# {{{ aptitude +elif [ "$PKMGR" = "aptitude" ]; then + pkm-cleanallall() { sudo aptitude clean ;} + pkm-cleanallold() { sudo aptitude autoclean ;} + pkm-dependsreverse() { aptitude why "$@" ;} + pkm-download() { aptitude download "$@" ;} # need a better 1; deb w/ depends + pkm-extract() { ar vx "$@" | tar -zxvf data.tar.gz ;} + pkm-hold() { echo "$1 hold" | sudo dpkg --set-selections && \ + dpkg --get-selections | awk "/$1/ && /hold/" ;} + pkm-hold-status() { dpkg --get-selections | awk "/${@:-hold}/" ;} + pkm-info() { aptitude show "$@" ;} + pkm-install() { sudo aptitude install --without-recommends "$@" ;} + pkm-list() { dpkg -L "$@" ;} + pkm-listcache() { ls -1 /var/cache/apt/archives "$@" && \ + echo "pwd: /var/cache/apt/archives" ;} + pkm-localinstall() { sudo dpkg -i "$@" ;} + pkm-own() { dpkg -S $(which "$@") ;} + pkm-pkgsearch() { apt-file search "$@" ;} + pkm-purge() { sudo aptitude purge "$@" ;} + pkm-query() { dpkg --get-selections | grep "$@" ;} + pkm-refresh() { sudo aptitude update ;} + pkm-remove() { sudo aptitude remove "$@" ;} + pkm-remove-orphans() { sudo aptitude autoclean ;} + pkm-search() { aptitude search "$*" ;} + # fix maybe with keyword $@ | sed / / ~d/ + pkm-search-description() { aptitude search ~d"$1"~d"$2"~d"$3"~d"$4"~d"$5"~d"$6"~d"$7" ;} + pkm-unhold() { echo "$1 install" | sudo dpkg --set-selections && \ + dpkg --get-selections | awk "/$1/ && /install/" ;} + pkm-upgrade() { sudo aptitude update && sudo aptitude upgrade ;} + # PPA on ubuntu base distro (not compatible with debian) + ppa-add() { sudo add-apt-repository $@ ;} + ppa-del() { sudo add-apt-repository -r $@ ;} + ppa-key() { sudo apt-key add $@ ;} + ppa-list() { ls /etc/apt/sources.list.d ;} + ppa-purge() { sudo ppa-purge $@ ;} + ppa-autokey() { sudo apt-get update 2> /tmp/keymissing; \ + for key in $(grep "NO_PUBKEY" /tmp/keymissing |sed "s/.*NO_PUBKEY //"); \ + do echo -e "\nProcessing key: $key"; gpg --keyserver pool.sks-keyservers.net \ + --recv $key && gpg --export --armor $key | sudo apt-key add -; done ;} +# }}} +# {{{ emerge +elif [ "$PKMGR" = "emerge" ]; then + pkm-remove-orphans() { sudo emerge --depclean ;} + pkm-cleanall() { sudo eclean distfiles ;} + pkm-info() { emerge -S "$@" ;} + pkm-install() { sudo emerge "$@" ;} + pkm-pkgsearch() { equery belongs "$@" ;} + pkm-refresh() { sudo layman -f ;} + pkm-remove() { sudo emerge -C "$@" ;} + pkm-search() { emerge -S "$@" ;} + pkm-upgrade() { sudo emerge -u world ;} +# }}} +# {{{ pacman +elif [ "$PKMGR" = "pacman" ]; then + pkm-build() { tar xvzf "$1" && cd "${1%%.tar.gz}" && makepkg -csi ;} + pkm-cleanall() { sudo pacman -Sc ;} + pkm-cleanold() { sudo pacman -Scc ;} + if type -p downgrade > /dev/null; then + # require: https://aur.archlinux.org/packages/downgrade/ + pkm-downgrade() { downgrade "$@" ;} + fi + pkm-download() { sudo pacman -Sw "$@" ;} + pkm-info() { for arg in "$@"; do + pacman -Qi $arg 2> /dev/null \ + || pacman -Si $arg; done ;} + pkm-install() { sudo pacman -S "$@" ;} + pkm-key() { sudo pacman-key --init \ + && sudo pacman-key --populate archlinux \ + && sudo pacman-key --refresh-keys ;} + pkm-list() { pacman -Qql "$@" ;} + pkm-listinstalled() { pacman -Qe ;} + pkm-listcache() { ls -1 /var/cache/pacman/pkg "$@" && \ + echo "pwd: /var/cache/pacman/pkg" ;} + pkm-localinstall() { sudo pacman --noconfirm -U "$@" ;} + pkm-own() { pacman -Qo "$@" ;} + pkm-pkgsearch() { pkgfile -s "$@" ;} + pkm-purge() { sudo pacman -R "$@" ;} + pkm-query() { pacman -Qqs "$@" ;} + pkm-query-detail() { pacman -Qs "$@" ;} + pkm-refresh() { sudo pacman -Syy ;} + pkm-remove() { sudo pacman -Rcs "$@" ;} + pkm-remove-nodepends() { sudo pacman -Rdd "$@" ;} + pkm-remove-orphans() { sudo pacman -Rs $(pacman -Qqtd) ;} + pkm-search() { pacman -Ss "$@" ;} + pkm-search-local() { pacman -Qs "$@" ;} + pkm-upgrade() { sudo pacman -Syu ;} +# }}} +# {{{ rug +elif [ "$PKMGR" = "rug" ]; then + pkm-install() { sudo rug install "$@" ;} + pkm-refresh() { sudo rug refresh ;} + pkm-remove() { sudo rug remove "$@" ;} + pkm-search() { rug search "$@" ;} + pkm-upgrade() { sudo rug update ;} +# }}} +# {{{ yaourt +elif [ "$PKMGR" = "yaourt" ]; then + pkm-build() { tar xvzf "$1" && cd "${1%%.tar.gz}" && makepkg -csi ;} + pkm-cleanall() { yaourt -Sc ;} + pkm-cleanold() { yaourt -Scc ;} + if type -p downgrade > /dev/null; then + # require: https://aur.archlinux.org/packages/downgrade/ + pkm-downgrade() { downgrade "$@" ;} + fi + pkm-download() { sudo pacman -Sw "$@" ;} # need better shit to dl from aur also + pkm-info() { for arg in "$@"; do + yaourt -Qi $arg 2> /dev/null \ + || yaourt -Si $arg; done ;} + pkm-install() { yaourt --noconfirm -S "$@" ;} + # https://wiki.archlinux.org/index.php/Pacman-key#Resetting_all_the_keys + pkm-key() { sudo pacman-key --init \ + && sudo pacman-key --populate archlinux \ + && sudo pacman-key --refresh-keys ;} + pkm-list() { yaourt -Qql "$@" ;} + pkm-listinstalled() { yaourt -Qe ;} + pkm-listcache() { ls -1 /var/cache/pacman/pkg "$@" && \ + echo "pwd: /var/cache/pacman/pkg" ;} + pkm-localinstall() { sudo pacman --noconfirm -U "$@" ;} + pkm-own() { pacman -Qo "$@" ;} + pkm-pkgsearch() { pkgfile -s "$@" ;} + pkm-purge() { yaourt -R "$@" ;} + pkm-query() { pacman -Qqs "$@" ;} + pkm-query-detail() { yaourt -Qs "$@" ;} + pkm-refresh() { yaourt -Syy ;} + pkm-remove() { yaourt -Rcs "$@" ;} + pkm-remove-nodepends() { yaourt -Rdd "$@" ;} + pkm-remove-orphans() { yaourt -Rs $(pacman -Qqtd) ;} + pkm-search() { yaourt --noconfirm "$@" ;} + pkm-search-local() { yaourt -Qs "$@" ;} + pkm-upgrade() { yaourt -Syu ;} # upgrade everything except aur package + pkm-upgrade-aur() { yaourt --noconfirm -Sbua ;} # only upgrade aur package +# }}} +# {{{ yum +elif [ "$PKMGR" = "yum" ]; then + pkm-cleanall() { sudo yum clean ;} + pkm-depends() { sudo yum deplist "$@" ;} + pkm-dependsreverse() { sudo yum resolvedep "$@" ;} + pkm-info() { for arg in "$@"; do + rpm -qi $arg 2> /dev/null || yum info $arg; done ;} + pkm-install() { sudo yum install "$@" ;} + pkm-list() { for arg in "$@"; do + rpm -ql $arg 2> /dev/null || repoquery -ql --plugins $arg; done ;} + pkm-localinstall() { sudo yum localinstall "$@" ;} + pkm-own() { rpm -qf $(which "$@") ;} + pkm-pkgsearch() { yum whatprovides "$@" ;} + pkm-query() { rpm -q "$@" ;} + pkm-refresh() { sudo yum clean expire-cache && sudo yum check-update ;} + pkm-remove() { sudo yum remove "$@" ;} + pkm-remove-orphans() { sudo package-cleanup --leaves ;} + pkm-search() { yum search "$@" ;} + pkm-upgrade() { sudo yum update ;} +# }}} +# {{{ zypper +elif [ "$PKMGR" = "zypper" ]; then + pkm-cleanall() { sudo zypper clean ;} + pkm-install() { sudo zypper install "$@" ;} + pkm-pkgsearch() { zypper what-provides "$@" ;} + pkm-refresh() { sudo zypper refresh ;} + pkm-remove() { sudo zypper remove "$@" ;} + pkm-search() { zypper search "$@" ;} + pkm-upgrade() { sudo zypper update ;} +fi +# }}} +# +##}}} +########################################################### +##-------- Clipboard and Upload {{{ +##------------------------------------------------------ +## DEMO: http://www.youtube.com/watch?v=fKP0FLp3uW0 (xclip) +## https://www.youtube.com/watch?v=Ww7Sl4d8F8A (pastebinit) +## DESC: copy/paste for linux machines (Mac style) +# +alias pbcopy='xclip -selection clipboard' # copy to clipboard, ctrl+c, ctrl+shift+c +alias pbpaste='xclip -selection clipboard -o' # paste from clipboard, ctrl+v, ctrl+shitt+v +alias pbselect='xclip -selection primary -o' # paste from highlight, middle click, shift+insert +alias pbnoformatting='xclip -selection clipboard -o | xclip -selection clipboard' +# +# +## dump text from clipboard to pastebin server and copy link +#alias pbdumpslexy='pbpaste | pastebinit -b "slexy.org" | pbcopy && echo "URL has been copied to clipboard" && pbpaste' +#alias pbdumpsprungeus="pbpaste | curl -F 'sprunge=<-' http://sprunge.us | pbcopy && echo 'URL has been copied to clipboard' && pbpaste" +#alias pbdumpixio="pbpaste | curl -F 'f:1=<-' ix.io | pbcopy && echo 'URL has been copied to clipboard' && pbpaste" +# +# +#alias pbuploadslexy='pbpaste | pastebinit -b "slexy.org" | pbcopy && echo "URL has been copied to clipboard" && pbpaste' +# +#alias pbuploadsprungeus="cat "$@" | curl -F 'sprunge=<-' http://sprunge.us | pbcopy && echo 'URL has been copied to clipboard' && pbpaste" +#alias pbuploadixio="cat "$1" | curl -F 'f:1=<-' ix.io | pbcopy && echo 'URL has been copied to clipboard' && pbpaste" +# +# +# +## }}} +########################################################### +##-------- Screenshot and Upload {{{ +##------------------------------------------------------ +## DEMO: http://www.youtube.com/watch?v=Hh8G1aBp8gc +## DESC: take screenshot fullscreen, single window or draw a box +#export PATH_SCREENSHOT=~/Pictures/screenshots +#pix() { scrot -d 2 "$PATH_SCREENSHOT/fullscr_`date +'%F_%Hh%Ms%S'`.png" ;} +#pix-area() { sleep 2 && scrot -s "$PATH_SCREENSHOT/windowed_`date +'%F_%Hh%Ms%S'`.png" ;} +# +# +## DEMO: http://www.youtube.com/watch?v=7-9uYSGyvU0 +## DESC: upload to imgur.com +## REFF: http://www.commandlinefu.com/commands/view/9341 +#upl-imgur() { +# curl -\# -F image=@"$1" -F "key=1913b4ac473c692372d108209958fd15" \ +# http://api.imgur.com/2/upload.xml | grep -Eo "(.)*" \ +# | grep -Eo "http://i.imgur.com/[^<]*" +#} +# +## }}} +########################################################### +##-------- Flexget (Torrent RSS) {{{ +##------------------------------------------------------ +## DEMO: http://www.youtube.com/playlist?list=PLqv94xWU9zZ0pVGrgKtMuhFHun8-MahSY +## DESC: auto download torrent similar to how a DVR works +## URL: http://flexget.com/ +# +#alias flexget='$HOME/anaconda2/bin/flexget' +#flexget-list() { flexget series list && flexget movie_list list waiting && flexget movie_list list downloaded ;} +#flexget-check() { flexget check ;} # check if config file has any errors +#flexget-test() { flexget --test execute ;} # dry run +#flexget-execute() { flexget execute ;} +#flexget-cron() { flexget execute --cron ;} # skip writing to logs +#flexget-version() { flexget -V ;} +#flexget-learnall() { flexget execute --learn ;} #bypass dling old torrents +#flexget-add() { flexget movie_list add "$@" ;} +#flexget-del() { flexget movie_list del "$@" ;} +#flexget-forget() { flexget movie_list forget "$@" ;} # allow redownloading on waiting list +# +##}}} +########################################################### +##-------- Convert to Video {{{ +##------------------------------------------------------ +## http://linuxconfig.org/ffmpeg-audio-format-conversions +convert2video_mp4() { + if [ $# -lt 1 ]; then + echo -e "Usage: $0 " + echo -e "\nsingle: $0 file.avi" + echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" + echo -e "\nwildcard: $0 *.avi" + return 1 + fi + + myArray=( "$@" ) + for arg in "${myArray[@]}"; do + while [ ! -f "${arg%.*}"-movie.mp4 ] + do + ffmpeg -i "$arg" -codec:v libx264 -preset medium -crf 22 -codec:a aac -qscale:a 6 -strict experimental "${arg%.*}"-movie.mp4 + done + done +} +# +#convert2video_avi() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.mp4" +# echo -e "\nmultiple: $0 file1.mp4 file2.mp4 file3.mp4" +# echo -e "\nwildcard: $0 *.mp4" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}"-movie.avi ] +# do +# ffmpeg -i "$arg" -codec:v mpeg4 -vtag xvid -qscale:v 3 -codec:a libmp3lame -qscale:a 4 "${arg%.*}"-movie.avi +# done +# done +#} +# +#convert2video_ogv() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}"-movie.ogv ] +# do +# ffmpeg -i "$arg" -codec:v libtheora -qscale:v 7 -codec:a libvorbis -qscale:a 5 "${arg%.*}"-movie.ogv +# done +# done +#} +# +#convert2video_mpg() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}"-movie.mpg ] +# do +# ffmpeg -i "$arg" -codec:v mpeg2video -qscale:v 2 -codec:a mp2 -b:a 192k "${arg%.*}"-movie.mpg +# done +# done +#} +# +#convert2video_mkv() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}"-movie.mkv ] +# do +# ffmpeg -i "$arg" -codec:v libx264 -preset medium -crf 22 -codec:a libvorbis -qscale:a 5 "${arg%.*}"-movie.mkv +# done +# done +#} +# +#convert2video_webm() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}"-movie.webm ] +# do +# ffmpeg -i "$arg" -codec:v libvpx -crf 10 -b:v 1M -codec:a libvorbis "${arg%.*}"-movie.webm +# done +# done +#} +# +## convert video to gif animation +## http://superuser.com/a/730389 +## http://superuser.com/a/841379 +#convert_to_gifv() { +# if [ $# -lt 1 ] +# then +# echo -e "convert video to animated gif" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 file.mkv \n" +# echo -e "$0 file.mkv 320\n" +# echo -e "$0 file.mkv 720\n" +# echo -e "$0 file.mkv 1080\n" +# echo -e "Note: animated gif size are usually x2 or x3 the size of the original video file" +# +# return 1 +# fi +# +# # get video resolution (height) +# eval $(ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width "$1") +# size=${streams_stream_0_height} +# +# ffmpeg -i "$1" -vf scale="${2:-$size}":-1 -r 10 -f image2pipe -vcodec ppm - | convert -delay 5 -loop 0 - "${1%.*}"-gifvid"$2".gif +#} +# +## }}} +########################################################### +##-------- Convert to iOS (iPod, Macs, iPhone, Apple TV) {{{ +##------------------------------------------------------ +## https://trac.handbrake.fr/wiki/BuiltInPresets +# +#convert2iOS_ipod() { +# if [ $# -lt 1 ]; then +# echo -e "HandBrake's low resolution settings for the iPod (5G and up)" +# echo -e "Optimized for great playback on the iPod screen, with smaller file size." +# echo -e "\nUsage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".ipod.mp4 ] +# do +# HandBrakeCLI -i "$arg" -o "${arg%.*}.ipod.mp4" --preset="iPod" +# done +# done +#} +#convert2iOS_universal() { +# if [ $# -lt 1 ]; then +# echo -e "HandBrake's universally compatible, full resolution settings for all current Apple devices: iPod (6G and up), iPhone, AppleTV, and Macs" +# echo -e "\nUsage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".universal.mp4 ] +# do +# HandBrakeCLI -i "$arg" -o "${arg%.*}.universal.mp4" --preset="Universal" +# done +# done +#} +# +#convert2iOS_iphone() { +# if [ $# -lt 1 ]; then +# echo -e "HandBrake's settings for all iPhones and iPod Touches going back to the original iPhone 2G." +# echo -e "\nUsage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".iphone.mp4 ] +# do +# HandBrakeCLI -i "$arg" -o "${arg%.*}.iphone.mp4" --preset="iPhone & iPod touch" +# done +# done +#} +# +#convert2iOS_ipodtouch() { +# if [ $# -lt 1 ]; then +# echo -e "HandBrake's settings for all iPhones and iPod Touches going back to the original iPhone 2G." +# echo -e "\nUsage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".ipodtouch.mp4 ] +# do +# HandBrakeCLI -i "$arg" -o "${arg%.*}.ipodtouch.mp4" --preset="iPhone & iPod touch" +# done +# done +#} +# +#convert2iOS_ipad() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".ipad.mp4 ] +# do +# HandBrakeCLI -i "$arg" -o "${arg%.*}.ipad.mp4" --preset="iPad" +# done +# done +#} +# +#convert2iOS_appletv() { +# if [ $# -lt 1 ]; then +# echo -e "HandBrake's settings for the AppleTV and 2009's iPhone and iPod Touch lineup. Provides a good balance between quality and file size, and pushes the devices to their limits. Includes Dolby Digital 5.1 AC3 sound for the AppleTV." +# echo -e "\nUsage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".appletv.mp4 ] +# do +# HandBrakeCLI -i "$arg" -o "${arg%.*}.appletv.mp4" --preset="AppleTV" +# done +# done +#} +# +#convert2iOS_appletv2() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".appletv2.mp4 ] +# do +# HandBrakeCLI -i "$arg" -o "${arg%.*}.appletv2.mp4" --preset="AppleTV 2" +# done +# done +#} +# +#convert2iOS_appletv3() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".appletv3.mp4 ] +# do +# HandBrakeCLI -i "$arg" -o "${arg%.*}.appletv3.mp4" --preset="AppleTV 3" +# done +# done +#} +# +## }}} +########################################################### +##-------- Convert to Devices (Other, Gaming Device) {{{ +##------------------------------------------------------ +## http://develop.participatoryculture.org/index.php/ConversionMatrix +# +#convert2psp() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".psp.mp4 ] +# do +# ffmpeg -i "$arg" -s 320x240 -b:v 512000 -ar 24000 -ab 64000 -f psp -r 29.97 -strict experimental "${arg%.*}".psp.mp4 +# done +# done +#} +# +#convert2windowsphone8() { +#if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +#fi +# +#myArray=( "$@" ) +#for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".windowsphone8.mp4 ] +# do +# HandBrakeCLI -i "$arg" -o "${arg%.*}.windowsphone8.mp4" --preset="Windows Phone 8" +# done +#done +#} +# +## }}} +########################################################### +##-------- Convert to Archive {{{ +##------------------------------------------------------ +# +## to see required install for different formats +## $ patool formats +#convert2archive_7z() { patool repack "$1" "${1%.*}".7z ;} +#convert2archive_ace() { patool repack "$1" "${1%.*}".ace ;} +#convert2archive_jar() { patool repack "$1" "${1%.*}".jar ;} +#convert2archive_rar() { patool repack "$1" "${1%.*}".rar ;} +#convert2archive_tar() { patool repack "$1" "${1%.*}".tar ;} +#convert2archive_xz() { patool repack "$1" "${1%.*}".xz ;} +#convert2archive_zip() { patool repack "$1" "${1%.*}".zip ;} +#convert2archive_targz() { patool repack "$1" "${1%.*}".tar.gz ;} +#convert2archive_tarbz2() { patool repack "$1" "${1%.*}".tar.bz2 ;} +#convert2archive_tarlzma() { patool repack "$1" "${1%.*}".tar.lzma ;} +# +## https://en.wikipedia.org/wiki/Comic_book_archive +#convert2archive_cbz() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.gz" +# echo -e "\nmultiple: $0 file1.gz file2.gz file3.gz" +# echo -e "\nwildcard: $0 *.gz" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# if [[ ! -f "${arg%.*}".zip && ! -f "${arg%.*}".cbz ]]; then +# patool repack "$arg" "${arg%.*}".zip && mv "${arg%.*}".zip "${arg%.*}".cbz +# else +# if [[ -f "${arg%.*}".zip ]]; then +# mv -v -- "${arg%.*}".zip "${arg%.*}".cbz +# fi +# fi +# done +#} +# +#convert2archive_cb7() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.gz" +# echo -e "\nmultiple: $0 file1.gz file2.gz file3.gz" +# echo -e "\nwildcard: $0 *.gz" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# if [[ ! -f "${arg%.*}".7z && ! -f "${arg%.*}".cb7 ]]; then +# patool repack "$arg" "${arg%.*}".7z && mv "${arg%.*}".7z "${arg%.*}".cb7 +# else +# if [[ -f "${arg%.*}".7z ]]; then +# mv -v -- "${arg%.*}".7z "${arg%.*}".cb7 +# fi +# fi +# done +#} +#convert2archive_cba() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.gz" +# echo -e "\nmultiple: $0 file1.gz file2.gz file3.gz" +# echo -e "\nwildcard: $0 *.gz" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# if [[ ! -f "${arg%.*}".ace && ! -f "${arg%.*}".cba ]]; then +# patool repack "$arg" "${arg%.*}".ace && mv "${arg%.*}".ace "${arg%.*}".cba +# else +# if [[ -f "${arg%.*}".ace ]]; then +# mv -v -- "${arg%.*}".ace "${arg%.*}".cba +# fi +# fi +# done +#} +#convert2archive_cbt() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.gz" +# echo -e "\nmultiple: $0 file1.gz file2.gz file3.gz" +# echo -e "\nwildcard: $0 *.gz" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# if [[ ! -f "${arg%.*}".tar && ! -f "${arg%.*}".cbt ]]; then +# patool repack "$arg" "${arg%.*}".tar && mv "${arg%.*}".tar "${arg%.*}".cbt +# else +# if [[ -f "${arg%.*}".tar ]]; then +# mv -v -- "${arg%.*}".tar "${arg%.*}".cbt +# fi +# fi +# done +#} +#convert2archive_cbr() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.gz" +# echo -e "\nmultiple: $0 file1.gz file2.gz file3.gz" +# echo -e "\nwildcard: $0 *.gz" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# if [[ ! -f "${arg%.*}".rar && ! -f "${arg%.*}".cbr ]]; then +# patool repack "$arg" "${arg%.*}".rar && mv "${arg%.*}".rar "${arg%.*}".cbr +# else +# if [[ -f "${arg%.*}".rar ]]; then +# mv -v -- "${arg%.*}".rar "${arg%.*}".cbr +# fi +# fi +# done +#} +# +## }}} +########################################################### +##-------- VimWiki {{{ +##------------------------------------------------------ +wikimd() { $EDITOR ~/vimwiki/index.md ;} +## }}} +########################################################### +##-------- Slice Videos {{{ +##------------------------------------------------------ +# +## movie = both audio & video +## audiotrack = audio only +## videotrack = video only +# +## mplayer OSD in milliseconds +#mplayer-milliseconds() { mplayer -osd-fractions 1 -osdlevel 3 "$1" -ss "${2:-00:00:00}" ;} +# +#slice_movie() { +# if [ $# -lt 5 ] +# then +# echo -e "Use ffmpeg to slice movie (video & audio tracks) with beginning and endpoint with accurate milliseconds" +# echo -e "\nUsage:\n$0 file hh:mm:ss ms hh:mm:ss ms" +# echo -e "\nexample:\n$0 file.mp4 00:01:00 00 00:05:00 00 \n" +# +# return 1 +# fi +# +# # code +# BEGINTIME=${2} +# ENDTIME=${4} +# +# # Convert the times to seconds from the Epoch +# SEC1=`date +%s -d ${BEGINTIME}` +# SEC2=`date +%s -d ${ENDTIME}` +# +# # Use expr to do the math +# DIFFSEC=`expr ${SEC2} - ${SEC1}` +# DURATIONTIME=`date +%H:%M:%S -ud @${DIFFSEC}` +# +# ffmpeg -i "$1" -ss ${BEGINTIME}."$3" -t ${DURATIONTIME}."$5" -codec:v copy -codec:a copy "${1%.*}"-"$0"-`date +'%F_%Hh%Ms%S'`."${1##*.}" +# +#} +# +#slice_videotrack() { +# if [ $# -lt 5 ] +# then +# echo -e "Use ffmpeg to slice videotrack (no audio) with beginning and endpoint with accurate milliseconds" +# echo -e "\nUsage:\n$0 file hh:mm:ss ms hh:mm:ss ms" +# echo -e "\nexample:\n$0 file.mp4 00:01:00 00 00:05:00 00 \n" +# +# return 1 +# fi +# +# BEGINTIME=${2} +# ENDTIME=${3} +# +# SEC1=`date +%s -d ${BEGINTIME}` +# SEC2=`date +%s -d ${ENDTIME}` +# +# DIFFSEC=`expr ${SEC2} - ${SEC1}` +# DURATIONTIME=`date +%H:%M:%S -ud @${DIFFSEC}` +# +# ffmpeg -i "$1" -ss ${BEGINTIME}."$3" -t ${DURATIONTIME}."$5" -an -codec:v copy "${1%.*}"-"$0"-`date +'%F_%Hh%Ms%S'`."${1##*.}" +# +#} +# +#slice_audiotrack() { +# if [ $# -lt 5 ] +# then +# echo -e "Use ffmpeg to slice audiotrack (no video) with beginning and endpoint with accurate milliseconds" +# echo -e "\nUsage:\n$0 file hh:mm:ss ms hh:mm:ss ms" +# echo -e "\nexample:\n$0 file.mp4 00:01:00 00 00:05:00 00 \n" +# +# return 1 +# fi +# +# BEGINTIME=${2} +# ENDTIME=${3} +# +# SEC1=`date +%s -d ${BEGINTIME}` +# SEC2=`date +%s -d ${ENDTIME}` +# +# DIFFSEC=`expr ${SEC2} - ${SEC1}` +# DURATIONTIME=`date +%H:%M:%S -ud @${DIFFSEC}` +# +# ffmpeg -i "$1" -ss ${BEGINTIME}."$3" -t ${DURATIONTIME}."$5" -vn -codec:a copy "${1%.*}"-"$0"-`date +'%F_%Hh%Ms%S'`."${1##*.}" +#} +# +## }}} +########################################################### +##-------- RipMe CLI (Bulk Image Downloader) {{{ +##------------------------------------------------------ +## image album downloader +## https://github.com/4pr0n/ripme +## CLI options: https://github.com/4pr0n/ripme/wiki/How-To-Run-RipMe +#ripme-cli() { java -jar /usr/share/java/ripme-git-1.2.8.jar -l ~/Downloads -u "$@" ;} +# +## }}} +########################################################### +##-------- Mount Archive (ZIP|RAR|TAR) {{{ +##------------------------------------------------------ +## http://ubuntuforums.org/showthread.php?t=1207096 +#mount-archive() { +# if [ $# -lt 1 ] +# then +# echo -e "mount archive files (zip|rar|tar...etc)" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 file.zip" +# return 1 +# fi +# +# # mount the archive +# gvfs-mount "archive://$( ( echo -n 'file://' ; readlink -f "$1" ; ) | perl -MURI::Escape -lne 'print uri_escape($_)')" +# +# # if mount was sucessful then cd into gvfs dir and ls the mountpoint +# if [ $? -eq 0 ]; then +# cd "/run/user/$(id -u)/gvfs" && ls +# else +# return 1 +# fi +# +#} +#unmount-archive() { +# if [ $# -lt 1 ] +# then +# echo -e "unmount archive files (zip|rar|tar)" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 disc_image.iso" +# echo -e "$0 disc_image.iso disc_image2.bin disc_image3.mdf" +# echo -e "$0 *.iso" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# fuseiso -n -p "$arg" "/tmp/$arg" +# done +# +# # if mount was sucessful then cd and ls the mountpoint +# if [ $? -eq 0 ]; then +# cd "/tmp/$1" && ls +# else +# return 1 +# fi +# +#} +# +#unmount-discimage() { +# if [ $# -lt 1 ] +# then +# echo -e "unmount ISO filesystem images (iso,nrg,bin,mdf,img)" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 disc_image.iso" +# echo -e "$0 disc_image.iso disc_image2.bin" +# echo -e "$0 mount_point1 mount_point2" +# echo -e "cd /tmp && $0 mount_point" +# echo -e "cd /tmp && $0 *.iso" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# fusermount -u "$arg" +# done +#} +## }}} +########################################################### +##-------- Image Resizer (32|96|128|480|600|768|720|960|1080) {{{ +##------------------------------------------------------ +## Resizing Pictures to different resolutions +# +#image-resize-32x32() { +# if [ $# -lt 1 ] +# then +# echo -e "resize pictures to another resolution" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 pic1.png pic2.png pic3.png" +# echo -e "\n$0 *.jpg" +# +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# convert "$arg" -resize 32x32 "${arg%.*}"_32x32_resized."${arg##*.}" +# done +#} +#image-resize-96x96() { +# if [ $# -lt 1 ] +# then +# echo -e "resize pictures to another resolution" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 pic1.png pic2.png pic3.png" +# echo -e "\n$0 *.jpg" +# +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# convert "$arg" -resize 96x96 "${arg%.*}"_96x96_resized."${arg##*.}" +# done +#} +#image-resize-128x128() { +# if [ $# -lt 1 ] +# then +# echo -e "resize pictures to another resolution" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 pic1.png pic2.png pic3.png" +# echo -e "\n$0 *.jpg" +# +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# convert "$arg" -resize 128x128 "${arg%.*}"_128x128_resized."${arg##*.}" +# done +#} +#image-resize-640x480() { +# if [ $# -lt 1 ] +# then +# echo -e "resize pictures to another resolution" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 pic1.png pic2.png pic3.png" +# echo -e "\n$0 *.jpg" +# +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# convert "$arg" -resize 640x480 "${arg%.*}"_640x480_resized."${arg##*.}" +# done +#} +# +#image-resize-800x600() { +# if [ $# -lt 1 ] +# then +# echo -e "resize pictures to another resolution" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 pic1.png pic2.png pic3.png" +# echo -e "\n$0 *.jpg" +# +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# convert "$arg" -resize 800x600 "${arg%.*}"_800x600_resized."${arg##*.}" +# done +#} +# +#image-resize-1024x768() { +# if [ $# -lt 1 ] +# then +# echo -e "resize pictures to another resolution" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 pic1.png pic2.png pic3.png" +# echo -e "\n$0 *.jpg" +# +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# convert "$arg" -resize 1024x768 "${arg%.*}"_1024x768_resized."${arg##*.}" +# done +#} +#image-resize-1280x720() { +# if [ $# -lt 1 ] +# then +# echo -e "resize pictures to another resolution" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 pic1.png pic2.png pic3.png" +# echo -e "\n$0 *.jpg" +# +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# convert "$arg" -resize 1280x720 "${arg%.*}"_1280x720_resized."${arg##*.}" +# done +#} +#image-resize-1280x960() { +# if [ $# -lt 1 ] +# then +# echo -e "resize pictures to another resolution" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 pic1.png pic2.png pic3.png" +# echo -e "\n$0 *.jpg" +# +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# convert "$arg" -resize 1280x960 "${arg%.*}"_1280x960_resized."${arg##*.}" +# done +#} +#image-resize-1920x1080() { +# if [ $# -lt 1 ] +# then +# echo -e "resize pictures to another resolution" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 pic1.png pic2.png pic3.png" +# echo -e "\n$0 *.jpg" +# +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# convert "$arg" -resize 1920x1080 "${arg%.*}"_1920x1080_resized."${arg##*.}" +# done +#} +# +## }}} +########################################################### +# +############################### +######## C. STREAMING MEDIA ### +############################### +## Code that is still useful but I no longer use it, still here for references +# +########################################################### +##-------- Peerflix (Popcorntime CLI) {{{ +##------------------------------------------------------ +## DEMO: https://www.youtube.com/watch?v=NG13yOTPgfY +## URL: https://github.com/saironiq/shellscripts +## DESC: popcorntime from terminal +#PFLIX_PORT=55055 +#peerflix-vlc() { vlc http://localhost:$PFLIX_PORT ;} +#peerflix-mplayer() { mplayer http://localhost:$PFLIX_PORT ;} +# +## }}} +########################################################### +##-------- Play Youtube videos in mplayer {{{ +#yt-mp() { export YTFILE=$1 ;mplayer -fs -cookies -cookies-file /tmp/cookies.txt $(`youtube-dl -g --cookies /tmp/cookies.txt $YTFILE` ) ; unset YTFILE;} +## }}} +########################################################### +##-------- Sopcast CLI v2 (Streaming P2P Videos) {{{ +##------------------------------------------------------ +## DEMO: http://www.youtube.com/watch?v=Dm7cFjhzgHo +## DESC: watch movies/tv shows over p2p +# +## REFF: +## http://www.sopcast.com/chlist.xml +## http://sopcast.ucoz.com +## http://streams.magazinmixt.ro +## google keyword: sop://broker.sopcast +# +## package: +## Archlinux: sopcast ( x64 https://www.archlinux.org/packages/multilib/x86_64/sopcast/) +## Archlinux: sopcast ( x32 https://www.archlinux.org/packages/community/i686/sopcast/) +## Ubuntu/Debian: sp-auth (https://launchpad.net/~jason-scheunemann/+archive/ppa) +# +## choose a player (cvlc is default) +## SP_VIDPLAYER=cvlc +#SP_VIDPLAYER=(cvlc --file-caching=10000) +## SP_VIDPLAYER=vlc +## SP_VIDPLAYER=(vlc --control=lirc) +## SP_VIDPLAYER=mplayer +## SP_VIDPLAYER=(mplayer -cache 1000) +# +## wait X seconds to stabilize channel (make it longer if u got slower connection) +#SP_SLEEP=15 +# +## sopcast port and player port +#SP_LOCAL_PORT=55050 +#SP_PLAYER_PORT=55051 +# +## manually kill sopcast (sometimes it doesnt exit properly and still uses bandwidth in the background) +#sppc-kill() { killall sp-sc ;} +# +## kills existing connection, starts a new connection, sleep X sec to stabilize the stream, waits to player to exit and kill itself +#sppc() { +# killall sp-sc &>/dev/null +# (sp-sc "$1" $SP_LOCAL_PORT $SP_PLAYER_PORT &>/dev/null &) +# sleep $SP_SLEEP +# ($SP_VIDPLAYER http://localhost:$SP_PLAYER_PORT) +# wait +# killall sp-sc +#} +# +##### eng = english, ro = romanian, esp = espanol/spanish +## added on February 06, 2014 +#spp-doc-discovery.eng,ro() { sppc "sop://broker.sopcast.com:3912/256241" ;} +#spp-doc-discoveryid.eng,ro() { sppc "sop://broker.sopcast.com:3912/256244" ;} +#spp-doc-discoveryscience.eng,ro() { sppc "sop://broker.sopcast.com:3912/256243" ;} +#spp-doc-discoveryworld.eng,ro() { sppc "sop://broker.sopcast.com:3912/256242" ;} +#spp-doc-history.eng,ro() { sppc "sop://broker.sopcast.com:3912/253032" ;} +#spp-doc-natgeo.eng,ro() { sppc "sop://broker.sopcast.com:3912/148248" ;} +#spp-doc-natgeowild.eng,ro() { sppc "sop://broker.sopcast.com:3912/253037" ;} +#spp-movie-hbo.eng,ro() { sppc "sop://broker.sopcast.com:3912/148985" ;} +#spp-movie-hbocomedy.eng,ro() { sppc "sop://broker.sopcast.com:3912/149255" ;} +#spp-tv-axn.eng,ro() { sppc "sop://broker.sopcast.com:3912/253035" ;} +#spp-tv-comedycentral.eng,ro() { sppc "sop://151.80.76.190:3912/253470" ;} +#spp-tv-foxsports2.eng,ro() { sppc "sop://124.232.150.188:3920/5730" ;} +# +##}}} +########################################################### +##-------- MPS-Youtube Channels {{{ +##------------------------------------------------------ +# tutorial video: https://www.youtube.com/watch?v=VE2iCBkIs8E +mps-d() { mpsyt dlurl $1 ; } +mps-p() { mpsyt dvpl $1 ; } + +mpsyt-collider-movietalk() { mpsyt pl "https://www.youtube.com/playlist?list=PLayt6616lBcmbuEa2cRW7Xe4_NrnVrxXn" ;} +mpsyt-collider-jedicouncil() { mpsyt pl "https://www.youtube.com/playlist?list=PLayt6616lBcnqEWU6U0D8I95SUiqVU3DR" ;} +mpsyt-collider-heroes() { mpsyt pl "https://www.youtube.com/playlist?list=PLayt6616lBcnaH7ltMEq0h8jBlfU79kwg" ;} +mpsyt-collider-mailbag() { mpsyt pl "https://www.youtube.com/playlist?list=PLayt6616lBcnuYS9PZhp3jgOSlb9BzaKs" ;} +mpsyt-collider-spoilers() { mpsyt pl "https://www.youtube.com/playlist?list=PLayt6616lBclxpYg1JdmqUYQnKCCiPcPd" ;} +mpsyt-collider-arrow() { mpsyt pl "https://www.youtube.com/playlist?list=PLayt6616lBcleKplDKkFuxLrcL9-7Gw8T" ;} +mpsyt-collider-flash() { mpsyt pl "https://www.youtube.com/playlist?list=PLayt6616lBcmOgOIwVNJV0G6YerPH_Fhp" ;} +mpsyt-collider-starwarsrebels() { mpsyt pl "https://www.youtube.com/playlist?list=PLayt6616lBckZWQgRqTXB2CYRdzNuhBJX" ;} +mpsyt-collider-walkingdead() { mpsyt pl "https://www.youtube.com/playlist?list=PLayt6616lBckJSHjt2QlwJ91YmNb_oH7k" ;} +mpsyt-amc-spoilers() { mpsyt pl "https://www.youtube.com/playlist?list=PLYNW0PN4_jrrILuvfws1zYComnO5n4nmJ" ;} +mpsyt-afterbuzz-arrowaftershow() { mpsyt pl PL6THzna6gLceNeZoXKUOoDeO7cwI57rJn ;} +mpsyt-afterbuzz-flash() { mpsyt pl "https://www.youtube.com/playlist?list=PL6THzna6gLcdfHMhXnGy-O0kS0q-muucC" ;} +mpsyt-afterbuzz-gameofthrones() { mpsyt pl PL0404DAD1AD037666 ;} +mpsyt-thestreamtv-arrow() { mpsyt pl "https://www.youtube.com/playlist?list=PLgh_e6sv2kpr40BXrvZ2qONoSlxFspXGK" ;} +mpsyt-thestreamtv-flash() { mpsyt pl "https://www.youtube.com/playlist?list=PLgh_e6sv2kprr9KHr94poccrwkAILkCcU" ;} +mpsyt-btt-beyondthetrailer() { mpsyt user beyondthetrailer ;} +mpsyt-btt-thinkabouttheink() { mpsyt user thinkabouttheink ;} +mpsyt-movie-watchmojo() { mpsyt user watchmojo ;} +mpsyt-movie-robertjones() { mpsyt user owiseone1 ;} +mpsyt-comic-variantcomics() { mpsyt user VariantComics ;} +mpsyt-tv-emergencyawesome() { mpsyt user emergencyawesome ;} +mpsyt-greatmilitarybattles() { mpsyt user greatmilitarybattles ;} +mpsyt-greentvgreentv() { mpsyt user greentvgreentv ;} +mpsyt-homeorganizing() { mpsyt user homeorganizing ;} +mpsyt-hak5(){ mpsyt user hak5 ;} +mpsyt-linux-linuxgamecast() { mpsyt user linuxgamecast ;} +mpsyt-linux-jupiterbroadcasting() { mpsyt user jupiterbroadcasting ;} +mpsyt-midwaysimplicity() { mpsyt user midwaysimplicity ;} +mpsyt-midwaysimplicity-mtohami() { mpsyt user mtohami ;} +mpsyt-minimalism-carriesimple() { mpsyt user UCtauuxrTG1yon8CNsgqhDkg ;} +mpsyt-minimalism-discernmylife() { mpsyt user UCJPp8gkjxH4T3A8rYO1S52A ;} +mpsyt-minimalism-poetskinny() { mpsyt user UC4O0Vd3UxFXGX-UQNelwTag ;} +mpsyt-minimalism-ticoandtina() { mpsyt user ticoandtina ;} +mpsyt-minimalism-unconventionalliving() { mpsyt user UC7uuFb0QztC-yC2CrcS-lJw ;} +mpsyt-minimalism-zenminimalism() { mpsyt user UCpD5Hqe60AJ79fupvuA6F1Q ;} +mpsyt-mma-arielhelwani() { mpsyt user arielhelwani ;} +mpsyt-mma-fueltv() { mpsyt user fueltv ;} +mpsyt-mma-gracieacademy() { mpsyt user gracieacademy ;} +mpsyt-mma-graciebreakdown() { mpsyt user graciebreakdown ;} +mpsyt-mma-karynbryant() { mpsyt user karynbryant ;} +mpsyt-mma-mmaheat() { mpsyt user mmaheat ;} +mpsyt-mma-mmafightingonsbn() { mpsyt user mmafightingonsbn ;} +mpsyt-mma-thefightnetwork() { mpsyt user thefightnetwork ;} +mpsyt-mma-themmanuts() { mpsyt user themmanuts ;} +mpsyt-mma-ufc() { mpsyt user ufc ;} +mpsyt-mma-uncutsports() { mpsyt user uncutsports ;} +mpsyt-movie-cinefix() { mpsyt user CineFix ;} +mpsyt-peakmoment() { mpsyt user peakmoment ;} +mpsyt-poetskinny() { mpsyt user poetskinny ;} +mpsyt-poetskinnyUnleashed() { mpsyt user PoetskinnyUnleashed ;} +mpsyt-tinyhouse-kirstendirksen() { mpsyt user kirstendirksen ;} +mpsyt-tinyhouse-livingbigtinyhouse() { mpsyt user livingbigtinyhouse ;} +mpsyt-tinyhouse-relaxshacksDOTcom() { mpsyt user relaxshacksDOTcom ;} +mpsyt-tinyhouse-tinyhousegj() { mpsyt user tinyhousegj ;} +mpsyt-tmw-askhodgetwins() { mpsyt user askhodgetwins ;} +mpsyt-tmw-fastingtwins() { mpsyt user fastingtwins ;} +mpsyt-tmw-getfit4women() { mpsyt user getfit4women ;} +mpsyt-tmw-hodgetwins() { mpsyt user hodgetwins ;} +mpsyt-tmw-hodgetwinsonsports() { mpsyt user hodgetwinsonsports ;} +mpsyt-tmw-twinmuscleworkout() { mpsyt user twinmuscleworkout ;} +mpsyt-vanlife-christravels() { mpsyt user tylerdurdeno9 ;} +mpsyt-vanlife-exploringalternatives() { mpsyt user explorealternatives ;} +mpsyt-vanlife-noellemarie() { mpsyt user noellemarie42 ;} +mpsyt-vanlife-happilyhouseless() { mpsyt user TheNomadicvanman ;} +mpsyt-vanlife-justincredible() { mpsyt user JustinCredibleTV ;} +mpsyt-vanlife-nomadicfanatic() { mpsyt user nomadicfanatic ;} +mpsyt-walkingdead() { mpsyt pl "http://www.youtube.com/playlist?list=PLC7EC9FB2E211A261" ;} +mpsyt-walkingdead-talkingdead() { mpsyt pl "http://www.youtube.com/playlist?list=PLP63B9XPsQt3H_5xGXifFxFJE7-RsKFb6" ;} +mpsyt-walkingdead-webisodes() { mpsyt pl "http://www.youtube.com/playlist?list=PLC09448134D906619" ;} +mpsyt-wwefannation() { mpsyt user wwefannation ;} +# +## }}} +########################################################### +##-------- Youtube Viewer Channels {{{ +##------------------------------------------------------ +## tutorial video: http://www.youtube.com/watch?v=FnJ67oAxVQ4 +## watch/login/comment/search/download...etc video on youtube, all from cli +## https://github.com/trizen/youtube-viewer +#yt-listen() { youtube-viewer -n $@ ;} # no video, music/audio only +#yt-music() { youtube-viewer -n --category=Music --top ;} # show top music list +#yts-movie-movieclipstrailer() { youtube-viewer -u UCi8e0iOVk1fEOogdfu4YgfA ;} +#yts-amcmovietalk() { youtube-viewer -p PLBFB97E5B9494EEBD ;} +#yts-amcmovietalk-mailbag() { youtube-viewer -p PLYNW0PN4_jrqlBqzAVRv3rfpo6nhzJnKp ;} +#yts-amctheatres() { youtube-viewer -u amctheatres ;} +#yts-afterbuzz-arrowaftershow() { youtube-viewer -p PL6THzna6gLceNeZoXKUOoDeO7cwI57rJn ;} +#yts-afterbuzz-gameofthrones() { youtube-viewer -p PL0404DAD1AD037666 ;} +#yts-afterbuzz-revolution() { youtube-viewer -p PL6THzna6gLccSY_0Cmoy6DvfH0iC8fyLR ;} +#yts-btt-beyondthetrailer() { youtube-viewer -u beyondthetrailer ;} +#yts-btt-thinkabouttheink() { youtube-viewer -u thinkabouttheink ;} +#yts-comic-watchmojo() { youtube-viewer -u watchmojo ;} +#yts-game-cinemassacre() { youtube-viewer -u cinemassacre ;} +#yts-game-craigslistgamefinds() { youtube-viewer -u craigslistgamefinds ;} +#yts-game-happyconsolegamer() { youtube-viewer -u happyconsolegamer ;} +#yts-game-jamesnintendonerd() { youtube-viewer -u jamesnintendonerd ;} +#yts-game-metaljesusrocks() { youtube-viewer -u metaljesusrocks ;} +#yts-game-mcfrosticles() { youtube-viewer -u mcfrosticles ;} +#yts-game-seejayare() { youtube-viewer -u SeeJayAre ;} +#yts-game-retroliberty() { youtube-viewer -u retroliberty ;} +#yts-greatmilitarybattles() { youtube-viewer -u greatmilitarybattles ;} +#yts-greentvgreentv() { youtube-viewer -u greentvgreentv ;} +#yts-homeorganizing() { youtube-viewer -u homeorganizing ;} +#yts-linuxgamecast() { youtube-viewer -u linuxgamecast ;} +#yts-jupiterbroadcasting() { youtube-viewer -u jupiterbroadcasting ;} +#yts-minimalism-carriesimple() { youtube-viewer -u UCtauuxrTG1yon8CNsgqhDkg ;} +#yts-minimalism-poetskinny() { youtube-viewer -u UC4O0Vd3UxFXGX-UQNelwTag ;} +#yts-minimalism-ticoandtina() { youtube-viewer -u ticoandtina ;} +#yts-minimalism-unconventionalliving() { youtube-viewer -u UC7uuFb0QztC-yC2CrcS-lJw ;} +#yts-minimalism-zenminimalism() { youtube-viewer -u UCpD5Hqe60AJ79fupvuA6F1Q ;} +#yts-midwaysimplicity() { youtube-viewer -u midwaysimplicity ;} +#yts-midwaysimplicity-mtohami() { youtube-viewer -u mtohami ;} +#yts-mma-arielhelwani() { youtube-viewer -u arielhelwani ;} +#yts-mma-fueltv() { youtube-viewer -u fueltv ;} +#yts-mma-gracieacademy() { youtube-viewer -u gracieacademy ;} +#yts-mma-graciebreakdown() { youtube-viewer -u graciebreakdown ;} +#yts-mma-karynbryant() { youtube-viewer -u karynbryant ;} +#yts-mma-mmaheat() { youtube-viewer -u mmaheat ;} +#yts-mma-mmafightingonsbn() { youtube-viewer -u mmafightingonsbn ;} +#yts-mma-thefightnetwork() { youtube-viewer -u thefightnetwork ;} +#yts-mma-themmanuts() { youtube-viewer -u themmanuts ;} +#yts-mma-ufc() { youtube-viewer -u ufc ;} +#yts-mma-uncutsports() { youtube-viewer -u uncutsports ;} +#yts-peakmoment() { youtube-viewer -u peakmoment ;} +#yts-poetskinny() { youtube-viewer -u poetskinny ;} +#yts-poetskinnyunleashed() { youtube-viewer -u PoetskinnyUnleashed ;} +#yts-tinyhouse-kirstendirksen() { youtube-viewer -u kirstendirksen ;} +#yts-tinyhouse-livingbigtinyhouse() { youtube-viewer -u livingbigtinyhouse ;} +#yts-tinyhouse-relaxshacksDOTcom() { youtube-viewer -u relaxshacksDOTcom ;} +#yts-tinyhouse-tinyhousegj() { youtube-viewer -u tinyhousegj ;} +#yts-tmw-askhodgetwins() { youtube-viewer -u askhodgetwins ;} +#yts-tmw-fastingtwins() { youtube-viewer -u fastingtwins ;} +#yts-tmw-getfit4women() { youtube-viewer -u getfit4women ;} +#yts-tmw-hodgetwins() { youtube-viewer -u hodgetwins ;} +#yts-tmw-hodgetwinsonsports() { youtube-viewer -u hodgetwinsonsports ;} +#yts-tmw-twinmuscleworkout() { youtube-viewer -u twinmuscleworkout ;} +#yts-vanlife-christravels() { youtube-viewer -u tylerdurdeno9 ;} +#yts-vanlife-happilyhouseless() { youtube-viewer -u TheNomadicvanman ;} +#yts-vanlife-justincredible() { youtube-viewer -u JustinCredibleTV ;} +#yts-walkingdead() { youtube-viewer -p PLC7EC9FB2E211A261 ;} +#yts-walkingdead-talkingdead() { youtube-viewer -p PLP63B9XPsQt3H_5xGXifFxFJE7-RsKFb6 ;} +#yts-walkingdead-webisodes() { youtube-viewer -p PLC09448134D906619 ;} +#yts-wwefannation() { youtube-viewer -u wwefannation ;} +### }}} +########################################################### +##-------- NVLC Podcast RSS {{{ +##------------------------------------------------------ +## DEMO: https://www.youtube.com/watch?v=7y_58wpHuFE +## DESC: play local and internet media using ncurses VLC +# +#nvlc-player() { nvlc ${1:-cdda://} ;} # other cdrom; cdda:///dev/cdrom ; cdda:///dev/sr0 ; cdda:///dev/sr1 +#nvlc-podcast() { nvlc -S podcast --podcast-urls "$@" ;} +#podcast-nba-shaq() { nvlc-podcast "http://www.podcastone.com/podcast?categoryID2=779" ;} +#podcast-mma-mmahour() { nvlc-podcast "http://feeds.feedburner.com/aol/fanhouse/mmahour/audio?format=xml" ;} +#podcast-mma-mmabeat() { nvlc-podcast "http://feeds.podtrac.com/ZGWlPI2WWyVk" ;} +#podcast-mma-mmajunkie() { nvlc-podcast "http://feeds.feedburner.com/MMAjunkieRadio?format=xml" ;} +#podcast-mma-mmaproradio() { nvlc-podcast "http://feeds.feedburner.com/ProMmaRadio" ;} +#podcast-mma-chaelsonnen() { nvlc-podcast "http://feeds.feedburner.com/YoureWelcomeWithChaelSonnen?format=xml" ;} +#podcast-mma-mmareport() { nvlc-podcast "http://staticv3.fightnetwork.com/xml/itunes_mma.rss" ;} +#podcast-mma-joerogan() { nvlc-podcast "http://joeroganexp.joerogan.libsynpro.com/rss" ;} +#podcast-wwf-stonecold() { nvlc-podcast "http://www.podcastone.com/podcast?categoryID2=436" ;} +#podcast-wwf-chrisjericho() { nvlc-podcast "http://www.podcastone.com/podcast?categoryID2=593" ;} +#podcast-wwf-liveaudiowrestling() { nvlc-podcast "http://staticv3.fightnetwork.com/xml/itunes_law.rss" ;} +#podcast-wwf-solomonster() { nvlc-podcast "http://solomonster.podbean.com/feed/" ;} +#podcast-wwf-bookert() { nvlc-podcast "https://api.radio.com/v2/podcast/rss/1240?format=MP3_128K" ;} +#podcast-movie-schmoesknow() { nvlc-podcast "http://feeds.feedburner.com/SchmoesKnowMoviesPodcast" ;} +#podcast-movie-dcmovienews() { nvlc-podcast "http://popcorntalknetwork.com/category/shows/dc-movie-news-podcast/feed/" ;} +#podcast-fitness-jillianmichaels() { nvlc-podcast "http://feeds.sideshownetwork.tv/JillianMichaels" ;} +#podcast-talk-jessahinton() { nvlc-podcast "http://www.podcastone.com/podcast?categoryID2=797" ;} +#podcast-talk-emilymorse() { nvlc-podcast "http://feeds.feedburner.com/SexWithEmily" ;} +#podcast-talk-lorasomoza() { nvlc-podcast "https://s3.amazonaws.com/betweenthesheetswithlora/feeds/betweenthesheetsrss.xml" ;} +#podcast-starwars-farfaraway() { nvlc-podcast "http://geeknation.com/podcast-feed/far-far-away/" ;} +#podcast-linux-thirdworldlinux() { nvlc-podcast "http://feeds.feedburner.com/thirdworldlinuxogg" ;} +#podcast-linux-linuxactionshow() { nvlc-podcast "http://feeds.feedburner.com/TheLinuxActionShowOGG" ;} +#podcast-linux-linuxunplugged() { nvlc-podcast "http://feeds.feedburner.com/linuxunogg" ;} +#podcast-linux-techtalktoday() { nvlc-podcast "http://feedpress.me/t3ogg" ;} +#podcast-linux-everydaylinux() { nvlc-podcast "http://elementopie.com/feeds/everydaylinux/feed.xml" ;} +#podcast-linux-goinglinux() { nvlc-podcast "http://goinglinux.com/oggpodcast.xml" ;} +#podcast-linux-hackerpublicradio() { nvlc-podcast "http://hackerpublicradio.org/hpr_total_ogg_rss.php" ;} +#podcast-science-nprradiolab() { nvlc-podcast "http://feeds.wnyc.org/radiolab" ;} +#podcast-science-startalk() { nvlc-podcast "http://feeds.soundcloud.com/users/soundcloud:users:38128127/sounds.rss" ;} +#podcast-science-thisweekinscience() { nvlc-podcast "http://feeds.feedburner.com/twis/science/" ;} +# +##}}} +########################################################### +##-------- Internet Music {{{ +## URL: http://whatnotlinux.blogspot.com/2013/02/somafm-and-digitally-imported-bash.html +#somafm() { +#while true; do local station;echo "Select a station to listen to:";select station in "Doomed" "Groove Salad" "Lush" "Suburbs of Goa" "Secret Agent" "Drone Zone" "Space Station" "cliqhop idm" "Digitalis" "Sonic Universe" "Boot Liquor" "Covers" "Illinois Street Lounge" "indie pop rocks" "PopTron" "Tags Trip" "Beat Bender" "Mission Control";do station=$(echo -n "$station"|tr '[:upper:]' '[:lower:]'|sed 's/ //g');break;done; mplayer -playlist http://somafm.com/startstream=${station}.pls; done; +#} +# +#difm() { +#while true; do local station;echo "Select a station to listen to:";select station in "trance" "vocaltrance" "electro" "chillout" "eurodance" "house" "soulfulhouse" "funkyhouse" "tribalhouse" "harddance" "minimal" "techno" "progressive" "goapsy" "hardstyle" "hardcore" "djmixes" "lounge" "drumandbass" "classictechno" "ambient" "breaks" "futuresynthpop";do station=$(echo -n "$station"|tr '[:upper:]' '[:lower:]'|sed 's/ //g');break;done; mplayer -playlist http://www.di.fm/mp3/${station}.pls; done; +#} +# +##}}} +########################################################### +# +############################### +######## D. OBSOLETE LIST ##### +############################### +## Code that is still useful but I no longer use it, still here for references +# +########################################################### +##-------- Recordmydesktop CLI {{{ +##------------------------------------------------------ +## http://www.pclinuxos.com/forum/index.php/topic,97181.msg822796.html#msg822796 +## Screen capture software +## Ctrl+C Stop +## Ctrl+C x2 Cancle rendering +## BUG: RMD Adjusted recording window, which cuts 10 pixel from the height, thus we have to use offset -x -y +## https://wiki.archlinux.org/index.php/RecordMyDesktop +## http://sourceforge.net/p/recordmydesktop/discussion/590957/thread/cf788e96/ +## https://groups.google.com/forum/#!topic/linux.debian.bugs.dist/reE8_9fqqAw +## native reso 1680x1050 -- > rmd reso 1080x1040, offset y axis -y 6 +## SOUND LAG? lower the freq; 45000, 44100, 22050 +## http://www.kkoncepts.net/blog/fixing-out-sync-audio-and-video-ffmpeg +#RMD_OUTPUT=~/Public/screencast/rr_movie_baking.ogv +# +## Frequency; lower to fix sound lag; 45000, 44100, 22050 +#RMD_FREQ=22050 +# +## Frames per second +#RMD_FPS=30 +# +## Channel (mono = 1 ; dual = 2) +#RMD_CHANNELS=1 +# +## SoundCard (pulse for pulseaudio; install pavucontrol to change pulse settings) +## hw:0,1 for directly communicating with your soundcard +## to get a list of sound device: +## arecord -l +## aplay -l +## cat /proc/asound/pcm +## alsamixer and hit F6 +## FF_SOUNDCARD=pulse +## FF_SOUNDCARD=hw:0,1 +#RMD_SOUNDCARD=hw:3,0 +# +#rmd-all() { recordmydesktop --no-wm-check --no-frame --full-shots --fps $RMD_FPS --channels $RMD_CHANNELS --device $RMD_SOUNDCARD --freq $RMD_FREQ --overwrite -o $RMD_OUTPUT ;} +# +## Benq Monitor; 1680x1050 (make sure 2nd monitor is higher res) +## Initial recording window is set to: +## X:0 Y:0 Width:1680 Height:1050 +## Adjusted recording window is set to: +## X:0 Y:0 Width:1680 Height:1056 +#rmd-benq() { recordmydesktop --no-wm-check --no-frame --full-shots --width 1680 --height 1050 --fps $RMD_FPS --channels $RMD_CHANNELS --device $RMD_SOUNDCARD --freq $RMD_FREQ --overwrite -o $RMD_OUTPUT ;} +# +# +## ProscanTV; 1920x1080 --> 1920x1072 ; X offset by 1680 +## Initial recording window is set to: +## X:0 Y:0 Width:1920 Height:1080 +## Adjusted recording window is set to: +## X:0 Y:4 Width:1920 Height:1072 +#rmd-proscantv() { recordmydesktop --no-wm-check --no-frame --full-shots -x 1680 --width 1920 --height 1072 --fps $RMD_FPS --channels $RMD_CHAN --device $RMD_DEV --freq $RMD_FREQ --overwrite -o $RMD_OUTPUT ;} +# +## Examples +## select window +## E1: (select window); recordmydesktop --no-frame --full-shots --fps 30 --channels 2 --freq 44100 --windowid $(xwininfo | awk '/Window id:/ {print $4}') --overwrite -o out.ogv ;} +## E2: recordmydesktop --no-wm-check --no-frame --width 1680 --height 1050 --fps 30 --channels 1 --device hw:3,0 --freq 44100 --overwrite -o out.ogv ;} +##E3: (fullscreen); recordmydesktop --no-frame --full-shots --fps 30 --channels 2 --freq 44100 --overwrite -o out.ogv ;} +# +##}}} +########################################################### +##-------- Air Comic Server # {{{ +##------------------------------------------------------ +## tutorial Video: http://www.youtube.com/watch?v=YceW_VcGA4A +## http://gnomewarrior32.blogspot.kr/2013/03/air-comic-server-english.html +#ACSJar=~/.scripts/aircomic/AirComicServer.jar +#ACSConf=~/.scripts/aircomic/AirComicServer.xml +# +#cfg-aircomicserver() { $EDITOR $ACSConf ;} +#aircomicserver() { nohup java -jar $ACSJar -c $ACSConf -n >/dev/null 2>&1& } +#aircomicserver-lite() { nohup java -XX:+UseSerialGC -Xms32M -Xminf=5 -Xmaxf=10 -jar $ACSJar -c $ACSConf -n >/dev/null 2>&1& } +#aircomicserver-gui() { nohup java -XX:+UseSerialGC -Xms32M -Xminf=5 -Xmaxf=10 -jar $ACSJar -c $ACSConf >/dev/null 2>&1& } +#aircomicserver-quit() { kill $(ps -ef | grep '[A]irComicServer.jar' | awk '{print $2}') ;} +## }}} +########################################################### +##-------- Cherry Music Server # {{{ +##------------------------------------------------------ +## tutorial Video: https://www.youtube.com/watch?v=X2goFerMJDY +# +#BIN_CHERRYMUSIC=~/.scripts/cherrymusic/cherrymusic +#cherrymusic() { nohup python $BIN_CHERRYMUSIC --port 8442 >/dev/null 2>&1& } +#cherrymusic-setup() { python $BIN_CHERRYMUSIC --setup --port 8442 ;} +#cherrymusic-quit() { kill $(ps -ef | grep -i '[C]herrymusic' | awk '{print $2}') ;} +#cfg-cherrymusic() { $EDITOR ~/.config/cherrymusic/cherrymusic.conf ;} +# +## }}} +########################################################### +##-------- Sharelin (Gnutella2 P2P Downloader) {{{ +##------------------------------------------------------ +# +## tutorial video: https://www.youtube.com/watch?v=Yi3JKyL-hxk +#sharelin-daemon() { sharelin -d ;} +#sharelin-quit() { killall sharelin ;} +# +## }}} +########################################################### +##-------- Aria2c WebUI {{{ +##------------------------------------------------------ +## downloader for torrents, magnet links, http, ftp, metalinks +## tutorial video: https://www.youtube.com/watch?v=LCr_0zFcbaM +#alias magnet-to-torrent="aria2c -q --bt-metadata-only --bt-save-metadata" +#aria2c-quit() { +# killall aria2c +# kill $(ps -ef | grep '[h]ttp.server' | awk '{print $2}') +# #kill $(ps -ef | grep '[S]impleHTTPServer' | awk '{print $2}') +#} +# +#aria2c-webui() { +# # download location +# DIR_DL=~/Downloads +# +# # run as daemon +# aria2c --enable-rpc --rpc-listen-all -D -d "$DIR_DL" +# +# +# # use python simplehttpserver to host the webui +# # this avoids download the index.html file on each computer +# # https://github.com/ziahamza/webui-aria2 +# +# # path to the webui index.html +# DIR_WEBUI=~/.scripts/webui-aria2/ +# +# # webui-aria2c uses port 6800 so we use 6801 for python_simple_http_server +# PORT=6801 +# cd "$DIR_WEBUI" +# nohup python3 -m http.server "$PORT" >/dev/null 2>&1& +# +# # for older distro +# # nohup python2 -m SimpleHTTPServer "$PORT" >/dev/null 2>&1& +# +# echo "connect via http://localhost:$PORT or http://ip_address_of_server:$PORT" +#} +# +## }}} +########################################################### +##-------- iPod 5G Device {{{ +##------------------------------------------------------ +## convert to ipod 5g compatible video format +## tutorial video: http://www.youtube.com/watch?v=gVVeR9KizBk +# +#ipod5g() { HandBrakeCLI -i "$1" -o "${1%.*}.ipod5g.mp4" --preset="iPod" ;} +#ipod5g-tsp() { tsp HandBrakeCLI -i "$1" -o "${1%.*}.ipod5g.mp4" --preset="iPod" ;} +#ipod5g-rsync() { +## https://gist.github.com/nekobato/5998548 +## including trailing slashes on $SRC +## rsync $SRC/Music/ $DEST/media/Ipod +#rsync -avrm --delete-excluded --modify-window=2 --include '*/' --include '*.mp3' --exclude '*' "$1" "$2" +#} +# +#tsp-handbrake-normal() { tsp HandBrakeCLI -i "$1" -o "${1%.*}.normal.mp4" --preset="Normal" ;} +#tsp-handbrake-high() { tsp HandBrakeCLI -i "$1" -o "${1%.*}.high.mp4" --preset="High Profile" ;} +# +## }}} +########################################################### +##-------- Spell Checking / Translation Related {{{ +##------------------------------------------------------ +## spell checking +## tutorial video: http://www.youtube.com/watch?v=UEwz5eeaZzc +#check-word() { echo "$1" | aspell -a ;} +#check-list() { cat "$1" | aspell list ;} +#check-file() { aspell check "$1" ;} +# +##}}} +########################################################### +##-------- i3 / Openbox {{{ +##------------------------------------------------------ +## wallpaper path +# +# +#setwallpaper() { +#ConnectedMonitor="$(xrandr | awk '/ connected/ {print $1}' | head -n 1)" +#PATH_WALLPAPER=~/Pictures/Wallpapers +# +# # find current running windows manager +# CURRENT_WM="$(wmctrl -m | grep "Name:" | awk '{print $2}')" +# +# # mate +# if [ $CURRENT_WM = Marco ]; then +# gsettings set org.mate.background picture-filename "$(find $PATH_WALLPAPER -type f -iregex '.*\.\(bmp\|gif\|jpg\|png\)$' | shuf -n1)" +# fi +# +# # xfce +# # tutorial video: http://www.youtube.com/watch?v=tL9uVT8D6k4 +# if [[ $DESKTOP_SESSION = Xfwm4 ]] || [[ $DESKTOP_SESSION = "Xfce Session" ]]; then +# xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor"$ConnectedMonitor"/workspace0/last-image -s "$PWD"/"$1" +# fi +# +# # i3 +# if [ $DESKTOP_SESSION = i3 ]; then +# # feh --randomize --bg-fill "$PATH_WALLPAPER"/* +# feh --randomize --bg-fill "$(find $PATH_WALLPAPER -type f -iregex '.*\.\(bmp\|gif\|jpg\|png\)$' | shuf -n1)" +# fi +# +# # gnome shell +# # tutorial video: http://www.youtube.com/watch?v=B_VnPXy3VCw +# if [ $DESKTOP_SESSION = GNOME ]; then +# gsettings set org.gnome.desktop.background picture-uri file://"$(find $PATH_WALLPAPER -type f -iregex '.*\.\(bmp\|gif\|jpg\|png\)$' | shuf -n1)" +# fi +# +# +# # gnome2 +# if [ $DESKTOP_SESSION = GNOME ]; then +# gconftool-2 -t str -s /desktop/gnome/background/picture_filename "$(find $PATH_WALLPAPER -type f -iregex '.*\.\(bmp\|gif\|jpg\|png\)$' | shuf -n1)" +# fi +# +# # lxde +# # tutorial video: http://www.youtube.com/watch?v=5xzfBiHuknk +# if [ $DESKTOP_SESSION = LXDE ]; then +# pcmanfm -w "$(find $PATH_WALLPAPER -type f -iregex '.*\.\(bmp\|gif\|jpg\|png\)$' | shuf -n1)" +# fi +# } +# +# +#chwallpaper() { +#ConnectedMonitor="$(xrandr | awk '/ connected/ {print $1}' | head -n 1)" +#PATH_WALLPAPER=~/Pictures/Wallpapers +# +# # find current running windows manager +# CURRENT_WM="$(wmctrl -m | grep "Name:" | awk '{print $2}')" +# +# # mate +# if [ $CURRENT_WM = Marco ]; then +# gsettings set org.mate.background picture-filename "$(find $PATH_WALLPAPER -type f -iregex '.*\.\(bmp\|gif\|jpg\|png\)$' | shuf -n1)" +# fi +# +# # xfce +# # tutorial video: http://www.youtube.com/watch?v=tL9uVT8D6k4 +# if [[ $DESKTOP_SESSION = Xfwm4 ]] || [[ $DESKTOP_SESSION = "Xfce Session" ]]; then +# xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor"$ConnectedMonitor"/workspace0/last-image -s "$(find $PATH_WALLPAPER -type f -iregex '.*\.\(bmp\|gif\|jpg\|png\)$' | shuf -n1)" +# fi +# +# # i3 +# if [ $DESKTOP_SESSION = i3 ]; then +# # feh --randomize --bg-fill "$PATH_WALLPAPER"/* +# feh --randomize --bg-fill "$(find $PATH_WALLPAPER -type f -iregex '.*\.\(bmp\|gif\|jpg\|png\)$' | shuf -n1)" +# fi +# +# # gnome shell +# # tutorial video: http://www.youtube.com/watch?v=B_VnPXy3VCw +# if [ $DESKTOP_SESSION = GNOME ]; then +# gsettings set org.gnome.desktop.background picture-uri file://"$(find $PATH_WALLPAPER -type f -iregex '.*\.\(bmp\|gif\|jpg\|png\)$' | shuf -n1)" +# fi +# +# +# # gnome2 +# if [ $DESKTOP_SESSION = GNOME ]; then +# gconftool-2 -t str -s /desktop/gnome/background/picture_filename "$(find $PATH_WALLPAPER -type f -iregex '.*\.\(bmp\|gif\|jpg\|png\)$' | shuf -n1)" +# fi +# +# # lxde +# # tutorial video: http://www.youtube.com/watch?v=5xzfBiHuknk +# if [ $DESKTOP_SESSION = LXDE ]; then +# pcmanfm -w "$(find $PATH_WALLPAPER -type f -iregex '.*\.\(bmp\|gif\|jpg\|png\)$' | shuf -n1)" +# fi +# } +# +# +##}}} +########################################################### +##-------- Capture RTMP Streams (URL Sniffing) {{{ +##------------------------------------------------------ +## tutorial video: http://www.youtube.com/watch?v=u1dQ81HT4AU +## https://github.com/gotbletu/shownotes/blob/master/rtmpdump_sniff_your_own_tutorial.txt +## http://pclosmag.com/html/Issues/201104/page19.html +sniff-begin() { sudo iptables -t nat -A OUTPUT -p tcp --dport 1935 -m owner \! --uid-owner root -j REDIRECT ;} +sniff-capture-rtmpsrv() { rtmpsrv ;} +sniff-capture-rtmpsuck() { rtmpsuck ;} +sniff-end() { sudo iptables -t nat -D OUTPUT -p tcp --dport 1935 -m owner \! --uid-owner root -j REDIRECT ;} +tsniff-begin() { sudo tcpdump -ieth0 -nn -A | grep -e"rtmp" -e"connect" -e"play" > /tmp/tcpoutput.txt ;} +tsniff-less() { less /tmp/tcpoutput.txt ;} +##}}} +########################################################### +# +############################### +######## E. TESTING LIST ###### +############################### +## New code dump, stuff I am creating or copy from others +# +# +########################################################### +##-------- Weechat XDCC {{{ +##------------------------------------------------------ +## http://nibl.co.uk/bots.php?search= +# +#xdcc-nibl() { +# if [ $# -lt 1 ] +# then +# echo -e "Download XDCC files from using weechat from (#nibl @ irc.rizon.net)" +# echo -e "Search using http://nibl.co.uk/bots.php?search=" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 '/msg AHQ[Turtle] xdcc send #1721'" +# +# return 1 +# fi +# +# echo "irc.rizon.#nibl *$1" > "$(ls ~/.weechat/weechat_fifo*)" +#} +# +# +# +# +## }}} +########################################################### +#-------- Empty Template {{{ +##------------------------------------------------------ +# +## }}} +########################################################### +## https://www.reddit.com/r/archlinux/comments/42784v/what_are_your_bash_aliasesfunctions_for_ffmpeg/cz88h5f +#ffmpeg-stereo () { +# ffmpeg -i "$1" -i "$2" -filter_complex "[0:a][1:a]amerge=inputs=2[aout]" -map "[aout]" -c:a flac "$3" +#} +# +## https://www.reddit.com/r/archlinux/comments/423wr9/is_anyone_having_trouble_with_reflector/ +## alias updatemirrors='sudo reflector --verbose --country 'United States' -l 200 -p http --sort rate --save /etc/pacman.d/mirrorlist' +# +## Shortcut to generate an updated Arch Linux mirrorlist - requires reflector +#reflector-generate() { +# reflector --country "United States" -l 200 -p http --sort rate --save "$1" +#} +# +#mpd-kill() { kill -9 $(cat ~/.mpd/mpd.pid) ;} +#mpd-restart() { kill -9 $(cat ~/.mpd/mpd.pid) && mpd ;} +# +########################################################### +#-------- Battery Status {{{ +##------------------------------------------------------ +## https://www.reddit.com/r/debian/comments/41sw7g/checking_battery_status_in_terminal/cz68iwq +#alias batterystatus="upower -i /org/freedesktop/UPower/devices/........ | grep time" +#alias batteryshow='cat /sys/class/power_supply/BAT1/status' +# }}} +########################################################### +##-------- Binary / Shell Scripts {{{ +##------------------------------------------------------ +# +# +## lightweight image viewer +## tutorial video: https://www.youtube.com/watch?v=OMOIZlOEfb8 +## https://wiki.archlinux.org/index.php/Feh#File_Browser_Image_Launcher +#feh-browser() { ~/.scripts/feh_browser.sh $@ -B white -g 1280x800 & } +#feh-slideshow() { ~/.scripts/feh_browser.sh $@ -B white -g 1280x800 -D 3 & } +# +## http://code.google.com/p/imgur-cli +## imgur image uploader http://imgur.com +#imgur() { python2 ~/.scripts/imgur-cli/imgur.py $@ ;} +# +## manual tiling (similar compiz grid plugin) +## tutorial video: https://www.youtube.com/watch?v=ZF76DELEpjM +## http://ssokolow.com/quicktile +#quicktile() { python2.7 ~/.config/quicktile/quicktile.py $@ ;} +#quicktile-daemonize() { nohup python2.7 ~/.config/quicktile/quicktile.py -d >/dev/null 2>&1& } +#quicktile-kill () { kill $(ps -ef | grep '[q]uicktile.py' | awk '{print $2}') ;} +# +## http://bash.cyberciti.biz/multimedia/linux-rip-audio-cd/ +#rip-audio-cd() { ~/.scripts/rip_audio_cd.sh ;} +# +## screenshot gallery generator +## tutorial video: https://www.youtube.com/watch?v=_4G4nMUTzX8 +## http://cli-apps.org/content/show.php/Movie+Thumbnailer?content=74676 +#shot() { ~/.scripts/shot.sh -n 30 -r 80% -s $@ ;} +# +## take screenshot fullscreen, window, area selection using import command +## http://en.gentoo-wiki.com/wiki/Screenshot +#sshot() { ~/.scripts/screenshot.sh area ;} +# +## Vim as a pager ( similar to the less command ) +## tutorial video: https://www.youtube.com/watch?v=RefWl8I3nBg +# # issue: gg hotkey does not jump to exact line +# vlessold() { /usr/share/vim/vim73/macros/less.sh "$1" ;} +# +# # http://technotales.wordpress.com/2009/05/24/using-vim-as-a-pager/ +# # vim readonly; to force write use :w! +# vless() { vim -R "$@" ;} +# +## https://bitbucket.org/antocuni/tty2gif +## convert ttyrec to gif files +#tty2gif() { python3 ~/.scripts/tty2gif/tty2gif.py $@ ;} +# +## https://github.com/saironiq/shellscripts/blob/master/wolframalpha_com/wa.sh +## http://www.wolframalpha.com +#wolframalpha() { ~/.scripts/shellscripts/wolframalpha_com/was.sh ;} +# +##}}} +########################################################### +##-------- Copy Move {{{ +##------------------------------------------------------ +#cpr() { +# if [ $# -lt 1 ]; then +# echo -e "rsync copying files using task spooler queue" +# echo -e "\nUsage:\n$0 [-h help] [-t task-spooler] " +# echo -e "\nInclude Parent Folder:\n$0 " +# echo -e "\nExclude Parent Folder:\n$0 / " +# echo -e "\nRequirements: rsync task-spooler" +# return 1 +# else +# case "$1" in +# -t) tsp rsync -a "$@" ;; +# -h) $0 ;; +# -*) $0 ;; +# *) rsync -av --progress "$@" ;; +# esac +# fi +#} +#mvr() { +# if [ $# -lt 1 ]; then +# echo -e "rsync moving files using task spooler queue" +# echo -e "\nUsage:\n$0 [-h help] [-t task-spooler] " +# echo -e "\nInclude Parent Folder:\n$0 " +# echo -e "\nExclude Parent Folder:\n$0 / " +# echo -e "\nRequirements: rsync task-spooler" +# return 1 +# else +# case "$1" in +# -t) tsp rsync -a --remove-source-files "$@" ;; +# -h) $0 ;; +# -*) $0 ;; +# *) rsync -av --progress --remove-source-files "$@" ;; +# esac +# fi +#} +## }}} +########################################################### +##-------- VirtualEnv (Python Isolated Environment) {{{ +##------------------------------------------------------ +# +## tutorial video: https://www.youtube.com/watch?v=n8ZzqsFeHOI +#virtwrap-create() { +# mkdir -p ~/.virtualenv +# cd ~/.virtualenv +# virtualenv "$1" -p "${2:-python}" +# source "$1"/bin/activate +#} +#virtwrap-activate() { +# cd ~/.virtualenv +# source "$1"/bin/activate +#} +# +## }}} +########################################################### +##-------- Convert to Image {{{ +##------------------------------------------------------ +## pdftoppm convert pdf to images +## http://askubuntu.com/a/50180 +#convert_pdf_to_png() { +# if [ $# -lt 1 ] +# then +# echo -e "convert PDF document to PNG image (default dpi is 150)" +# echo -e "\nUsage:\n$0 " +# echo -e "\nall pages to images:\n$0 file.pdf" +# echo -e "\nchange dpi (common dpi are 150, 300, 600):\n$0 file.pdf 300" +# echo -e "\nsingle page to image:\n$0 file.pdf 300 5" +# echo -e "\nmultiple pages to images:\n$0 file.pdf 300 5 12" +# +# return 1 +# fi +# pdftoppm -png "$1" "${1%.*}"-"${2:-150}"DPI -r "${2:-150}" -f "$3" -l "${4:-$3}" +#} +# +#convert_pdf_to_jpg() { +# if [ $# -lt 1 ] +# then +# echo -e "convert PDF document to JPEG image (default dpi is 150)" +# echo -e "\nUsage:\n$0 " +# echo -e "\nall pages to images:\n$0 file.pdf" +# echo -e "\nchange dpi (common dpi are 150, 300, 600):\n$0 file.pdf 300" +# echo -e "\nsingle page to image:\n$0 file.pdf 300 5" +# echo -e "\nmultiple pages to images:\n$0 file.pdf 300 5 12" +# +# return 1 +# fi +# pdftoppm -jpeg "$1" "${1%.*}"-"${2:-150}"DPI -r "${2:-150}" -f "$3" -l "${4:-$3}" +#} +# +#convert_pdf_to_tiff() { +# if [ $# -lt 1 ] +# then +# echo -e "convert PDF document to TIFF image (default dpi is 150)" +# echo -e "\nUsage:\n$0 " +# echo -e "\nall pages to images:\n$0 file.pdf" +# echo -e "\nchange dpi (common dpi are 150, 300, 600):\n$0 file.pdf 300" +# echo -e "\nsingle page to image:\n$0 file.pdf 300 5" +# echo -e "\nmultiple pages to images:\n$0 file.pdf 300 5 12" +# +# return 1 +# fi +# pdftoppm -tiff "$1" "${1%.*}"-"${2:-150}"DPI -r "${2:-150}" -f "$3" -l "${4:-$3}" +#} +# +#convert_pdf_to_pgm-grayscale() { +# if [ $# -lt 1 ] +# then +# echo -e "convert PDF document to PGM Grayscale image (default dpi is 150)" +# echo -e "\nUsage:\n$0 " +# echo -e "\nall pages to images:\n$0 file.pdf" +# echo -e "\nchange dpi (common dpi are 150, 300, 600):\n$0 file.pdf 300" +# echo -e "\nsingle page to image:\n$0 file.pdf 300 5" +# echo -e "\nmultiple pages to images:\n$0 file.pdf 300 5 12" +# +# return 1 +# fi +# pdftoppm -gray "$1" "${1%.*}"-"${2:-150}"DPI -r "${2:-150}" -f "$3" -l "${4:-$3}" +#} +# +#convert_pdf_to_pbm-monochrome() { +# if [ $# -lt 1 ] +# then +# echo -e "convert PDF document to PBM Monochrome image (default dpi is 150)" +# echo -e "\nUsage:\n$0 " +# echo -e "\nall pages to images:\n$0 file.pdf" +# echo -e "\nchange dpi (common dpi are 150, 300, 600):\n$0 file.pdf 300" +# echo -e "\nsingle page to image:\n$0 file.pdf 300 5" +# echo -e "\nmultiple pages to images:\n$0 file.pdf 300 5 12" +# +# return 1 +# fi +# pdftoppm -mono "$1" "${1%.*}"-"${2:-150}"DPI -r "${2:-150}" -f "$3" -l "${4:-$3}" +#} +# +## }}} +########################################################### +##-------- Disk Image to ISO {{{ +##------------------------------------------------------ +# +## https://github.com/helmuthdu/dotfiles/blob/master/.bashrc +#convert2discimage_iso () { +# if [[ $# == 0 || $1 == "--help" || $1 == "-h" ]]; then +# echo -e "Converts raw|bin|cue|ccd|img|mdf|nrg disc image to ISO" +# echo -e "Usage: $0 " +# fi +# for i in $*; do +# if [[ ! -f "$i" ]]; then +# echo "'$i' is not a valid file; jumping it" +# else +# echo -n "converting $i..." +# # OUT=`echo $i | cut -d '.' -f 1` +# case $i in +# *.raw ) bchunk "$i" "${i%.*}.iso" ;; #raw=bin +# *.bin|*.cue ) bchunk "${i%.*}.bin" "${i%.*}.cue" "${i%.*}.iso" ;; # bin,cue +# *.ccd|*.img ) ccd2iso "${i%.*}.img" "${i%.*}.iso" ;; # Clone CD images +# *.mdf ) mdf2iso "$i" "${i%.*}.iso" ;; # Alcohol images +# *.nrg ) nrg2iso "$i" "${i%.*}.iso" ;; # Nero images +# * ) echo "$0 don't know de extension of '$i'";; +# esac +# if [[ $? != 0 ]]; then +# echo -e "${R}ERROR!${W}" +# else +# echo -e "${G}done!${W}" +# fi +# fi +# done +#} +# +## https://help.ubuntu.com/community/ManageDiscImages#CloneCD.2FIMG_Images +#convert_to_iso() { +# if [ -z "$1" ]; then +# # display usage if no parameters given +# echo "Usage: extract ." +# else +# if [ -f "$1" ] ; then +# NAME=${1%.*} +# #mkdir $NAME && cd $NAME +# case "$1" in +# *.bin) bchunk "$1" "${1%.*}".cue "${1%.*}".iso ;; # bin/cue +# *.cue) bchunk "${1%.*}".bin "$1" "${1%.*}".iso ;; # bin/cue +# *.img) ccd2iso "$1" "${1%.*}".iso ;; # CloneCD/IMG +# *.nrg) nrg2iso "$1" "${1%.*}".iso ;; +# *.mdf) mdf2iso "$1" "${1%.*}".iso ;; +# *.mds) mdf2iso "${1%.*}".mdf "${1%.*}".iso ;; +# *) echo "$0: '$1' - unsupported format" ;; +# esac +# else +# echo "'$1' - file does not exist" +# fi +#fi +#} +# +## ex() -- Extract compressed files (tarballs, zip, etc) +#ex() { +# for file in "$@"; do +# if [ -f "$file" ]; then +# local file_type=$(file -bizL "$file") +# case "$file_type" in +# *application/x-tar*|*application/zip*|*application/x-zip*|*application/x-cpio*) +# bsdtar -x -f "$file" ;; +# *application/x-gzip*) +# gunzip -d -f "$file" ;; +# *application/x-bzip*) +# bunzip2 -f "$file" ;; +# *application/x-rar*) +# 7z x "$file" ;; +# *application/octet-stream*) +# local file_type=$(file -bzL "$file") +# case "$file_type" in +# 7-zip*) 7z x "$file" ;; +# *) echo -e "Unknown filetype for '$file'\n$file_type" ;; +# esac ;; +# *) +# echo -e "Unknown filetype for '$file'\n$file_type" ;; +# esac +# else +# echo "'$file' is not a valid file" +# fi +# done +#} +# +# +## }}} +########################################################### +##-------- Convert to Documents {{{ +##------------------------------------------------------ +#convert_images_to_pdf() { +# if [ $# -lt 1 ] +# then +# echo -e "convert images into one single pdf" +# echo -e "\nUsage:\n$0 " +# echo -e "\nexample:\n$0 image1.jpg image2.jpg image3.jpg" +# echo -e "\n$0 *.jpg" +# echo -e "\n$0 *.png" +# +# return 1 +# fi +# convert "$@" "${1%.*}"-`date +'%F_%Hh%Ms%S'`.pdf +#} +# +# +## Using libreoffice +#convert_to_html() { soffice --headless --convert-to "html:XHTML Writer File:UTF8" "$1" ;} +#convert_to_txt() { soffice --headless --convert-to "txt:Text (encoded):UTF8" "$1" ;} +# +# +## convert_to_pdfo() { +## if [ -z "$1" ]; then +## # display usage if no parameters given +## echo "Usage: extract ." +## else +## if [ ! -f "${1%.*}".pdf ] ; then +## NAME=${1%.*} +## case "$1" in +## *.doc|*.docx) soffice --headless --convert-to pdf "$@" ;; +## *.ppt|*.pptx) soffice --headless --convert-to pdf "$@" ;; +## *.xls|*.xlsx) soffice --headless --convert-to pdf "$@" ;; +## *.txt|*.rtf) soffice --headless --convert-to pdf "$@" ;; +## *.html) soffice --headless --convert-to pdf "$@" ;; +## *.epub) soffice --headless --convert-to pdf "$@" ;; +## *.cbr|*.cbz|*.cb7|*.cbt|*.cba) ebook-convert "$1" .pdf ;; +## *.jpg|*.jpeg) convert "$@" "${1%.*}"-`date +'%F_%Hh%Ms%S'`.pdf ;; +## *.pbm|*.pgm) convert "$@" "${1%.*}"-`date +'%F_%Hh%Ms%S'`.pdf ;; +## *.png) convert "$@" "${1%.*}"-`date +'%F_%Hh%Ms%S'`.pdf ;; +## *) echo "'$1' - unsupported format or file does not exist" ;; +## esac +## else +## echo "'${1%.*}.pdf' - file exist, skipping to prevent overwrite" +## fi +## fi +## } +# +## http://duff-johnson.com/2014/02/17/the-8-most-popular-document-formats-on-the-web/ +#convert_to_pdf() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 ." +# echo -e "\nsingle: $0 file.doc" +# echo -e "\nmultiple: $0 file1.jpg file2.jpg file3.jpg" +# echo -e "\nwildcard: $0 *.png" +# echo -e "\nRequirement: calibre imagemagick libreoffice" +# return 1 +# else +# if [ ! -f "${1%.*}".pdf ] ; then +# NAME=${1%.*} +# case "$1" in +# *.doc|*.docx) soffice --headless --convert-to pdf "$@" ;; +# *.ppt|*.pptx) soffice --headless --convert-to pdf "$@" ;; +# *.xls|*.xlsx) soffice --headless --convert-to pdf "$@" ;; +# *.txt|*.rtf) soffice --headless --convert-to pdf "$@" ;; +# *.html) soffice --headless --convert-to pdf "$@" ;; +# *.epub) soffice --headless --convert-to pdf "$@" ;; +# *.cbr|*.cbz|*.cb7|*.cbt|*.cba) ebook-convert "$1" .pdf ;; +# *.jpg|*.jpeg|*.pbm|*.pgm|*.png) convert "$@" "${1%.*}"-`date +'%F_%Hh%Ms%S'`.pdf ;; +# *) echo "'$1' - unsupported format or file does not exist" ;; +# esac +# else +# echo "'${1%.*}.pdf' - file exist, skipping to prevent overwrite" +# fi +# fi +#} +# +## }}} +########################################################### +##-------- Convert to Android (Smartphone, Tablet) {{{ +##------------------------------------------------------ +## http://develop.participatoryculture.org/index.php/ConversionMatrix +## https://trac.handbrake.fr/wiki/BuiltInPresets +# +#ANDROID_DEVICE=(-acodec aac -ab 160k -vcodec libx264 -preset slow -profile:v baseline -level 30 -maxrate 10000000 -bufsize 10000000 -f mp4 -threads 0 -strict experimental) +#convert2devices_android_720pnd() { ffmpeg -i "$1" -s 1280x720 ${ANDROID_DEVICE[*]} "${1%.*}".android720p.mp4 ;} +#convert2devices_android_1080p() { ffmpeg -i "$1" -s 1920x1080 ${ANDROID_DEVICE[*]} "${1%.*}".android1080p.mp4 ;} +# +#convert2droid_kindlefire() { +# if [ $# -lt 1 ]; then +# echo -e "Usage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".kindlefire.mp4 ] +# do +# ffmpeg -i "$arg" -s 1024x600 -acodec aac -ab 96k -vcodec libx264 -preset slow -f mp4 -crf 22 -strict experimental "${arg%.*}".kindlefire.mp4 +# done +# done +#} +# +#convert2droid_androidtablet() { +# if [ $# -lt 1 ]; then +# echo -e "A preset for Midrange Andriud Tablet devices." +# echo -e "\nUsage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".androidtablet.mp4 ] +# do +# HandBrakeCLI -i "$arg" -o "${arg%.*}.androidtablet.mp4" --preset="Android Tablet" +# done +# done +#} +# +#convert2droid_android() { +# if [ $# -lt 1 ]; then +# echo -e "A preset for Midrange android devices." +# echo -e "\nUsage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".android.mp4 ] +# do +# HandBrakeCLI -i "$arg" -o "${arg%.*}.android.mp4" --preset="Android" +# done +# done +#} +#convert2droid_high() { +# if [ $# -lt 1 ]; then +# echo -e "HandBrake's general-purpose preset for High Profile H.264 video, with all the bells and whistles." +# echo -e "\nUsage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".high.mp4 ] +# do +# HandBrakeCLI -i "$arg" -o "${arg%.*}.high.mp4" --preset="High Profile" +# done +# done +#} +# +#convert2droid_normal() { +# if [ $# -lt 1 ]; then +# echo -e "HandBrake's normal, default settings." +# echo -e "\nUsage: $0 " +# echo -e "\nsingle: $0 file.avi" +# echo -e "\nmultiple: $0 file1.avi file2.avi file3.avi" +# echo -e "\nwildcard: $0 *.avi" +# return 1 +# fi +# +# myArray=( "$@" ) +# for arg in "${myArray[@]}"; do +# while [ ! -f "${arg%.*}".normal.mp4 ] +# do +# HandBrakeCLI -i "$arg" -o "${arg%.*}.normal.mp4" --preset="Normal" +# done +# done +#} +# +## }}} +########################################################### +##-------- Youtube to Audio (Vice Versa) {{{ +##------------------------------------------------------ +# +## -f 171 = webm audio (vorbis) +## -f 140 = m4a (aac) +#yt2ogg() { youtube-dl -c --restrict-filenames --extract-audio --audio-format vorbis -o "%(title)s.%(ext)s" -f 171 "$@" ;} +#yt2wav() { youtube-dl -c --restrict-filenames --extract-audio --audio-format wav -o "%(title)s.%(ext)s" -f 171 "$@" ;} +yt2mp3() { youtube-dl -c --restrict-filenames --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" -f 140 "$@" ;} +#yt2webmaudio() { youtube-dl -c --restrict-filenames -o "%(title)s.%(ext)s" -f 171 "$@" ;} +#yt2m4a() { youtube-dl -c --restrict-filenames -o "%(title)s.%(ext)s" -f 140 "$@" ;} +# +## http://www.tecmint.com/ffmpeg-commands-for-video-audio-and-image-conversion-in-linux/ +#yt2banneraudio() { +# if [ $# -lt 2 ] +# then +# echo -e "Use ffmpeg to create a banner audio (audio + image to video)" +# echo -e "\nUsage:\n$0