diff --git a/ap-hotspot b/ap-hotspot new file mode 100755 index 0000000..22dd2a3 --- /dev/null +++ b/ap-hotspot @@ -0,0 +1,284 @@ +#!/bin/bash +# Script to set up a WiFi Hotspot in Ubuntu that works with +# Android and Windows Phone. +# +# Copyright (C) 2013 Alin Andrei +# Copyright (C) 2013 Satyajit sahoo +# +# This scipt is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; either version 3 of the License, +# or (at your option) any later version. +# +# The script is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this script. If not, see . + +# Global variables +logfile="/tmp/hostapd.log" +pidfile="/tmp/hotspot.pid" +hotspotconfig="/etc/hostapd-hotspot.conf" +dnsmasqconfig="/etc/dnsmasq.conf" +user=$(who | grep $(echo "$DISPLAY" | cut -d '.' -f 1) | cut -d ' ' -f 1 | tail -1) + +show_msg() { +echo -e "$@" +} + +show_info() { +echo -e "\033[1;34m$@\033[0m" +} + +show_warn() { +echo -e "\033[1;33m$@\033[0m" +} + +show_err() { +echo -e "\033[1;31m$@\033[0m" 1>&2 +} + +show_debug() { +while read input; do + [[ "$debug" == "true" ]] && echo -e "$input" +done +} + +show_notify() { +sudo -u "$user" notify-send -h int:transient:1 -i "network-wireless" "$@" +} + +check_root() { +# Check if user is root +if [[ ! $(whoami) = "root" ]]; then + show_err "Please run the script as root" + exit 1 +fi +} + +check_supported() { +# Check if the wireless card supports Access Point mode. This script won't work if it doesn't support it +if [[ ! $(iw list 2>&1 | grep -A6 "Supported interface modes" | grep AP$) ]]; then + show_err "Your wireless card does not support Access Point mode" + exit 1 +fi +} + +check_network() { +# Check if Wireless is disabled +if [[ $(iwconfig "$INTERFACE_WLAN" 2>&1 | grep "Tx-Power=off") ]]; then + show_err "WiFi is disabled, please enable WiFi before running this script" + exit 1 +# Check if Wireless is enabled, but connected to a network +elif [[ ! $(iwconfig "$INTERFACE_WLAN" 2>&1 | grep "ESSID:off/any") && $(iwconfig "$INTERFACE_WLAN" 2>&1 | grep "ESSID:") ]]; then + show_err "Please disconnect WiFi before proceeding" + exit 1 +fi +} + +check_connected() { +# Monitor logfile for connected devices +lines_con="0" +lines_dis="0" +while [[ -f "$logfile" ]]; do + if [[ "$lines_con" < $(grep -c "AP-STA-CONNECTED" "$logfile") ]]; then + show_notify "New device connected to Hotspot" + (( lines_con++ )) + elif [[ "$lines_dis" < $(grep -c "AP-STA-DISCONNECTED" "$logfile") ]]; then + show_notify "Device disconnected from Hotspot" + (( lines_dis++ )) + fi + sleep 5 +done +} + +configure() { +# Check root +check_root +# Check supported +check_supported +# Reset config +rm -f "$hotspotconfig" +sed -i "s/# Bind to only one interface//g" "$dnsmasqconfig" +sed -i "s/bind-interfaces//g" "$dnsmasqconfig" +sed -i "s/# Choose interface for binding//g" "$dnsmasqconfig" +sed -i "s/^interface=.*//g" "$dnsmasqconfig" +sed -i "s/# Specify range of IP addresses for DHCP leasses//g" "$dnsmasqconfig" +sed -i "s/dhcp-range=192.168.150.2.*//g" "$dnsmasqconfig" +sed -i "s/#INTERFACE_NET=.*//g" "$dnsmasqconfig" +cat -s "$dnsmasqconfig" | tee "$dnsmasqconfig" > /dev/null 2>&1 +# Network interface connected to the Internet +show_msg "Detecting main network interface..." +INTERFACE_NET=$(route | grep -iw "default" | awk '{print $NF}') +if [[ ! $INTERFACE_NET ]]; then + show_warn "Failed to detect the network interface connected to the Internet. Please enter your network interface (e.g.- eth1):" +else + show_msg "Detected $INTERFACE_NET as the network interface connected to the Internet. Press ENTER if this is correct or enter the desired interface below (e.g.- eth0, ppp0 etc.):" +fi +read interface_net +[[ "$interface_net" ]] && INTERFACE_NET="$interface_net" +# WiFi interface +INTERFACE_WLAN=$(iwconfig 2>&1 | grep "^wlan" | sed -e 's/ .*//g') +if [[ ! $INTERFACE_WLAN ]]; then + show_warn "Failed to detect the WiFi interface. Please enter your WiFi interface (e.g.- wlan0):" +else + show_msg "Detected $INTERFACE_WLAN as your WiFi interface. Press ENTER if this is correct or enter the desired interface (e.g.- wlan1):" +fi +read interface_wlan +[[ "$interface_wlan" ]] && INTERFACE_WLAN="$interface_wlan" +# Hotspot SSID +SSID="myhotspot" +show_msg "Enter the desired Access Point name or press ENTER to use the default one ($SSID):" +read ssid +[[ "$ssid" ]] && SSID="$ssid" +# WPA Passphrase +WPAPASS="qwerty0987" +show_msg "Enter the desired WPA Passphrase below or press ENTER to use the default one ($WPAPASS):" +read wpapass +[[ "$wpapass" ]] && WPAPASS="$wpapass" +# Write the hostapd config file +cat < /dev/null 2>&1 +# WiFi Hotspot +interface=$INTERFACE_WLAN +driver=nl80211 +#Access Point +ssid=$SSID +hw_mode=g +# WiFi Channel: +channel=1 +macaddr_acl=0 +auth_algs=1 +ignore_broadcast_ssid=0 +wpa=3 +wpa_passphrase=$WPAPASS +wpa_key_mgmt=WPA-PSK +wpa_pairwise=TKIP +rsn_pairwise=CCMP +EOF +# Add the required bits to the dnsmasq config file +if [[ ! $(grep "Bind to only one interface" "$dnsmasqconfig") ]]; then +cat < /dev/null 2>&1 +# Bind to only one interface +bind-interfaces +# Choose interface for binding +interface=$INTERFACE_WLAN +# Specify range of IP addresses for DHCP leasses +dhcp-range=192.168.150.2,192.168.150.10,12h +#INTERFACE_NET=$INTERFACE_NET +EOF +fi +} + +get_vars() { +# Run Configuration Wizard if config files don't exist +[[ ! -f "$hotspotconfig" || ! -f "$dnsmasqconfig" ]] && configure +# Get $INTERFACE_NET and $INTERFACE_WLAN from the config files +INTERFACE_WLAN=$(grep "interface" "$hotspotconfig" | sed -e 's/interface=//g') +INTERFACE_NET=$(grep "INTERFACE_NET" "$dnsmasqconfig" | sed -e 's/#INTERFACE_NET=//g') +} + +start() { +# Check previous process +if [[ -f "$pidfile" ]]; then + show_err "Another process is already running" + exit 1 +fi +# Check root +check_root +# Check supported +check_supported +# Get variables +get_vars +# Check network +check_network +# Write the PID to a file +echo "$$" > "$pidfile" +show_info "Starting Wireless Hotspot..." +# Set up the services +service hostapd stop 2>&1 | show_debug +service dnsmasq stop 2>&1 | show_debug +update-rc.d hostapd disable 2>&1 | show_debug +update-rc.d dnsmasq disable 2>&1 | show_debug +# Configure IP address for WLAN +ifconfig "$INTERFACE_WLAN" 192.168.150.1 2>&1 | show_debug +# Start DHCP/DNS server +service dnsmasq restart 2>&1 | show_debug +# Enable routing +sysctl net.ipv4.ip_forward=1 2>&1 | show_debug +# Enable NAT +iptables -t nat -A POSTROUTING -o "$INTERFACE_NET" -j MASQUERADE 2>&1 | show_debug +# Run access point daemon +if [[ $(hostapd --help 2>&1 | grep "\-f") ]]; then + rm -f "$logfile" + touch "$logfile" + hostapd -B "$hotspotconfig" -f "$logfile" + while : + do + [[ $(grep "Using interface" "$logfile") ]] && show_info "Wireless Hotspot active" && show_notify "Wireless Hotspot active" && break + sleep 5 + done + check_connected 2>&1 & + disown +else + hostapd -B "$hotspotconfig" 2>&1 | show_debug + show_info "Wireless Hotspot active" +fi +} + +stop() { +# Check root +check_root +# Get variables +get_vars +# Kill process +show_info "Stopping Wireless Hotspot..." +if [[ -f "$pidfile" ]]; then + pid=$(cat "$pidfile") + rm -f "$pidfile" + [[ $(grep -s "ap-hotspot" "/proc/$pid/cmdline") ]] && kill -9 "$pid" +fi +# Delete log +rm -f "$logfile" +# Disable NAT +iptables -D POSTROUTING -t nat -o "$INTERFACE_NET" -j MASQUERADE 2>&1 | show_debug +# Disable routing +sysctl net.ipv4.ip_forward=0 2>&1 | show_debug +# Set up the services +service hostapd stop 2>&1 | show_debug +service dnsmasq stop 2>&1 | show_debug +# Restart WiFi and disable newly created mon.WLAN network +ifconfig "mon.$INTERFACE_WLAN" down +ifconfig "$INTERFACE_WLAN" down +ifconfig "$INTERFACE_WLAN" up +} + +restart() { +show_info "Restarting Wireless Hotspot..." +stop +start +} + +case "$1" in + start) + start;; + stop) + stop;; + restart) + restart;; + configure) + configure;; + debug) + debug="true" + start;; + *) + args=( "start" "stop" "restart" "configure" "debug" ) + desc=( "start wireless hotspot" "stop wireless hotspot" "restart wireless hotspot" "configure hotspot" "start with detailed messages" ) + echo -e "Usage:\tap-hotspot [argument]\n" + for ((i=0; i < ${#args[@]}; i++)); do + printf "\t%-15s%-s\n" "${args[i]}" "${desc[i]}" + done + exit;; +esac diff --git a/composer b/composer new file mode 100755 index 0000000..a420351 Binary files /dev/null and b/composer differ diff --git a/fasd b/fasd new file mode 100755 index 0000000..b1e64f4 --- /dev/null +++ b/fasd @@ -0,0 +1,624 @@ +#!/usr/bin/env sh + +# Fasd (this file) can be sourced or executed by any POSIX compatible shell. + +# Fasd is originally written based on code from z (https://github.com/rupa/z) +# by rupa deadwyler under the WTFPL license. Most if not all of the code has +# been rewritten. + +# Copyright (C) 2011, 2012 by Wei Dai. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +fasd() { + + # make zsh do word splitting inside this function + [ "$ZSH_VERSION" ] && emulate sh && setopt localoptions + + case $1 in + --init) shift + while [ "$1" ]; do + case $1 in + env) + { # source rc files if present + [ -s "/etc/fasdrc" ] && . "/etc/fasdrc" + [ -s "$HOME/.fasdrc" ] && . "$HOME/.fasdrc" + + # set default options + [ -z "$_FASD_DATA" ] && _FASD_DATA="$HOME/.fasd" + [ -z "$_FASD_BLACKLIST" ] && _FASD_BLACKLIST="--help" + [ -z "$_FASD_SHIFT" ] && _FASD_SHIFT="sudo busybox" + [ -z "$_FASD_IGNORE" ] && _FASD_IGNORE="fasd ls echo" + [ -z "$_FASD_SINK" ] && _FASD_SINK=/dev/null + [ -z "$_FASD_TRACK_PWD" ] && _FASD_TRACK_PWD=1 + [ -z "$_FASD_MAX" ] && _FASD_MAX=2000 + [ -z "$_FASD_BACKENDS" ] && _FASD_BACKENDS=native + [ -z "$_FASD_FUZZY" ] && _FASD_FUZZY=2 + [ -z "$_FASD_VIMINFO" ] && _FASD_VIMINFO="$HOME/.viminfo" + [ -z "$_FASD_RECENTLY_USED_XBEL" ] && \ + _FASD_RECENTLY_USED_XBEL="$HOME/.local/share/recently-used.xbel" + + if [ -z "$_FASD_AWK" ]; then + # awk preferences + local awk; for awk in mawk gawk original-awk nawk awk; do + $awk "" && _FASD_AWK=$awk && break + done + fi + } >> "${_FASD_SINK:-/dev/null}" 2>&1 + ;; + + auto) cat <> "$_FASD_SINK" 2>&1 + +EOS + ;; + + posix-alias) cat <& /dev/null || fasd -d'; +EOS + ;; + + zsh-hook) cat <> "$_FASD_SINK" 2>&1 +} +autoload -Uz add-zsh-hook +add-zsh-hook preexec _fasd_preexec + +EOS + ;; + + bash-hook) cat <> "$_FASD_SINK" 2>&1 +} + +# add bash hook +case \$PROMPT_COMMAND in + *_fasd_prompt_func*) ;; + *) PROMPT_COMMAND="_fasd_prompt_func;\$PROMPT_COMMAND";; +esac + +EOS + ;; + + posix-hook) cat <> "$_FASD_SINK" 2>&1 +} +case \$PS1 in + *_fasd_ps1_func*) ;; + *) export PS1="\\\$(_fasd_ps1_func)\$PS1";; +esac + +EOS + ;; + + tcsh-hook) cat <& /dev/null'; +EOS + + ;; + + zsh-ccomp) cat <> "$_FASD_SINK" | \\ + sort -nr | sed 's/^[^ ]*[ ]*//' | while read -r line; do + compadd -U -V fasd "\$line" + done + compstate[insert]=menu # no expand + } + _fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; } + _fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; } + _fasd_zsh_word_complete_trigger() { + local _fasd_cur="\${words[CURRENT]}" + eval \$(fasd --word-complete-trigger _fasd_zsh_word_complete \$_fasd_cur) + } + # define zle widgets + zle -C fasd-complete complete-word _generic + zstyle ':completion:fasd-complete:*' completer _fasd_zsh_word_complete + zstyle ':completion:fasd-complete:*' menu-select + + zle -C fasd-complete-f complete-word _generic + zstyle ':completion:fasd-complete-f:*' completer _fasd_zsh_word_complete_f + zstyle ':completion:fasd-complete-f:*' menu-select + + zle -C fasd-complete-d complete-word _generic + zstyle ':completion:fasd-complete-d:*' completer _fasd_zsh_word_complete_d + zstyle ':completion:fasd-complete-d:*' menu-select +} + +EOS + ;; + + zsh-ccomp-install) cat <> "$_FASD_SINK" | sed -n "\\\$s/^.*'\\\\(.*\\\\)'/\\\\1/p") + \${COMP_LINE#* }" | while read -r line; do + quote_readline "\$line" 2>/dev/null || \\ + printf %q "\$line" 2>/dev/null && \\ + printf \\\\n + done) + local IFS=\$'\\n'; COMPREPLY=( \$RESULT ) +} +_fasd_bash_hook_cmd_complete() { + for cmd in \$*; do + complete -F _fasd_bash_cmd_complete \$cmd + done +} + +EOS + ;; + + bash-ccomp-install) cat <$`{}]\{1,\}/\1 /g' + ;; + + --proc) shift # process commands + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return + + # blacklists + local each; for each in $_FASD_BLACKLIST; do + case " $* " in *\ $each\ *) return;; esac + done + + # shifts + while true; do + case " $_FASD_SHIFT " in + *\ $1\ *) shift;; + *) break;; + esac + done + + # ignores + case " $_FASD_IGNORE " in + *\ $1\ *) return;; + esac + + shift; fasd --add "$@" # add all arguments except command + ;; + + --add|-A) shift # add entries + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return + + # find all valid path arguments, convert them to simplest absolute form + local paths="$(while [ "$1" ]; do + [ -e "$1" ] && printf %s\\n "$1"; shift + done | sed '/^[^/]/s@^@'"$PWD"'/@ + s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 + s@[^/][^/]*//*\.\./@/@;t 0 + s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@;s@^$@/@' 2>> "$_FASD_SINK" \ + | tr '\n' '|')" + + # add current pwd if the option is set + [ "$_FASD_TRACK_PWD" = "1" -a "$PWD" != "$HOME" ] && paths="$paths|$PWD" + + [ -z "${paths##\|}" ] && return # stop if we have nothing to add + + # maintain the file + local tempfile + tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return + $_FASD_AWK -v list="$paths" -v now="$(date +%s)" -v max="$_FASD_MAX" -F"|" ' + BEGIN { + split(list, files, "|") + for(i in files) { + path = files[i] + if(path == "") continue + paths[path] = path # array for checking + rank[path] = 1 + time[path] = now + } + } + $2 >= 1 { + if($1 in paths) { + rank[$1] = $2 + 1 / $2 + time[$1] = now + } else { + rank[$1] = $2 + time[$1] = $3 + } + count += $2 + } + END { + if(count > max) + for(i in rank) print i "|" 0.9*rank[i] "|" time[i] # aging + else + for(i in rank) print i "|" rank[i] "|" time[i] + }' "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" + if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then + env rm -f "$tempfile" + else + env mv -f "$tempfile" "$_FASD_DATA" + fi + ;; + + --delete|-D) shift # delete entries + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return + + # turn valid arguments into entry-deleting sed commands + local sed_cmd="$(while [ "$1" ]; do printf %s\\n "$1"; shift; done | \ + sed '/^[^/]/s@^@'"$PWD"'/@;s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 + s@[^/][^/]*//*\.\./@/@;t 0 + s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@ + s@^$@/@;s@\([.[\/*^$]\)@\\\1@g;s@^\(.*\)$@/^\1|/d@' 2>> "$_FASD_SINK")" + + # maintain the file + local tempfile + tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return + + sed "$sed_cmd" "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" + + if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then + env rm -f "$tempfile" + else + env mv -f "$tempfile" "$_FASD_DATA" + fi + ;; + + --query) shift # query the db, --query [$typ ["$fnd" [$mode]]] + [ -f "$_FASD_DATA" ] || return # no db yet + [ "$1" ] && local typ="$1" + [ "$2" ] && local fnd="$2" + [ "$3" ] && local mode="$3" + + # cat all backends + local each _fasd_data; for each in $_FASD_BACKENDS; do + _fasd_data="$_fasd_data +$(fasd --backend $each)" + done + [ "$_fasd_data" ] || _fasd_data="$(cat "$_FASD_DATA")" + + # set mode specific code for calculating the prior + case $mode in + rank) local prior='times[i]';; + recent) local prior='sqrt(100000/(1+t-la[i]))';; + *) local prior='times[i] * frecent(la[i])';; + esac + + if [ "$fnd" ]; then # dafault matching + local bre="$(printf %s\\n "$fnd" | sed 's/\([*\.\\\[]\)/\\\1/g + s@ @[^|]*@g;s/\$$/|/')" + bre='^[^|]*'"$bre"'[^|/]*|' + local _ret="$(printf %s\\n "$_fasd_data" | grep "$bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + if [ "$_ret" ]; then + _fasd_data="$_ret" + else # no case mathcing + _ret="$(printf %s\\n "$_fasd_data" | grep -i "$bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + if [ "$_ret" ]; then + _fasd_data="$_ret" + elif [ "${_FASD_FUZZY:-0}" -gt 0 ]; then # fuzzy matching + local fuzzy_bre="$(printf %s\\n "$fnd" | \ + sed 's/\([*\.\\\[]\)/\\\1/g;s/\$$/|/ + s@\(\\\{0,1\}[^ ]\)@\1[^|/]\\{0,'"$_FASD_FUZZY"'\\}@g + s@ @[^|]*@g')" + fuzzy_bre='^[^|]*'"$fuzzy_bre"'[^|/]*|' + _ret="$(printf %s\\n "$_fasd_data" | grep -i "$fuzzy_bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + [ "$_ret" ] && _fasd_data="$_ret" || _fasd_data= + fi + fi + else # no query arugments + _fasd_data="$(printf %s\\n "$_fasd_data" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + fi + + # query the database + [ "$_fasd_data" ] && printf %s\\n "$_fasd_data" | \ + $_FASD_AWK -v t="$(date +%s)" -F"|" ' + function frecent(time) { + dx = t-time + if( dx < 3600 ) return 6 + if( dx < 86400 ) return 4 + if( dx < 604800 ) return 2 + return 1 + } + { + if(!paths[$1]) { + times[$1] = $2 + la[$1] = $3 + paths[$1] = 1 + } else { + times[$1] += $2 + if($3 > la[$1]) la[$1] = $3 + } + } + END { + for(i in paths) printf "%-10s %s\n", '"$prior"', i + }' - 2>> "$_FASD_SINK" + ;; + + --backend) + case $2 in + native) cat "$_FASD_DATA";; + viminfo) + < "$_FASD_VIMINFO" sed -n '/^>/{s@~@'"$HOME"'@ + s/^..// + p + }' | $_FASD_AWK -v t="$(date +%s)" '{ + t -= 60 + print $0 "|1|" t + }' + ;; + recently-used) + local nl="$(printf '\\\nX')"; nl="${nl%X}" # slash newline for sed + tr -d '\n' < "$_FASD_RECENTLY_USED_XBEL" | \ + sed 's@file:/@'"$nl"'@g;s@count="@'"$nl"'@g' | sed '1d;s/".*$//' | \ + tr '\n' '|' | sed 's@|/@'"$nl"'@g' | $_FASD_AWK -F'|' '{ + sum = 0 + for( i=2; i<=NF; i++ ) sum += $i + print $1 "|" sum + }' + ;; + *) eval "$2";; + esac + ;; + + *) # parsing logic and processing + local fnd= last= _FASD_BACKENDS="$_FASD_BACKENDS" _fasd_data= comp= exec= + while [ "$1" ]; do case $1 in + --complete) [ "$2" = "--" ] && shift; set -- $2; local lst=1 r=r comp=1;; + --query|--add|--delete|-A|-D) fasd "$@"; return $?;; + --version) [ -z "$comp" ] && echo "1.0.1" && return;; + --) while [ "$2" ]; do shift; fnd="$fnd $1"; last="$1"; done;; + -*) local o="${1#-}"; while [ "$o" ]; do case $o in + s*) local show=1;; + l*) local lst=1;; + i*) [ -z "$comp" ] && local interactive=1 show=1;; + r*) local mode=rank;; + t*) local mode=recent;; + e*) o="${o#?}"; if [ "$o" ]; then # there are characters after "-e" + local exec="$o" # anything after "-e" + else # use the next argument + local exec="${2:?"-e: Argument needed "}" + shift + fi; break;; + b*) o="${o#?}"; if [ "$o" ]; then + _FASD_BACKENDS="$o" + else + _FASD_BACKENDS="${2:?"-b: Argument needed"}" + shift + fi; break;; + B*) o="${o#?}"; if [ "$o" ]; then + _FASD_BACKENDS="$_FASD_BACKENDS $o" + else + _FASD_BACKENDS="$_FASD_BACKENDS ${2:?"-B: Argument needed"}" + shift + fi; break;; + a*) local typ=e;; + d*) local typ=d;; + f*) local typ=f;; + R*) local r=r;; + [0-9]*) local _fasd_i="$o"; break;; + h*) [ -z "$comp" ] && echo "fasd [options] [query ...] +[f|a|s|d|z] [options] [query ...] + options: + -s list paths with scores + -l list paths without scores + -i interactive mode + -e set command to execute on the result file + -b only use backend + -B add additional backend + -a match files and directories + -d match directories only + -f match files only + -r match by rank only + -t match by recent access only + -R reverse listing order + -h show a brief help message + -[0-9] select the nth entry + +fasd [-A|-D] [paths ...] + -A add paths + -D delete paths" >&2 && return;; + esac; o="${o#?}"; done;; + *) fnd="$fnd $1"; last="$1";; + esac; shift; done + + # guess whether the last query is selected from tab completion + case $last in + /?*) if [ -z "$show$lst" -a -${typ:-e} "$last" -a "$exec" ]; then + $exec "$last" + return + fi;; + esac + + local R; [ -z "$r" ] && R=r || R= # let $R be the opposite of $r + fnd="${fnd# }" + + local res + res="$(fasd --query 2>> "$_FASD_SINK")" # query the database + [ $? -gt 0 ] && return + if [ 0 -lt ${_fasd_i:-0} ] 2>> "$_FASD_SINK"; then + res="$(printf %s\\n "$res" | sort -n${R} | \ + sed -n "$_fasd_i"'s/^[^ ]*[ ]*//p')" + elif [ "$interactive" ] || [ "$exec" -a -z "$fnd$lst$show" -a -t 1 ]; then + if [ "$(printf %s "$res" | sed -n '$=')" -gt 1 ]; then + res="$(printf %s\\n "$res" | sort -n${R})" + printf %s\\n "$res" | sed = | sed 'N;s/\n/ /' | sort -nr >&2 + printf "> " >&2 + local i; read i; [ 0 -lt "${i:-0}" ] 2>> "$_FASD_SINK" || return 1 + fi + res="$(printf %s\\n "$res" | sed -n "${i:-1}"'s/^[^ ]*[ ]*//p')" + elif [ "$lst" ]; then + [ "$res" ] && printf %s\\n "$res" | sort -n${r} | sed 's/^[^ ]*[ ]*//' + return + elif [ "$show" ]; then + [ "$res" ] && printf %s\\n "$res" | sort -n${r} + return + elif [ "$fnd" ] && [ "$exec" -o ! -t 1 ]; then # exec or subshell + res="$(printf %s\\n "$res" | sort -n | sed -n '$s/^[^ ]*[ ]*//p')" + else # no args, show + [ "$res" ] && printf %s\\n "$res" | sort -n${r} + return + fi + if [ "$res" ]; then + fasd --add "$res" + [ -z "$exec" ] && exec='printf %s\n' + $exec "$res" + fi + ;; + esac +} + +fasd --init env + +case $- in + *i*) ;; # assume being sourced, do nothing + *) # assume being executed as an executable + if [ -x "$_FASD_SHELL" -a -z "$_FASD_SET" ]; then + _FASD_SET=1 exec $_FASD_SHELL "$0" "$@" + else + fasd "$@" + fi;; +esac + diff --git a/port_list.txt b/port_list.txt new file mode 100644 index 0000000..779cde9 --- /dev/null +++ b/port_list.txt @@ -0,0 +1,60 @@ +Port 21 unblocked +Port 22 unblocked +Port 53 unblocked +Port 80 unblocked +Port 81 unblocked +Port 110 unblocked +Port 161 unblocked +Port 162 unblocked +Port 210 unblocked +Port 443 unblocked +Port 465 unblocked +Port 554 unblocked +Port 587 unblocked +Port 993 unblocked +Port 995 unblocked +Port 1720 unblocked +Port 1935 unblocked +Port 1985 unblocked +Port 2000 unblocked +Port 2020 unblocked +Port 2082 unblocked +Port 2083 unblocked +Port 2095 unblocked +Port 2096 unblocked +Port 2401 unblocked +Port 3230 unblocked +Port 3231 unblocked +Port 3232 unblocked +Port 3233 unblocked +Port 3234 unblocked +Port 3235 unblocked +Port 3236 unblocked +Port 3237 unblocked +Port 3238 unblocked +Port 3239 unblocked +Port 3240 unblocked +Port 3241 unblocked +Port 3242 unblocked +Port 3243 unblocked +Port 3386 unblocked +Port 4764 unblocked +Port 4765 unblocked +Port 8008 unblocked +Port 8080 unblocked +Port 8081 unblocked +Port 8085 unblocked +Port 8400 unblocked +Port 8443 unblocked +Port 9091 unblocked +Port 10098 unblocked +Port 10099 unblocked +Port 12359 unblocked +Port 15003 unblocked +Port 18000 unblocked +Port 20001 unblocked +Port 27001 unblocked +Port 47372 unblocked +Port 47373 unblocked +Port 52709 unblocked +Port 52710 unblocked diff --git a/screen-off b/screen-off new file mode 100755 index 0000000..ecd83f7 --- /dev/null +++ b/screen-off @@ -0,0 +1,17 @@ +#!/bin/bash +screenOffLockFile=/tmp/screen-off-lock + +if [ -f $screenOffLockFile ]; +then + rm $screenOffLockFile + notify-send "Screen on." -i /usr/share/icons/gnome/48x48/devices/display.png +else + touch $screenOffLockFile + sleep .5 + while [ -f $screenOffLockFile ] + do + xset dpms force off + sleep 2 + done + xset dpms force on +fi