├── README.md ├── backup.sh ├── backup2_test.sh ├── backup3_test.sh ├── backup_database_muffin.sh ├── brightness.sh ├── extract.sh ├── lsfiles.sh ├── makegif.sh ├── myip.sh ├── pass_push.sh ├── passmenu ├── polybar ├── arch_updates.sh ├── brightness.sh ├── btc_price_coinm.sh ├── cpu_loadavg.sh ├── free_space_buflash.sh ├── free_space_home.sh ├── free_space_mnt.sh ├── free_space_myarchserver.sh ├── humidity1.sh ├── humidity2.sh ├── info_ssh_sessions.sh ├── pub_ip_polybar.sh ├── pulseaudio-rofi.sh ├── trash.sh ├── usd_price_cbr.sh ├── vpn_status.sh └── weather-openmap.sh ├── screencast3.sh ├── screencast4.sh ├── screenshot.sh ├── screenshot_local.sh ├── screenshotranger.sh ├── youtube_one_click.sh └── youtube_vlc.sh /README.md: -------------------------------------------------------------------------------- 1 | # scripts 2 | my simple scripts 3 | -------------------------------------------------------------------------------- /backup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | NOW=$(date +%Y%m%d%H%M) 4 | MNOW=$(date +%Y%m) 5 | 6 | BACKUP_HOME="/mnt/bu/backup" 7 | EMAIL="devpew" 8 | ARCHIVES_DIR="$BACKUP_HOME/archives" 9 | 10 | 11 | tar --exclude='/home/dm/.local/share/Steam' --exclude='/home/dm/.POD' --exclude='/home/dm/.tor-browser-en' --exclude='/home/dm/Dropbox' --exclude='/home/dm/Nextcloud' --exclude='/home/dm/Downloads' --exclude='/home/dm/backup' --exclude='/home/dm/.dbus' --exclude='/home/dm/.gvfs' --exclude='/home/dm/.cache' --exclude='/home/dm/.cache/dconf' --exclude='/home/dm/.dropbox' -z --create --file /mnt/bu/backup/$NOW.tar.gz --listed-incremental=/mnt/bu/backup/$MNOW.snar /home/dm 12 | 13 | if [ $(ls -d /mnt/bu/backup/*.tar.gz 2> /dev/null | wc -l) != "0" ] 14 | then 15 | gpg -r $EMAIL --encrypt-files /mnt/bu/backup/*.tar.gz \ 16 | && rm -rf /mnt/bu/backup/*.tar.gz 17 | fi 18 | 19 | scp -P port /mnt/bu/backup/$NOW.tar.gz.gpg /mnt/bu/backup/$MNOW.snar user@ip:/mnt/media/backup/x1arch -------------------------------------------------------------------------------- /backup2_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | USER="dm" 4 | EMAIL="devpew" 5 | 6 | NOW=$(date +%Y%m%d%H%M) 7 | YESTERDAY=$(date --date="-1 day" +%Y%m%d) 8 | 9 | BACKUP_HOME="/home/dm/butest2" 10 | CURRENT_LINK="$BACKUP_HOME/current" 11 | SNAPSHOT_DIR="$BACKUP_HOME/snapshots" 12 | ARCHIVES_DIR="$BACKUP_HOME/archives" 13 | 14 | BACKUP_SOURCE_DIR="/home/$USER/butest" 15 | 16 | mkdir -p $SNAPSHOT_DIR $ARCHIVES_DIR &> /dev/null 17 | 18 | rsync -azH --link-dest=$CURRENT_LINK $BACKUP_SOURCE_DIR $SNAPSHOT_DIR/$NOW \ 19 | && ln -snf $(ls -1d $SNAPSHOT_DIR/* | tail -n1) $CURRENT_LINK 20 | 21 | if [ $(ls -d $SNAPSHOT_DIR/$YESTERDAY* 2> /dev/null | wc -l) != "0" ] 22 | then 23 | tar -czf $ARCHIVES_DIR/$YESTERDAY.tar.gz $SNAPSHOT_DIR/$YESTERDAY* \ 24 | && rm -rf $SNAPSHOT_DIR/$YESTERDAY* 25 | fi 26 | 27 | if [ $(ls -d $ARCHIVES_DIR/*.tar.gz 2> /dev/null | wc -l) != "0" ] 28 | then 29 | gpg -r $EMAIL --encrypt-files $ARCHIVES_DIR/*.tar.gz \ 30 | && rm -rf $ARCHIVES_DIR/*.tar.gz 31 | fi 32 | -------------------------------------------------------------------------------- /backup3_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | dest="/home/dm/bu1" 3 | 4 | files=( "/home/dm/bu2" "/home/dm/bu3" "/home/dm/bu4" "/home/dm/bu5" ) 5 | day=$(date +%A) 6 | hostname=$(hostname -s) 7 | archive_file="$hostname-TEST-$day.tgz" 8 | 9 | 10 | for i in "${files[@]}" 11 | do echo "Backing up $i to $dest/$archive_file" 12 | date 13 | echo 14 | 15 | tar czf $dest/$archive_file $i 16 | done 17 | 18 | echo 19 | echo "Backup finished" 20 | -------------------------------------------------------------------------------- /backup_database_muffin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | NOW=$(date +%Y%m%d%H%M) 4 | 5 | pg_dump -U postgres -d fin -t costs > /mnt/bu/backup_muffin_databases/costs_$NOW.sql 6 | pg_dump -U postgres -d fin -t currentcash > /mnt/bu/backup_muffin_databases/currentcash_$NOW.sql 7 | pg_dump -U postgres -d fin -t earnings > /mnt/bu/backup_muffin_databases/earnings_$NOW.sql 8 | pg_dump -U postgres -d fin -t fullstats > /mnt/bu/backup_muffin_databases/fullstats_$NOW.sql 9 | pg_dump -U postgres -d fin -t funds > /mnt/bu/backup_muffin_databases/funds_$NOW.sql 10 | pg_dump -U postgres -d fin -t investpercent > /mnt/bu/backup_muffin_databases/investpercent_$NOW.sql -------------------------------------------------------------------------------- /brightness.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CURRBRIGHT=$(xrandr --current --verbose | grep -m 1 'Brightness:' | cut -f2- -d:) 4 | if [ "$1" = "+" ] && [ $(echo "$CURRBRIGHT < 1" | bc) -eq 1 ] 5 | then 6 | xrandr --output $2 --brightness $(echo "$CURRBRIGHT + 0.1" | bc) 7 | elif [ "$1" = "-" ] && [ $(echo "$CURRBRIGHT > 0" | bc) -eq 1 ] 8 | then 9 | xrandr --output $2 --brightness $(echo "$CURRBRIGHT - 0.1" | bc) 10 | fi 11 | -------------------------------------------------------------------------------- /extract.sh: -------------------------------------------------------------------------------- 1 | function extract () { 2 | if [ -f $1 ] ; then 3 | case $1 in 4 | *.tar.bz2) tar xvjf $1 ;; 5 | *.tar.gz) tar xvzf $1 ;; 6 | *.tar.xz) tar Jxvf $1 ;; 7 | *.bz2) bunzip2 $1 ;; 8 | *.rar) rar x $1 ;; 9 | *.gz) gunzip $1 ;; 10 | *.tar) tar xvf $1 ;; 11 | *.tbz2) tar xvjf $1 ;; 12 | *.tgz) tar xvzf $1 ;; 13 | *.zip) unzip -d `echo $1 | sed 's/\(.*\)\.zip/\1/'` $1;; 14 | *.Z) uncompress $1 ;; 15 | *.7z) 7z x $1 ;; 16 | *) echo "don't know how to extract '$1'" ;; 17 | esac 18 | else 19 | echo "'$1' is not a valid file!" 20 | fi 21 | } 22 | -------------------------------------------------------------------------------- /lsfiles.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ls -lA | awk -F':[0-9]* ' '/:/{print $2}' 4 | -------------------------------------------------------------------------------- /makegif.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ffmpeg -i $1 -r 3 -s 587x550 $1.gif 3 | -------------------------------------------------------------------------------- /myip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | curl ifconfig.co 3 | -------------------------------------------------------------------------------- /pass_push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd ~/.password-store 3 | git add . 4 | git commit -m "123" 5 | git push -u origin master 6 | -------------------------------------------------------------------------------- /passmenu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | shopt -s nullglob globstar 4 | 5 | typeit=0 6 | if [[ $1 == "--type" ]]; then 7 | typeit=1 8 | shift 9 | fi 10 | 11 | prefix=${PASSWORD_STORE_DIR-~/.password-store} 12 | password_files=( "$prefix"/**/*.gpg ) 13 | password_files=( "${password_files[@]#"$prefix"/}" ) 14 | password_files=( "${password_files[@]%.gpg}" ) 15 | 16 | password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@") 17 | 18 | [[ -n $password ]] || exit 19 | 20 | if [[ $typeit -eq 0 ]]; then 21 | pass show -c "$password" 2>/dev/null 22 | else 23 | pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | 24 | xdotool type --clearmodifiers --file - 25 | fi 26 | 27 | -------------------------------------------------------------------------------- /polybar/arch_updates.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then 4 | updates_arch=0 5 | fi 6 | 7 | if ! updates_aur=$(yay -Qum | wc -l); then 8 | # if ! updates_aur=$(cower -u 2> /dev/null | wc -l); then 9 | # if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then 10 | updates_aur=0 11 | fi 12 | 13 | updates=$(("$updates_arch" + "$updates_aur")) 14 | 15 | #if [ "$updates" -gt 0 ]; then 16 | # echo "# $updates" 17 | #else 18 | # echo "" 19 | #fi 20 | 21 | 22 | re='^[0-9]+$' 23 | if ! [[ $updates_arch =~ $re ]] ; then 24 | updates_aur=999; exit 1 25 | fi 26 | 27 | if ! [[ $updates_arch =~ $re ]] ; then 28 | updates_aur=999; exit 1 29 | fi 30 | 31 | 32 | echo P:$updates_arch Y:$updates_aur 33 | -------------------------------------------------------------------------------- /polybar/brightness.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CURRBRIGHT=$(xrandr --current --verbose | grep -m 1 'Brightness:' | cut -f2- -d:) 4 | if [ "$1" = "+" ] && [ $(echo "$CURRBRIGHT < 1" | bc) -eq 1 ] 5 | then 6 | xrandr --output $2 --brightness $(echo "$CURRBRIGHT + 0.1" | bc) 7 | elif [ "$1" = "-" ] && [ $(echo "$CURRBRIGHT > 0" | bc) -eq 1 ] 8 | then 9 | xrandr --output $2 --brightness $(echo "$CURRBRIGHT - 0.1" | bc) 10 | fi 11 | 12 | echo $CURRBRIGHT 13 | -------------------------------------------------------------------------------- /polybar/btc_price_coinm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DATA=$(curl -s 'https://api.coinmarketcap.com/v2/ticker/' | jq -r '.data ."1" .quotes .USD .price') 4 | #echo $DATA 5 | printf "%0.0f\n" $DATA 6 | -------------------------------------------------------------------------------- /polybar/cpu_loadavg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | awk '{print $1" "$2" "$3}' < /proc/loadavg 4 | -------------------------------------------------------------------------------- /polybar/free_space_buflash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #DIR=$(df -h /mnt/buflash | grep dev | awk -F ' ' '{ print $4 }' | sed 's/\G//') 4 | DIR=$(df -h /mnt/buflash | grep dev | awk -F ' ' '{ print $4 }') 5 | 6 | if [[ "${DIR}" ]]; then 7 | echo "${DIR}" 8 | fi 9 | -------------------------------------------------------------------------------- /polybar/free_space_home.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #DIR=$(df -h /home | grep dev | awk -F ' ' '{ print $4 }' | sed 's/\G//') 4 | DIR=$(df -h /home | grep dev | awk -F ' ' '{ print $4 }') 5 | 6 | if [[ "${DIR}" ]]; then 7 | echo "${DIR}" 8 | fi 9 | -------------------------------------------------------------------------------- /polybar/free_space_mnt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #DIR=$(df -h /mnt/bu | grep dev | awk -F ' ' '{ print $4 }' | sed 's/\G//') 4 | DIR=$(df -h /mnt/bu | grep dev | awk -F ' ' '{ print $4 }') 5 | 6 | if [[ "${DIR}" ]]; then 7 | echo "${DIR}" 8 | fi 9 | -------------------------------------------------------------------------------- /polybar/free_space_myarchserver.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #DIR=$(ssh -p 4562 -t dm@192.168.0.112 df -h /mnt/media | grep dev | awk -F ' ' '{ print $4 }' | sed 's/\G//') 4 | DIR=$(ssh -p port -o LogLevel=QUIET -tt user@ip df -h /mnt/media | grep dev | awk -F ' ' '{ print $4 }') 5 | 6 | if [[ "${DIR}" ]]; then 7 | echo "${DIR}" 8 | fi 9 | -------------------------------------------------------------------------------- /polybar/humidity1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #DIR=$(ssh -p 4562 -t dm@192.168.0.112 df -h /mnt/media | grep dev | awk -F ' ' '{ print $4 }' | sed 's/\G//') 4 | DIR=$(ssh -o LogLevel=QUIET -tt pi@192.168.0.134 tail -2 /home/pi/temphum.txt | head -1 | sed 's/[^ ]* //') 5 | 6 | if [[ "${DIR}" ]]; then 7 | echo "${DIR}" 8 | fi 9 | -------------------------------------------------------------------------------- /polybar/humidity2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #DIR=$(ssh -p 4562 -t dm@192.168.0.112 df -h /mnt/media | grep dev | awk -F ' ' '{ print $4 }' | sed 's/\G//') 4 | DIR=$(ssh -o LogLevel=QUIET -tt pi@192.168.0.155 tail -2 /home/pi/temphum.txt | head -1 | sed 's/[^ ]* //') 5 | 6 | if [[ "${DIR}" ]]; then 7 | echo "${DIR}" 8 | fi 9 | -------------------------------------------------------------------------------- /polybar/info_ssh_sessions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sessions="$(lsof -Pi | grep ":22")" 4 | 5 | if [ ! -z "$sessions" ]; then 6 | count=$(echo "$sessions" | wc -l) 7 | echo "# ($count): $(echo "$sessions" | cut -d ">" -f 2 | cut -d " " -f 1 | cut -d ":" -f 1 | tail -n 1)" 8 | else 9 | echo "# (0)" 10 | fi 11 | -------------------------------------------------------------------------------- /polybar/pub_ip_polybar.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | IP=$(dig +short myip.opendns.com @resolver1.opendns.com) 4 | 5 | 6 | if pgrep -x openvpn > /dev/null; then 7 | echo VPN: $IP 8 | else 9 | echo $IP 10 | fi 11 | -------------------------------------------------------------------------------- /polybar/pulseaudio-rofi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | outputs() { 4 | OUTPUT=$(pactl list short sinks | cut -f 2 | rofi -dmenu -p "Output" -mesg "Select prefered output source" ) 5 | pacmd set-default-sink "$OUTPUT" >/dev/null 2>&1 6 | 7 | for playing in $(pacmd list-sink-inputs | awk '$1 == "index:" {print $2}'); do 8 | pacmd move-sink-input "$playing" "$OUTPUT" >/dev/null 2>&1 9 | done 10 | } 11 | 12 | inputs() { 13 | INPUT=$(pactl list short sources | cut -f 2 | grep input | rofi -dmenu -p "Output" -mesg "Select prefered input source" ) 14 | pacmd set-default-source "$INPUT" >/dev/null 2>&1 15 | 16 | for recording in $(pacmd list-source-outputs | awk '$1 == "index:" {print $2}'); do 17 | pacmd move-source-output "$recording" "$INPUT" >/dev/null 2>&1 18 | done 19 | } 20 | 21 | volume_up() { 22 | pactl set-sink-volume @DEFAULT_SINK@ +3% 23 | } 24 | 25 | volume_down() { 26 | pactl set-sink-volume @DEFAULT_SINK@ -3% 27 | } 28 | 29 | mute() { 30 | pactl set-sink-mute @DEFAULT_SINK@ toggle 31 | } 32 | 33 | volume_source_up() { 34 | pactl set-source-volume @DEFAULT_SOURCE@ +3% 35 | } 36 | 37 | volume_source_down() { 38 | pactl set-source-volume @DEFAULT_SOURCE@ -3% 39 | } 40 | 41 | mute_source() { 42 | pactl set-source-mute @DEFAULT_SOURCE@ toggle 43 | } 44 | 45 | get_default_sink() { 46 | pacmd stat | awk -F": " '/^Default sink name: /{print $2}' 47 | } 48 | 49 | output_volume() { 50 | pacmd list-sinks | awk '/^\s+name: /{indefault = $2 == "'"<$(get_default_sink)>"'"} 51 | /^\s+muted: / && indefault {muted=$2} 52 | /^\s+volume: / && indefault {volume=$5} 53 | END { print muted=="no"?volume:"Muted" }' 54 | } 55 | 56 | get_default_source() { 57 | pacmd stat | awk -F": " '/^Default source name: /{print $2}' 58 | } 59 | 60 | input_volume() { 61 | pacmd list-sources | awk '/^\s+name: /{indefault = $2 == "'"<$(get_default_source)>"'"} 62 | /^\s+muted: / && indefault {muted=$2} 63 | /^\s+volume: / && indefault {volume=$5} 64 | END { print muted=="no"?volume:"Muted" }' 65 | } 66 | 67 | output_volume_listener() { 68 | pactl subscribe | while read -r event; do 69 | if echo "$event" | grep -q "change"; then 70 | output_volume 71 | fi 72 | done 73 | } 74 | 75 | input_volume_listener() { 76 | pactl subscribe | while read -r event; do 77 | if echo "$event" | grep -q "change"; then 78 | input_volume 79 | fi 80 | done 81 | } 82 | 83 | case "$1" in 84 | --output) 85 | outputs 86 | ;; 87 | --input) 88 | inputs 89 | ;; 90 | --mute) 91 | mute 92 | ;; 93 | --mute_source) 94 | mute_source 95 | ;; 96 | --volume_up) 97 | volume_up 98 | ;; 99 | --volume_down) 100 | volume_down 101 | ;; 102 | --volume_source_up) 103 | volume_source_up 104 | ;; 105 | --volume_source_down) 106 | volume_source_down 107 | ;; 108 | --output_volume) 109 | output_volume 110 | ;; 111 | --input_volume) 112 | input_volume 113 | ;; 114 | --output_volume_listener) 115 | output_volume 116 | output_volume_listener 117 | ;; 118 | --input_volume_listener) 119 | input_volume 120 | input_volume_listener 121 | ;; 122 | *) 123 | echo "Wrong argument" 124 | ;; 125 | esac 126 | -------------------------------------------------------------------------------- /polybar/trash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TRASH_DIRECTORY="${BLOCK_INSTANCE}" 4 | 5 | if [[ "${TRASH_DIRECTORY}" = "" ]]; then 6 | TRASH_DIRECTORY="${XDG_DATA_HOME:-${HOME}/.local/share}/Trash" 7 | fi 8 | 9 | # Left click 10 | if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then 11 | xdg-open "${TRASH_DIRECTORY}/files" 12 | # Right click 13 | elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then 14 | # Delete all files permanently (unlink them) 15 | rm -r "${TRASH_DIRECTORY}/files" 16 | rm -r "${TRASH_DIRECTORY}/info" 17 | exec paplay ~/.sounds/freedesktop/stereo/trash-empty.oga 18 | # Create new directory 19 | mkdir "${TRASH_DIRECTORY}/files" 20 | mkdir "${TRASH_DIRECTORY}/info" 21 | fi 22 | 23 | TRASH_COUNT=$(ls -A -U -1 "${TRASH_DIRECTORY}/files" | wc -l) 24 | 25 | echo "${TRASH_COUNT}" 26 | -------------------------------------------------------------------------------- /polybar/usd_price_cbr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DATA=$(curl -s 'https://www.cbr-xml-daily.ru/daily_json.js' | jq -r '.Valute.USD.Value') 4 | #echo $DATA 5 | printf "%0.2f\n" $DATA 6 | -------------------------------------------------------------------------------- /polybar/vpn_status.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$(pgrep openvpn)" ]; then 4 | echo "VPN: ON" 5 | else 6 | echo "VPN: OFF" 7 | fi 8 | -------------------------------------------------------------------------------- /polybar/weather-openmap.sh: -------------------------------------------------------------------------------- 1 | 2 | #!/bin/sh 3 | 4 | get_icon() { 5 | case $1 in 6 | 01d) icon="";; 7 | 01n) icon="";; 8 | 02d) icon="";; 9 | 02n) icon="";; 10 | 03*) icon="";; 11 | 04*) icon="";; 12 | 09d) icon="";; 13 | 09n) icon="";; 14 | 10d) icon="";; 15 | 10n) icon="";; 16 | 11d) icon="";; 17 | 11n) icon="";; 18 | 13d) icon="";; 19 | 13n) icon="";; 20 | 50d) icon="";; 21 | 50n) icon="";; 22 | *) icon=""; 23 | esac 24 | 25 | echo $icon 26 | } 27 | 28 | get_duration() { 29 | 30 | osname=$(uname -s) 31 | 32 | case $osname in 33 | *BSD) date -r "$1" -u +%H:%M;; 34 | *) date --date="@$1" -u +%H:%M;; 35 | esac 36 | 37 | } 38 | 39 | KEY= 40 | CITY="498817" 41 | UNITS="metric" 42 | SYMBOL="°" 43 | 44 | API="https://api.openweathermap.org/data/2.5" 45 | 46 | if [ ! -z $CITY ]; then 47 | if [ "$CITY" -eq "$CITY" ] 2>/dev/null; then 48 | CITY_PARAM="id=$CITY" 49 | else 50 | CITY_PARAM="q=$CITY" 51 | fi 52 | 53 | current=$(curl -sf "$API/weather?appid=$KEY&$CITY_PARAM&units=$UNITS") 54 | forecast=$(curl -sf "$API/forecast?appid=$KEY&$CITY_PARAM&units=$UNITS&cnt=1") 55 | else 56 | location=$(curl -sf https://location.services.mozilla.com/v1/geolocate?key=geoclue) 57 | 58 | if [ ! -z "$location" ]; then 59 | location_lat="$(echo "$location" | jq '.location.lat')" 60 | location_lon="$(echo "$location" | jq '.location.lng')" 61 | 62 | current=$(curl -sf "$API/weather?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS") 63 | forecast=$(curl -sf "$API/forecast?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS&cnt=1") 64 | fi 65 | fi 66 | 67 | if [ ! -z "$current" ] && [ ! -z "$forecast" ]; then 68 | current_temp=$(echo "$current" | jq ".main.temp" | cut -d "." -f 1) 69 | current_icon=$(echo "$current" | jq -r ".weather[0].icon") 70 | 71 | forecast_temp=$(echo "$forecast" | jq ".list[].main.temp" | cut -d "." -f 1) 72 | forecast_icon=$(echo "$forecast" | jq -r ".list[].weather[0].icon") 73 | 74 | 75 | if [ "$current_temp" -gt "$forecast_temp" ]; then 76 | trend="" 77 | elif [ "$forecast_temp" -gt "$current_temp" ]; then 78 | trend="" 79 | else 80 | trend="" 81 | fi 82 | 83 | 84 | sun_rise=$(echo "$current" | jq ".sys.sunrise") 85 | sun_set=$(echo "$current" | jq ".sys.sunset") 86 | now=$(date +%s) 87 | 88 | if [ "$sun_rise" -gt "$now" ]; then 89 | daytime=" $(get_duration "$((sun_rise-now))")" 90 | elif [ "$sun_set" -gt "$now" ]; then 91 | daytime=" $(get_duration "$((sun_set-now))")" 92 | else 93 | daytime=" $(get_duration "$((sun_rise-now))")" 94 | fi 95 | 96 | echo "$(get_icon "$current_icon") $current_temp$SYMBOL $trend $(get_icon "$forecast_icon") $forecast_temp$SYMBOL $daytime" 97 | fi 98 | -------------------------------------------------------------------------------- /screencast3.sh: -------------------------------------------------------------------------------- 1 | 2 | #!/bin/bash -e 3 | 4 | while getopts "mnhv" o 5 | do 6 | case "$o" in 7 | (\?) echo "Invalid option: -$OPTARG" >&2 ;; 8 | (h) less $(readlink -f $(dirname $0))/README.md; exit;; 9 | (v) verbose="";; # funnily ffmpeg is verbose by default 10 | (*) break;; 11 | esac 12 | done 13 | shift $((OPTIND - 1)) 14 | 15 | lockfile=/tmp/r2d2 16 | 17 | if test -f $lockfile 18 | then 19 | pid=$(awk '{print $1}' $lockfile) 20 | if kill -0 $pid 21 | then 22 | kill -INT $pid 23 | echo Killed $(cat $lockfile) 24 | logger x11captured: $(du -h $(awk '{print $2}' $lockfile)) 25 | rm $lockfile 26 | exit 27 | else 28 | rm $lockfile 29 | fi 30 | fi 31 | 32 | #output="$(dirname $(readlink -f $0))/$(date +%Y-%m-%d)/${1:-$(date +%s)}.mkv" 33 | output="/home/dm/Videos/screencast/$(date +%Y-%m-%d)/${1:-$(date +%s)}.mkv" 34 | mkdir -p $(dirname $output) 35 | 36 | # Only create RAW file if one does not exist 37 | if test -f "$output" 38 | then 39 | echo $output already exists 40 | logger $(basename $0): $output already exists 41 | exit 1 42 | fi 43 | 44 | die() { echo "$@"; exit 1; } 45 | require() { which $1 &> /dev/null; } 46 | for prg in xdpyinfo ffmpeg; do 47 | require $prg || die "needs ${prg} installed" 48 | done 49 | 50 | res="$(xdpyinfo | awk '/dimensions:/ { print $2; exit }')" 51 | 52 | # https://trac.ffmpeg.org/wiki/Capture/Desktop 53 | #FFREPORT=file=/tmp/$(basename $output).log ffmpeg -report -hide_banner -loglevel quiet \ 54 | # -f x11grab -video_size $res -i $DISPLAY -f pulse -i default -acodec pcm_s16le -c:v lib#x264 \ 55 | # $output & 56 | 57 | 58 | # https://trac.ffmpeg.org/wiki/Capture/Desktop 59 | X11GRAB=$(xrectsel "-f x11grab -s %wx%h -i :0.0+%x,%y") || exit -1 60 | FFREPORT=file=/tmp/$(basename $output).log ffmpeg -report -hide_banner -loglevel quiet \ 61 | -framerate 25 $X11GRAB -f alsa -ac 2 -i hw:0 \ 62 | $output & 63 | 64 | 65 | echo "$! $(readlink -f $output)" > $lockfile 66 | echo -e "\033[1;34m$0\033[m Capturing $res to $output kill $(awk '{print $1}' $lockfile) to kill capture or run $0 again" 67 | -------------------------------------------------------------------------------- /screencast4.sh: -------------------------------------------------------------------------------- 1 | 2 | #!/bin/bash -e 3 | 4 | while getopts "mnhv" o 5 | do 6 | case "$o" in 7 | (\?) echo "Invalid option: -$OPTARG" >&2 ;; 8 | (h) less $(readlink -f $(dirname $0))/README.md; exit;; 9 | (v) verbose="";; # funnily ffmpeg is verbose by default 10 | (*) break;; 11 | esac 12 | done 13 | shift $((OPTIND - 1)) 14 | 15 | lockfile=/tmp/r2d2 16 | 17 | if test -f $lockfile 18 | then 19 | pid=$(awk '{print $1}' $lockfile) 20 | if kill -0 $pid 21 | then 22 | kill -INT $pid 23 | echo Killed $(cat $lockfile) 24 | logger x11captured: $(du -h $(awk '{print $2}' $lockfile)) 25 | rm $lockfile 26 | exit 27 | else 28 | rm $lockfile 29 | fi 30 | fi 31 | 32 | #output="$(dirname $(readlink -f $0))/$(date +%Y-%m-%d)/${1:-$(date +%s)}.mkv" 33 | output="/home/dm/Videos/screencast/$(date +%Y-%m-%d)/${1:-$(date +%s)}.mov" 34 | mkdir -p $(dirname $output) 35 | 36 | # Only create RAW file if one does not exist 37 | if test -f "$output" 38 | then 39 | echo $output already exists 40 | logger $(basename $0): $output already exists 41 | exit 1 42 | fi 43 | 44 | die() { echo "$@"; exit 1; } 45 | require() { which $1 &> /dev/null; } 46 | for prg in xdpyinfo ffmpeg; do 47 | require $prg || die "needs ${prg} installed" 48 | done 49 | 50 | res="$(xdpyinfo | awk '/dimensions:/ { print $2; exit }')" 51 | 52 | # https://trac.ffmpeg.org/wiki/Capture/Desktop 53 | #FFREPORT=file=/tmp/$(basename $output).log ffmpeg -report -hide_banner -loglevel quiet \ 54 | # -f x11grab -video_size $res -i $DISPLAY -f pulse -i default -acodec pcm_s16le -c:v lib#x264 \ 55 | # $output & 56 | 57 | 58 | # https://trac.ffmpeg.org/wiki/Capture/Desktop 59 | X11GRAB=$(xrectsel "-f x11grab -s %wx%h -i :0.0+%x,%y") || exit -1 60 | FFREPORT=file=/tmp/$(basename $output).log ffmpeg -report -hide_banner -loglevel quiet \ 61 | -framerate 25 $X11GRAB -f alsa -ac 2 -i hw:0 \ 62 | $output & 63 | 64 | 65 | echo "$! $(readlink -f $output)" > $lockfile 66 | echo -e "\033[1;34m$0\033[m Capturing $res to $output kill $(awk '{print $1}' $lockfile) to kill capture or run $0 again" 67 | -------------------------------------------------------------------------------- /screenshot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | fileDate=`date +%Y-%m-%d-%H-%M-%S` 4 | machineName=`hostname` 5 | fileName=".png" 6 | FILENAME=$fileDate"-"$machineName$fileName 7 | SHORT=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n 1) 8 | FILENAMESHORT=$SHORT$fileName 9 | dst="dpscr.ru" #your dst. server 10 | dstPath="html" 11 | dstAbs="/var/www/yoururl.ru/" 12 | user="root" 13 | 14 | import $FILENAMESHORT 15 | scp -C $FILENAMESHORT $user@$dst:$dstAbs$dstPath #send screenshot through SCP(with compression enabled for low-bandwith connection) 16 | 17 | echo "http://yoururl.ru/"$FILENAMESHORT | xclip -i -selection clipboard #copy screenshot link to your clipboard 18 | 19 | rm $FILENAMESHORT #delete screenshot locally 20 | -------------------------------------------------------------------------------- /screenshot_local.sh: -------------------------------------------------------------------------------- 1 | fileDate=`date +%Y-%m-%d-%H-%M-%S` 2 | machineName=`hostname` 3 | fileName=".png" 4 | FILENAME=$fileDate"-"$machineName$fileName 5 | SHORT=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n 1) 6 | FILENAMESHORT=$fileDate$fileName 7 | 8 | import $FILENAMESHORT 9 | 10 | -------------------------------------------------------------------------------- /screenshotranger.sh: -------------------------------------------------------------------------------- 1 | #fileName=".png" 2 | #SHORT=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n 1) 3 | #FILENAMESHORT=$SHORT$fileName 4 | dst="yoururl.ru" 5 | dstPath="html" 6 | dstAbs="/var/www/yoururl.ru/" 7 | user="root" 8 | 9 | #import $FILENAMESHORT 10 | FILENAMESHORT=$1 11 | scp -C $FILENAMESHORT $user@$dst:$dstAbs$dstPath #send screenshot through SCP(with compression enabled for low-bandwith connection) 12 | 13 | echo "http://yoururl.ru/"$FILENAMESHORT | xclip -i -selection clipboard #copy screenshot link to your clipboard 14 | -------------------------------------------------------------------------------- /youtube_one_click.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | id=$(wmctrl -l | grep -oP "(?<=)(0x\w+)(?=.*Firefox)") 4 | sleep 0.3 5 | xdotool key --window $id "ctrl+l" 6 | xdotool key --window $id "ctrl+c" 7 | 8 | RESULT=$(xclip -o) 9 | 10 | #echo \'$RESULT\' 11 | 12 | #you-get -p vlc \"$RESULT\" 13 | 14 | RRR=$(you-get -p mpv $RESULT) 15 | echo $RRR 16 | 17 | #you-get -p vlc 'https://www.youtube.com/watch?v=8c7QKerwmh4' 18 | 19 | #echo you-get -p vlc \'$RESULT\' 20 | -------------------------------------------------------------------------------- /youtube_vlc.sh: -------------------------------------------------------------------------------- 1 | RESULT=$(xclip -o) 2 | 3 | 4 | #echo \'$RESULT\' 5 | 6 | #you-get -p vlc \"$RESULT\" 7 | 8 | RRR=$(you-get -p mpv $RESULT) 9 | echo $RRR 10 | 11 | 12 | 13 | #you-get -p vlc 'https://www.youtube.com/watch?v=8c7QKerwmh4' 14 | 15 | #echo you-get -p vlc \'$RESULT\' 16 | --------------------------------------------------------------------------------