config files
This commit is contained in:
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#! /bin/bash
|
||||
|
||||
bar="▁▂▃▄▅▆▇█"
|
||||
dict="s/;//g;"
|
||||
|
||||
# creating "dictionary" to replace char with bar
|
||||
i=0
|
||||
while [ $i -lt ${#bar} ]
|
||||
do
|
||||
dict="${dict}s/$i/${bar:$i:1}/g;"
|
||||
i=$((i=i+1))
|
||||
done
|
||||
|
||||
# make sure to clean pipe
|
||||
pipe="/tmp/cava.fifo"
|
||||
if [ -p $pipe ]; then
|
||||
unlink $pipe
|
||||
fi
|
||||
mkfifo $pipe
|
||||
|
||||
# write cava config
|
||||
config_file="/tmp/polybar_cava_config"
|
||||
echo "
|
||||
[general]
|
||||
bars = 12
|
||||
[output]
|
||||
method = raw
|
||||
raw_target = $pipe
|
||||
data_format = ascii
|
||||
ascii_max_range = 7
|
||||
" > $config_file
|
||||
|
||||
# run cava in the background
|
||||
cava -p $config_file &
|
||||
|
||||
# reading data from fifo
|
||||
while read -r cmd; do
|
||||
echo $cmd | sed $dict
|
||||
done < $pipe
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
prepend_zero () {
|
||||
seq -f "%02g" $1 $1
|
||||
}
|
||||
|
||||
artist=$(echo -n $(cmus-remote -C 'format_print %F'))
|
||||
|
||||
if [[ $artist = *[!\ ]* ]]; then
|
||||
# song=$(echo -n $(cmus-remote -C status | grep title | cut -c 11-))
|
||||
position=$(cmus-remote -C status | grep position | cut -c 10-)
|
||||
minutes1=$(prepend_zero $(($position / 60)))
|
||||
seconds1=$(prepend_zero $(($position % 60)))
|
||||
duration=$(cmus-remote -C status | grep duration | cut -c 10-)
|
||||
minutes2=$(prepend_zero $(($duration / 60)))
|
||||
seconds2=$(prepend_zero $(($duration % 60)))
|
||||
echo -n "$artist"
|
||||
else
|
||||
echo
|
||||
fi
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
killall -q polybar
|
||||
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
|
||||
|
||||
polybar -c ~/.config/bspwm/themes/mytheme/polybar/config.ini &
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#! /bin/sh
|
||||
|
||||
rofi_cmd() {
|
||||
rofi -dmenu \
|
||||
-theme ~/.config/bspwm/themes/bspwm_nord/rofi/powermenu.rasi
|
||||
}
|
||||
|
||||
chosen=$(printf "⏻ poweroff\n reboot\n exit" | rofi_cmd)
|
||||
|
||||
case "$chosen" in
|
||||
|
||||
"⏻ poweroff") poweroff ;;
|
||||
" reboot") reboot ;;
|
||||
" exit") bspc quit ;;
|
||||
*) exit 1 ;;
|
||||
|
||||
esac
|
||||
Executable
+159
@@ -0,0 +1,159 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o noclobber -o noglob -o nounset -o pipefail
|
||||
IFS=$'\n'
|
||||
|
||||
# If the option `use_preview_script` is set to `true`,
|
||||
# then this script will be called and its output will be displayed in ranger.
|
||||
# ANSI color codes are supported.
|
||||
# STDIN is disabled, so interactive scripts won't work properly
|
||||
|
||||
# This script is considered a configuration file and must be updated manually.
|
||||
# It will be left untouched if you upgrade ranger.
|
||||
|
||||
# Meanings of exit codes:
|
||||
# code | meaning | action of ranger
|
||||
# -----+------------+-------------------------------------------
|
||||
# 0 | success | Display stdout as preview
|
||||
# 1 | no preview | Display no preview at all
|
||||
# 2 | plain text | Display the plain content of the file
|
||||
# 3 | fix width | Don't reload when width changes
|
||||
# 4 | fix height | Don't reload when height changes
|
||||
# 5 | fix both | Don't ever reload
|
||||
# 6 | image | Display the image `$IMAGE_CACHE_PATH` points to as an image preview
|
||||
# 7 | image | Display the file directly as an image
|
||||
|
||||
# Script arguments
|
||||
FILE_PATH="${1}" # Full path of the highlighted file
|
||||
PV_WIDTH="${2}" # Width of the preview pane (number of fitting characters)
|
||||
PV_HEIGHT="${3}" # Height of the preview pane (number of fitting characters)
|
||||
IMAGE_CACHE_PATH="${4}" # Full path that should be used to cache image preview
|
||||
PV_IMAGE_ENABLED="${5}" # 'True' if image previews are enabled, 'False' otherwise.
|
||||
|
||||
FILE_EXTENSION="${FILE_PATH##*.}"
|
||||
FILE_EXTENSION_LOWER="${FILE_EXTENSION,,}"
|
||||
|
||||
# Settings
|
||||
HIGHLIGHT_SIZE_MAX=262143 # 256KiB
|
||||
HIGHLIGHT_STYLE='pablo'
|
||||
PYGMENTIZE_STYLE='autumn'
|
||||
|
||||
|
||||
handle_extension() {
|
||||
case "${FILE_EXTENSION_LOWER}" in
|
||||
# Archive
|
||||
a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
|
||||
rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
|
||||
atool --list -- "${FILE_PATH}" && exit 5
|
||||
bsdtar --list --file "${FILE_PATH}" && exit 5
|
||||
exit 1;;
|
||||
rar)
|
||||
# Avoid password prompt by providing empty password
|
||||
unrar lt -p- -- "${FILE_PATH}" && exit 5
|
||||
exit 1;;
|
||||
7z)
|
||||
# Avoid password prompt by providing empty password
|
||||
7z l -p -- "${FILE_PATH}" && exit 5
|
||||
exit 1;;
|
||||
|
||||
# PDF
|
||||
pdf)
|
||||
# Preview as text conversion
|
||||
pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - && exit 5
|
||||
exiftool "${FILE_PATH}" && exit 5
|
||||
exit 1;;
|
||||
|
||||
# BitTorrent
|
||||
torrent)
|
||||
transmission-show -- "${FILE_PATH}" && exit 5
|
||||
exit 1;;
|
||||
|
||||
# OpenDocument
|
||||
odt|ods|odp|sxw)
|
||||
# Preview as text conversion
|
||||
odt2txt "${FILE_PATH}" && exit 5
|
||||
exit 1;;
|
||||
|
||||
# HTML
|
||||
htm|html|xhtml)
|
||||
# Preview as text conversion
|
||||
w3m -dump "${FILE_PATH}" && exit 5
|
||||
lynx -dump -- "${FILE_PATH}" && exit 5
|
||||
elinks -dump "${FILE_PATH}" && exit 5
|
||||
;; # Continue with next handler on failure
|
||||
esac
|
||||
}
|
||||
|
||||
handle_image() {
|
||||
local mimetype="${1}"
|
||||
case "${mimetype}" in
|
||||
# SVG
|
||||
image/svg+xml)
|
||||
convert "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6
|
||||
exit 1;;
|
||||
|
||||
# Image
|
||||
image/*)
|
||||
# `w3mimgdisplay` will be called for all images (unless overriden as above),
|
||||
# but might fail for unsupported types.
|
||||
exit 7;;
|
||||
|
||||
# Video
|
||||
video/*)
|
||||
# Thumbnail
|
||||
ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6
|
||||
exit 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
handle_mime() {
|
||||
local mimetype="${1}"
|
||||
case "${mimetype}" in
|
||||
# Text
|
||||
text/* | */xml)
|
||||
# Syntax highlight
|
||||
if [[ "$( stat --printf='%s' -- "${FILE_PATH}" )" -gt "${HIGHLIGHT_SIZE_MAX}" ]]; then
|
||||
exit 2
|
||||
fi
|
||||
if [[ "$( tput colors )" -ge 256 ]]; then
|
||||
local pygmentize_format='terminal256'
|
||||
local highlight_format='xterm256'
|
||||
else
|
||||
local pygmentize_format='terminal'
|
||||
local highlight_format='ansi'
|
||||
fi
|
||||
highlight --out-format="${highlight_format}" --style="${HIGHLIGHT_STYLE}" -- "${FILE_PATH}" && exit 5
|
||||
# pygmentize -f "${pygmentize_format}" -O "style=${PYGMENTIZE_STYLE}" -- "${FILE_PATH}" && exit 5
|
||||
exit 2;;
|
||||
|
||||
# Image
|
||||
image/*)
|
||||
# Preview as text conversion
|
||||
# img2txt --gamma=0.6 --width="${PV_WIDTH}" -- "${FILE_PATH}" && exit 4
|
||||
exiftool "${FILE_PATH}" && exit 5
|
||||
exit 1;;
|
||||
|
||||
# Video and audio
|
||||
video/* | audio/*)
|
||||
mediainfo "${FILE_PATH}" && exit 5
|
||||
exiftool "${FILE_PATH}" && exit 5
|
||||
exit 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
handle_fallback() {
|
||||
echo '----- File Type Classification -----' && file --dereference --brief -- "${FILE_PATH}" && exit 5
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
handle_extension
|
||||
MIMETYPE="$( file --dereference --brief --mime-type -- "${FILE_PATH}" )"
|
||||
if [[ "${PV_IMAGE_ENABLED}" == 'True' ]]; then
|
||||
handle_image "${MIMETYPE}"
|
||||
fi
|
||||
handle_mime "${MIMETYPE}"
|
||||
handle_fallback
|
||||
|
||||
exit 1
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
Executable
+75
@@ -0,0 +1,75 @@
|
||||
#!/bin/sh
|
||||
|
||||
get_icon() {
|
||||
case $1 in
|
||||
# Icons for weather-icons
|
||||
01d) icon="";;
|
||||
01n) icon="";;
|
||||
02d) icon="";;
|
||||
02n) icon="";;
|
||||
03*) icon="";;
|
||||
04*) icon="";;
|
||||
09d) icon="";;
|
||||
09n) icon="";;
|
||||
10d) icon="";;
|
||||
10n) icon="";;
|
||||
11d) icon="";;
|
||||
11n) icon="";;
|
||||
13d) icon="";;
|
||||
13n) icon="";;
|
||||
50d) icon="";;
|
||||
50n) icon="";;
|
||||
*) icon="";
|
||||
|
||||
# Icons for Font Awesome 5 Pro
|
||||
#01d) icon="";;
|
||||
#01n) icon="";;
|
||||
#02d) icon="";;
|
||||
#02n) icon="";;
|
||||
#03d) icon="";;
|
||||
#03n) icon="";;
|
||||
#04*) icon="";;
|
||||
#09*) icon="";;
|
||||
#10d) icon="";;
|
||||
#10n) icon="";;
|
||||
#11*) icon="";;
|
||||
#13*) icon="";;
|
||||
#50*) icon="";;
|
||||
#*) icon="";
|
||||
esac
|
||||
|
||||
echo $icon
|
||||
}
|
||||
|
||||
KEY="e434b5435a979de6e155570590bee89b"
|
||||
CITY="Krasnoyarsk"
|
||||
UNITS="metric"
|
||||
SYMBOL="°"
|
||||
|
||||
API="https://api.openweathermap.org/data/2.5"
|
||||
|
||||
if [ -n "$CITY" ]; then
|
||||
if [ "$CITY" -eq "$CITY" ] 2>/dev/null; then
|
||||
CITY_PARAM="id=$CITY"
|
||||
else
|
||||
CITY_PARAM="q=$CITY"
|
||||
fi
|
||||
|
||||
weather=$(curl -sf "$API/weather?appid=$KEY&$CITY_PARAM&units=$UNITS")
|
||||
else
|
||||
location=$(curl -sf https://location.services.mozilla.com/v1/geolocate?key=geoclue)
|
||||
|
||||
if [ -n "$location" ]; then
|
||||
location_lat="$(echo "$location" | jq '.location.lat')"
|
||||
location_lon="$(echo "$location" | jq '.location.lng')"
|
||||
|
||||
weather=$(curl -sf "$API/weather?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$weather" ]; then
|
||||
weather_temp=$(echo "$weather" | jq ".main.temp" | cut -d "." -f 1)
|
||||
weather_icon=$(echo "$weather" | jq -r ".weather[0].icon")
|
||||
|
||||
echo "$weather_temp$SYMBOL"
|
||||
fi
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Load NetworkManager
|
||||
network_status=$(ps aux | grep NetworkManager | grep root)
|
||||
|
||||
# Если служба не запущена
|
||||
if [ "$network_status" = "" ]; then
|
||||
# TODO: Hide password entry
|
||||
rofi -dmenu -p "Root Password: " | sudo -S NetworkManager
|
||||
fi
|
||||
|
||||
# Starts a scan of available broadcasting SSIDs
|
||||
# nmcli dev wifi rescan
|
||||
notify-send "Getting list of available Wi-Fi networks..."
|
||||
wifi_list=$(nmcli --fields "SECURITY,SSID" device wifi list | sed 1d | sed 's/ */ /g' | sed -E "s/WPA*.?\S/ /g" | sed "s/^--/ /g" | sed "s/ //g" | sed "/--/d")
|
||||
# Gives a list of known connections so we can parse it later
|
||||
|
||||
connected=$(nmcli -fields WIFI g)
|
||||
if [[ "$connected" =~ "enabled" ]]; then
|
||||
toggle=" Disable Wi-Fi"
|
||||
elif [[ "$connected" =~ "disabled" ]]; then
|
||||
toggle=" Enable Wi-Fi"
|
||||
fi
|
||||
|
||||
chosen_network=$(echo -e "$toggle\n$wifi_list" | uniq -u | rofi -dmenu -theme ~/.config/bspwm/themes/bspwm_nord/rofi/menu.rasi -i -selected-row 1 -p "Wi-Fi SSID: " )
|
||||
chosen_id=$(echo "${chosen_network:3}" | xargs)
|
||||
|
||||
# Parses the list of preconfigured connections to see if it already contains the chosen SSID. This speeds up the connection process
|
||||
if [ "$chosen_network" = "" ]; then
|
||||
exit
|
||||
elif [ "$chosen_network" = " Enable Wi-Fi" ]; then
|
||||
nmcli radio wifi on
|
||||
elif [ "$chosen_network" = " Disable Wi-Fi" ]; then
|
||||
nmcli radio wifi off
|
||||
else
|
||||
# Message to show when connection is activated successfully
|
||||
success_message="You are now connected to the Wi-Fi network \"$chosen_id\"."
|
||||
# Get known connections
|
||||
saved_connections=$(nmcli -g NAME connection)
|
||||
if [[ $(echo "$saved_connections" | grep -w "$chosen_id") = "$chosen_id" ]]; then
|
||||
nmcli connection up id "$chosen_id" | grep "successfully" && notify-send "Connection Established" "$success_message"
|
||||
else
|
||||
if [[ "$chosen_network" =~ "" ]]; then
|
||||
wifi_password=$(rofi -dmenu -p "Password: " )
|
||||
fi
|
||||
nmcli device wifi connect "$chosen_id" password "$wifi_password" | grep "successfully" && notify-send "Connection Established" "$success_message"
|
||||
fi
|
||||
fi
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# Unfortunately it's not easy to directly use Polybar colour values in this
|
||||
# script so I have to redefine some of my colours here. See the link below for
|
||||
# more details:
|
||||
# https://github.com/polybar/polybar/wiki/Formatting#format-tags-inside-polybar-config
|
||||
green=#55aa55
|
||||
br=#cfd1cd
|
||||
configs_path="/etc/wireguard/"
|
||||
connected_interface=$(networkctl | grep -P "\d+ .* wireguard routable" -o | cut -d" " -f2)
|
||||
|
||||
connect() {
|
||||
selected_config=$(ls $configs_path/*.conf | xargs basename -a -s .conf | rofi -dmenu -theme ~/.config/bspwm/themes/bspwm_nord/rofi/menu.rasi -p "WG choose")
|
||||
[[ $selected_config ]] && sudo /usr/bin/wg-quick up "$configs_path"/"$selected_config".conf
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
# Normally we should have a single connected interface but technically
|
||||
# there's nothing stopping us from having multiple active intgerfaces so
|
||||
# let's do this in a loop:
|
||||
for connected_config in $(networkctl | grep -P "\d+ .* wireguard routable" -o | cut -d" " -f2)
|
||||
do
|
||||
sudo /usr/bin/wg-quick down $configs_path/"$connected_config".conf
|
||||
done
|
||||
}
|
||||
|
||||
toggle() {
|
||||
if [[ $connected_interface ]]
|
||||
then
|
||||
disconnect
|
||||
else
|
||||
connect
|
||||
fi
|
||||
}
|
||||
|
||||
print() {
|
||||
if [[ $connected_interface ]]
|
||||
then
|
||||
echo %{u"$green"}%{+u}%{T2}%{F"$green"} VPN: "$connected_interface%"{T-}%{F-}
|
||||
else
|
||||
echo %{u"$br"}%{+u}%{T2}%{F"$br"} VPN: off%{T-}%{F-} "$connected_interface"
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
--connect)
|
||||
connect
|
||||
;;
|
||||
--disconnect)
|
||||
disconnect
|
||||
;;
|
||||
--toggle)
|
||||
toggle
|
||||
;;
|
||||
*)
|
||||
print
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user