From 78db7d43845d3ea276b8028bec6d67b5a5641a1b Mon Sep 17 00:00:00 2001 From: NeodarZ Date: Wed, 21 Sep 2016 20:01:28 +0200 Subject: =?UTF-8?q?Ajout=20de=20la=20conf=20de=20vim=20+=20mise=20=C3=A0?= =?UTF-8?q?=20jour=20de=20la=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .i3-blocks/blocks/audio | 26 -- .i3-blocks/blocks/bandwidth | 96 -------- .i3-blocks/blocks/battery | 26 -- .i3-blocks/blocks/bluetooth | 20 -- .i3-blocks/blocks/brightness | 57 ----- .i3-blocks/blocks/cmus | 20 -- .i3-blocks/blocks/countdown | 36 --- .i3-blocks/blocks/cpu | 48 ---- .i3-blocks/blocks/datetime | 8 - .i3-blocks/blocks/display | 68 ------ .i3-blocks/blocks/feed | 31 --- .i3-blocks/blocks/firewall | 28 --- .i3-blocks/blocks/ip-address | 9 - .i3-blocks/blocks/keymap | 27 --- .i3-blocks/blocks/keystate | 25 -- .i3-blocks/blocks/launcher | 26 -- .i3-blocks/blocks/load | 19 -- .i3-blocks/blocks/locale | 10 - .i3-blocks/blocks/mail | 59 ----- .i3-blocks/blocks/memory | 69 ------ .i3-blocks/blocks/microphone | 26 -- .i3-blocks/blocks/network | 23 -- .i3-blocks/blocks/notifier | 185 --------------- .i3-blocks/blocks/packages | 20 -- .i3-blocks/blocks/playerctl | 39 --- .i3-blocks/blocks/process | 17 -- .i3-blocks/blocks/scroll | 69 ------ .i3-blocks/blocks/space | 38 --- .i3-blocks/blocks/ssid | 18 -- .i3-blocks/blocks/temperature | 35 --- .i3-blocks/blocks/trash | 32 --- .i3-blocks/blocks/usb | 15 -- .i3-blocks/blocks/user | 9 - .i3-blocks/blocks/vpn | 9 - .i3-blocks/blocks/weather | 55 ----- .i3-blocks/blocks/webcam | 17 -- .i3-blocks/blocks/window | 9 - .i3blocks.conf | 159 ------------- .vimrc | 3 + README.md | 29 ++- i3/.i3blocks.conf | 159 +++++++++++++ i3/blocks/audio | 26 ++ i3/blocks/bandwidth | 96 ++++++++ i3/blocks/battery | 26 ++ i3/blocks/bluetooth | 20 ++ i3/blocks/brightness | 57 +++++ i3/blocks/cmus | 20 ++ i3/blocks/countdown | 36 +++ i3/blocks/cpu | 48 ++++ i3/blocks/datetime | 8 + i3/blocks/display | 68 ++++++ i3/blocks/feed | 31 +++ i3/blocks/firewall | 28 +++ i3/blocks/ip-address | 9 + i3/blocks/keymap | 27 +++ i3/blocks/keystate | 25 ++ i3/blocks/launcher | 26 ++ i3/blocks/load | 19 ++ i3/blocks/locale | 10 + i3/blocks/mail | 59 +++++ i3/blocks/memory | 69 ++++++ i3/blocks/microphone | 26 ++ i3/blocks/network | 23 ++ i3/blocks/notifier | 185 +++++++++++++++ i3/blocks/packages | 20 ++ i3/blocks/playerctl | 39 +++ i3/blocks/process | 17 ++ i3/blocks/scroll | 69 ++++++ i3/blocks/space | 38 +++ i3/blocks/ssid | 18 ++ i3/blocks/temperature | 35 +++ i3/blocks/trash | 32 +++ i3/blocks/usb | 15 ++ i3/blocks/user | 9 + i3/blocks/vpn | 9 + i3/blocks/weather | 55 +++++ i3/blocks/webcam | 17 ++ i3/blocks/window | 9 + vim/.vimrc | 541 ++++++++++++++++++++++++++++++++++++++++++ 79 files changed, 2054 insertions(+), 1485 deletions(-) delete mode 100755 .i3-blocks/blocks/audio delete mode 100755 .i3-blocks/blocks/bandwidth delete mode 100755 .i3-blocks/blocks/battery delete mode 100755 .i3-blocks/blocks/bluetooth delete mode 100755 .i3-blocks/blocks/brightness delete mode 100755 .i3-blocks/blocks/cmus delete mode 100755 .i3-blocks/blocks/countdown delete mode 100755 .i3-blocks/blocks/cpu delete mode 100755 .i3-blocks/blocks/datetime delete mode 100755 .i3-blocks/blocks/display delete mode 100755 .i3-blocks/blocks/feed delete mode 100755 .i3-blocks/blocks/firewall delete mode 100755 .i3-blocks/blocks/ip-address delete mode 100755 .i3-blocks/blocks/keymap delete mode 100755 .i3-blocks/blocks/keystate delete mode 100755 .i3-blocks/blocks/launcher delete mode 100755 .i3-blocks/blocks/load delete mode 100755 .i3-blocks/blocks/locale delete mode 100755 .i3-blocks/blocks/mail delete mode 100755 .i3-blocks/blocks/memory delete mode 100755 .i3-blocks/blocks/microphone delete mode 100755 .i3-blocks/blocks/network delete mode 100755 .i3-blocks/blocks/notifier delete mode 100755 .i3-blocks/blocks/packages delete mode 100755 .i3-blocks/blocks/playerctl delete mode 100755 .i3-blocks/blocks/process delete mode 100755 .i3-blocks/blocks/scroll delete mode 100755 .i3-blocks/blocks/space delete mode 100755 .i3-blocks/blocks/ssid delete mode 100755 .i3-blocks/blocks/temperature delete mode 100755 .i3-blocks/blocks/trash delete mode 100755 .i3-blocks/blocks/usb delete mode 100755 .i3-blocks/blocks/user delete mode 100755 .i3-blocks/blocks/vpn delete mode 100755 .i3-blocks/blocks/weather delete mode 100755 .i3-blocks/blocks/webcam delete mode 100644 .i3-blocks/blocks/window delete mode 100644 .i3blocks.conf create mode 100644 i3/.i3blocks.conf create mode 100755 i3/blocks/audio create mode 100755 i3/blocks/bandwidth create mode 100755 i3/blocks/battery create mode 100755 i3/blocks/bluetooth create mode 100755 i3/blocks/brightness create mode 100755 i3/blocks/cmus create mode 100755 i3/blocks/countdown create mode 100755 i3/blocks/cpu create mode 100755 i3/blocks/datetime create mode 100755 i3/blocks/display create mode 100755 i3/blocks/feed create mode 100755 i3/blocks/firewall create mode 100755 i3/blocks/ip-address create mode 100755 i3/blocks/keymap create mode 100755 i3/blocks/keystate create mode 100755 i3/blocks/launcher create mode 100755 i3/blocks/load create mode 100755 i3/blocks/locale create mode 100755 i3/blocks/mail create mode 100755 i3/blocks/memory create mode 100755 i3/blocks/microphone create mode 100755 i3/blocks/network create mode 100755 i3/blocks/notifier create mode 100755 i3/blocks/packages create mode 100755 i3/blocks/playerctl create mode 100755 i3/blocks/process create mode 100755 i3/blocks/scroll create mode 100755 i3/blocks/space create mode 100755 i3/blocks/ssid create mode 100755 i3/blocks/temperature create mode 100755 i3/blocks/trash create mode 100755 i3/blocks/usb create mode 100755 i3/blocks/user create mode 100755 i3/blocks/vpn create mode 100755 i3/blocks/weather create mode 100755 i3/blocks/webcam create mode 100644 i3/blocks/window create mode 100644 vim/.vimrc diff --git a/.i3-blocks/blocks/audio b/.i3-blocks/blocks/audio deleted file mode 100755 index c401c68..0000000 --- a/.i3-blocks/blocks/audio +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# Left click -if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then - amixer -q sset Master 5%+ -# Middle click -elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then - amixer -q sset Master toggle -# Right click -elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then - amixer -q sset Master 5%- -fi - -statusLine=$(amixer get Master | tail -n 1) -status=$(echo "${statusLine}" | grep -wo "on") -volume=$(echo "${statusLine}" | awk -F ' ' '{print $5}' | tr -d '[]%') - -if [[ "${status}" == "on" ]]; then - echo "${volume}%" - echo "${volume}%" - echo "" -else - echo "off" - echo "off" - echo "" -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/bandwidth b/.i3-blocks/blocks/bandwidth deleted file mode 100755 index f0b18cf..0000000 --- a/.i3-blocks/blocks/bandwidth +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash -# Source: http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html - -INSTANCE="${BLOCK_INSTANCE}" - -if [[ "${INSTANCE}" = "" ]]; then - INSTANCE="wlp3s0;both" -fi - -DISPLAY=$(echo "${INSTANCE}" | awk -F ';' '{print $2}') -INSTANCE=$(echo "${INSTANCE}" | awk -F ';' '{print $1}') - -if [[ "${DISPLAY}" = "" ]]; then - DISPLAY="both" -fi - -ONE_KB=1024 -ONE_MB=$(echo "${ONE_KB}*1024" | bc -l) -TEN_MB=$(echo "${ONE_MB}*10" | bc -l) -OHD_MB=$(echo "${TEN_MB}*10" | bc -l) - -URGENT_VALUE="${ONE_MB}" - -PREV_IN=0 -PREV_OUT=0 - -PREV_FILE="/tmp/.bandwidth" - -if [[ -f "${PREV_FILE}" ]]; then - PREV_CONT=$(cat "${PREV_FILE}") - PREV_IN=$(echo "${PREV_CONT}" | head -n 1) - PREV_OUT=$(echo "${PREV_CONT}" | tail -n 1) -fi - -BANDWIDTH=$(grep "${INSTANCE}" /proc/net/dev | awk -F: '{print $2}' | awk '{print $1" "$9}') - -if [[ "${BANDWIDTH}" = "" ]]; then - exit -fi - -BYTES_IN=$(echo "${BANDWIDTH}" | awk -F ' ' '{print $1}') -BYTES_OUT=$(echo "${BANDWIDTH}" | awk -F ' ' '{print $2}') - -function FormatNumber() { - if [[ "${1}" -ge "${OHD_MB}" ]]; then - echo $(echo "scale=0;${1}/${ONE_MB}" | bc -l)"mb" - elif [[ "${1}" -ge "${TEN_MB}" ]]; then - echo $(echo "scale=1;${1}/${ONE_MB}" | bc -l)"mb" - elif [[ "${1}" -ge "${ONE_MB}" ]]; then - echo $(echo "scale=2;${1}/${ONE_MB}" | bc -l)"mb" - elif [[ "${1}" -ge "${ONE_KB}" ]]; then - echo $(echo "scale=0;${1}/${ONE_KB}" | bc -l)"kb" - else - echo "${1}""b" - fi -} - -if [[ "${PREV_IN}" != "" ]] && [[ "${PREV_OUT}" != "" ]]; then - # Calculate the CPU usage since we last checked. - DIFF_IN=$(echo "scale=0;${BYTES_IN} - ${PREV_IN}" | bc -l) - DIFF_OUT=$(echo "scale=0;${BYTES_OUT} - ${PREV_OUT}" | bc -l) - DIFF_TOTAL=0 - - USAGE_IN=$(FormatNumber "${DIFF_IN}") - USAGE_OUT=$(FormatNumber "${DIFF_OUT}") - - if [[ "${DISPLAY}" = "both" ]]; then - echo "${USAGE_IN} : ${USAGE_OUT}" - echo "${USAGE_IN} : ${USAGE_OUT}" - echo "" - DIFF_TOTAL=$((DIFF_TOTAL+DIFF_IN)) - DIFF_TOTAL=$((DIFF_TOTAL+DIFF_OUT)) - elif [[ "${DISPLAY}" = "in" ]]; then - echo "${USAGE_IN}" - echo "${USAGE_IN}" - echo "" - DIFF_TOTAL=$((DIFF_TOTAL+DIFF_IN)) - elif [[ "${DISPLAY}" = "out" ]]; then - echo "${USAGE_OUT}" - echo "${USAGE_OUT}" - echo "" - DIFF_TOTAL=$((DIFF_TOTAL+DIFF_OUT)) - fi -else - echo "?" - echo "?" - echo "" -fi - -# Remember the total and idle CPU times for the next check. -echo "${BYTES_IN}" > "${PREV_FILE}" -echo "${BYTES_OUT}" >> "${PREV_FILE}" - -if [[ "${DIFF_TOTAL}" -ge "${URGENT_VALUE}" ]]; then - exit 33 -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/battery b/.i3-blocks/blocks/battery deleted file mode 100755 index 3058f36..0000000 --- a/.i3-blocks/blocks/battery +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -BATTERY=0 -BATTERY_INFO=$(acpi -b | grep "Battery ${BATTERY}") -BATTERY_STATE=$(echo "${BATTERY_INFO}" | grep -wo "Full\|Charging\|Discharging") -BATTERY_POWER=$(echo "${BATTERY_INFO}" | grep -o '[0-9]\+%' | tr -d '%') - -URGENT_VALUE=10 - -if [[ "${BATTERY_STATE}" = "Charging" ]]; then - echo "${BATTERY_POWER}%+" - echo "${BATTERY_POWER}%+" - echo "" -elif [[ "${BATTERY_STATE}" = "Discharging" ]]; then - echo "${BATTERY_POWER}%-" - echo "${BATTERY_POWER}%-" - echo "" -else - echo "${BATTERY_POWER}%" - echo "${BATTERY_POWER}%" - echo "" -fi - -if [[ "${BATTERY_POWER}" -le "${URGENT_VALUE}" ]]; then - exit 33 -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/bluetooth b/.i3-blocks/blocks/bluetooth deleted file mode 100755 index c9673a5..0000000 --- a/.i3-blocks/blocks/bluetooth +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -# Left click -if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then - sudo bluetooth on -# Middle click -elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then - sudo bluetooth toggle -# Right click -elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then - sudo bluetooth off -fi - -STATUS=$(bluetooth | grep -wo 'on') - -if [[ "${STATUS}" = "on" ]]; then - echo "on" - echo "on" - echo "" -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/brightness b/.i3-blocks/blocks/brightness deleted file mode 100755 index f6294e4..0000000 --- a/.i3-blocks/blocks/brightness +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# One of the following: xrandr, xbacklight, kernel -METHOD="xbacklight" - -# Left click -if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then - xbacklight -inc 5 -# Right click -elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then - xbacklight -dec 5 -fi - -URGENT_VALUE=10 - -if [[ "${METHOD}" = "xrandr" ]]; then - device="${BLOCK_INSTANCE:-primary}" - xrandrOutput=$(xrandr --verbose) - - if [[ "${device}" = "primary" ]]; then - device=$(echo "${xrandrOutput}" | grep 'primary' | head -n 1 | awk -F ' ' '{print $1}') - fi - - curBrightness=$(echo "${xrandrOutput}" | grep "${device}" -A 5 | grep -i "Brightness" | awk -F ':' '{print $2}') -elif [[ "${METHOD}" = "kernel" ]]; then - device="${BLOCK_INSTANCE:-intel_backlight}" - maxBrightness=$(cat /sys/class/backlight/${device}/max_brightness) - curBrightness=$(cat /sys/class/backlight/${device}/brightness) -elif [[ "${METHOD}" = "xbacklight" ]]; then - curBrightness=$(xbacklight -get) -fi - -if [[ "${curBrightness}" -le 0 ]]; then - exit -fi - -if [[ "${METHOD}" = "xrandr" ]]; then - percent=$(echo "scale=0;${curBrightness} * 100" | bc -l) -elif [[ "${METHOD}" = "kernel" ]]; then - percent=$(echo "scale=0;${curBrightness} / ${maxBrightness} * 100" | bc -l) -elif [[ "${METHOD}" = "xbacklight" ]]; then - percent=$(echo "scale=0;${curBrightness}" | bc -l) -fi - -percent=${percent%.*} - -if [[ "${percent}" -le 0 ]]; then - exit -fi - -echo "${percent}%" -echo "${percent}%" -echo "" - -if [[ "${percent}" -le "${URGENT_VALUE}" ]]; then - exit 33 -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/cmus b/.i3-blocks/blocks/cmus deleted file mode 100755 index f4d15b3..0000000 --- a/.i3-blocks/blocks/cmus +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -INFO_CMUS=$(cmus-remote -Q 2>/dev/null) -if [[ $? -eq 0 ]]; then - INFO_TITLE=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*title//p' | head -n 1) - INFO_ALBUM=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*album//p' | head -n 1) - INFO_ARTIST=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*artist//p' | head -n 1) -else - exit -fi - -if [[ "${INFO_ARTIST}" ]] && [[ "${INFO_TITLE}" ]]; then - OUT_TEXT=$(echo "${INFO_ARTIST} - ${INFO_TITLE}" | xargs) -elif [[ "${INFO_TITLE}" ]]; then - OUT_TEXT=$(echo "${INFO_TITLE}" | xargs) -fi - -echo "${OUT_TEXT}" -echo "${OUT_TEXT}" -exit \ No newline at end of file diff --git a/.i3-blocks/blocks/countdown b/.i3-blocks/blocks/countdown deleted file mode 100755 index 311a3b7..0000000 --- a/.i3-blocks/blocks/countdown +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -END_DATE="${BLOCK_INSTANCE}" - -URGENT_VALUE=86400 - -if [[ "${END_DATE}" = "" ]]; then - END_DATE=$(date --date "next Friday" "+%m/%d/%Y %H:%M:%S") -fi - -END_DATE=$(date --date="${END_DATE}" '+%s') -CUR_DATE=$(date "+%s") -DIFF_DATE=$((END_DATE - CUR_DATE)) -DIFF="" - -if [[ "${DIFF_DATE}" -le 0 ]]; then - echo "${END_DATE}" - echo "${END_DATE}" - echo "" - exit 33 -fi - -if [[ "${DIFF_DATE}" -ge 86400 ]]; then - DIFF="[$((DIFF_DATE / 86400))] " - #DIFF_DATE=$((DIFF_DATE % 86400)) -fi - -DIFF+=$(date -u -d "@${DIFF_DATE}" +"%H:%M:%S") - -echo "${DIFF}" -echo "${DIFF}" -echo "" - -if [[ "${DIFF_DATE}" -le "${URGENT_VALUE}" ]]; then - exit 33 -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/cpu b/.i3-blocks/blocks/cpu deleted file mode 100755 index 2cb27ad..0000000 --- a/.i3-blocks/blocks/cpu +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# Source: http://askubuntu.com/a/450136 - -URGENT_VALUE=90 - -PREV_TOTAL=0 -PREV_IDLE=0 - -cpuFile="/tmp/.cpu" - -if [[ -f "${cpuFile}" ]]; then - fileCont=$(cat "${cpuFile}") - PREV_TOTAL=$(echo "${fileCont}" | head -n 1) - PREV_IDLE=$(echo "${fileCont}" | tail -n 1) -fi - -CPU=(`cat /proc/stat | grep '^cpu '`) # Get the total CPU statistics. -unset CPU[0] # Discard the "cpu" prefix. -IDLE=${CPU[4]} # Get the idle CPU time. - -# Calculate the total CPU time. -TOTAL=0 - -for VALUE in "${CPU[@]:0:4}"; do - let "TOTAL=$TOTAL+$VALUE" -done - -if [[ "${PREV_TOTAL}" != "" ]] && [[ "${PREV_IDLE}" != "" ]]; then - # Calculate the CPU usage since we last checked. - let "DIFF_IDLE=$IDLE-$PREV_IDLE" - let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL" - let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10" - echo "${DIFF_USAGE}%" - echo "${DIFF_USAGE}%" - echo "" -else - echo "?" - echo "?" - echo "" -fi - -# Remember the total and idle CPU times for the next check. -echo "${TOTAL}" > "${cpuFile}" -echo "${IDLE}" >> "${cpuFile}" - -if [[ "${DIFF_USAGE}" -gt 0 ]] && [[ "${DIFF_USAGE}" -gt "${URGENT_VALUE}" ]]; then - exit 33 -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/datetime b/.i3-blocks/blocks/datetime deleted file mode 100755 index 178073f..0000000 --- a/.i3-blocks/blocks/datetime +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -FORMAT="${BLOCK_INSTANCE:-%H:%M}" -DATETIME=$(date "+${FORMAT}") - -echo "${DATETIME}" -echo "${DATETIME}" -echo "" \ No newline at end of file diff --git a/.i3-blocks/blocks/display b/.i3-blocks/blocks/display deleted file mode 100755 index 9071900..0000000 --- a/.i3-blocks/blocks/display +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash - -xrandrOut=$(xrandr) - -hdmiName=$(echo "${xrandrOut}" | grep -i 'HDMI' | awk '{print $1}') -vgaName=$(echo "${xrandrOut}" | grep -i 'VGA' | awk '{print $1}') -edpName=$(echo "${xrandrOut}" | grep -i 'EDP' | awk '{print $1}') - -activeDisplays=$(echo "${xrandrOut}" | grep " connected" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/" | tr -s '\n' ' ') -displayFile='/tmp/.displays' - -if [[ -f "${displayFile}" ]]; then - oldDisplays=$(cat "${displayFile}") -else - oldDisplays="" -fi - -if [[ "${oldDisplays}" != "${activeDisplays}" ]]; then - change="yes" -else - change="no" -fi - -# External, HDMI + VGA -if [[ "$activeDisplays" =~ "${hdmiName}" && "$activeDisplays" =~ "${vgaName}" ]]; then - if [[ "${change}" = "yes" ]]; then - $(xrandr --output "${edpName}" --off) - $(xrandr --output "${vgaName}" --auto) - $(xrandr --output "${hdmiName}" --primary --auto) - fi - echo "VGA1 & HDMI" - echo "VGA1 & HDMI" - echo "" -# External, HDMI -elif [[ "$activeDisplays" =~ "${hdmiName}" ]]; then - if [[ "${change}" = "yes" ]]; then - $(xrandr --output "${edpName}" --off) - $(xrandr --output "${vgaName}" --off) - $(xrandr --output "${hdmiName}" --primary --auto) - fi - echo "HDMI" - echo "HDMI" - echo "" -# External, VGA -elif [[ "$activeDisplays" =~ "${vgaName}" ]]; then - if [[ "${change}" = "yes" ]]; then - $(xrandr --output "${edpName}" --off) - $(xrandr --output "${vgaName}" --primary --auto) - $(xrandr --output "${hdmiName}" --off) - fi - echo "VGA" - echo "VGA" - echo -# Only one internal -elif [[ "$activeDisplays" =~ "${edpName}" ]]; then - if [[ "${change}" = "yes" ]]; then - $(xrandr --output "${edpName}" --primary --auto) - $(xrandr --output "${vgaName}" --off) - $(xrandr --output "${hdmiName}" --off) - fi - echo "eDP" - echo "eDP" - echo "" -fi - -if [[ "${change}" = "yes" ]]; then - echo "${activeDisplays}" > "${displayFile}" -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/feed b/.i3-blocks/blocks/feed deleted file mode 100755 index 0030939..0000000 --- a/.i3-blocks/blocks/feed +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# WARNING: This has a LIMIT of 32 characters for now! -# If your URL is longer you should use an URL shortener -# Caused by https://github.com/vivien/i3blocks/blob/01a4f4a9ca1e3d0b3c95d1d62000ad8506bdff1a/include/block.h#L50 -# Example: https://goo.gl/ -FEED_URL="${BLOCK_INSTANCE:-https://www.archlinux.org/feeds/news/}" - -if [[ "${FEED_URL}" = "" ]]; then - exit -fi - -# Follows redirects! -FEED_CONTENT=$(curl ${FEED_URL} -s -L) -FEED_TITLE=$(echo "${FEED_CONTENT}" | grep -v "xmlns:atom" | grep -o '.*' | head -n 1 | sed 's/\(\|<\/title>\)//g') -FEED_LINK=$(echo "${FEED_CONTENT}" | grep -v "xmlns:atom" | grep -o '<link>.*</link>' | head -n 1 | sed 's/\(<link>\|<\/link>\)//g') - -if [[ "${FEED_TITLE}" = *404* ]]; then - echo "${FEED_URL}" - echo "${FEED_URL}" - echo "" - exit 33 -fi - -if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then - xdg-open "${FEED_LINK}" -fi - -echo "${FEED_TITLE}" -echo "${FEED_TITLE}" -echo "" \ No newline at end of file diff --git a/.i3-blocks/blocks/firewall b/.i3-blocks/blocks/firewall deleted file mode 100755 index 6fe26f6..0000000 --- a/.i3-blocks/blocks/firewall +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# Left click -if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then - sudo ufw enable -# Middle click -elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then - sudo ufw reload -# Right click -elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then - sudo ufw disable -fi - -status=$(sudo ufw status 2>/dev/null) - -if [[ $? -gt 0 ]]; then - exit -fi - -if [[ "${status}" != *inactive* ]]; then - echo "on" - echo "on" - echo "" -else - echo "off" - echo "off" - echo "" -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/ip-address b/.i3-blocks/blocks/ip-address deleted file mode 100755 index d91ab56..0000000 --- a/.i3-blocks/blocks/ip-address +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -IP_ADDRESS=$(ip route get 1 | awk '{print $NF;exit}') - -if [[ "${IP_ADDRESS}" != "" ]]; then - echo "${IP_ADDRESS}" - echo "${IP_ADDRESS}" - echo "" -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/keymap b/.i3-blocks/blocks/keymap deleted file mode 100755 index f25ee98..0000000 --- a/.i3-blocks/blocks/keymap +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -KEYMAP_DIRECTORY='/usr/share/kbd/keymaps' - -# Aprrently localectl status does not update on keymap change. However, setxkbmap does. -XKB_OUTPUT=$(setxkbmap -query) -VC_KEYMAP=$(echo "${XKB_OUTPUT}" | grep "layout" | awk -F ':' '{print $2}' | tr -d ' ') -VC_VARIANT=$(echo "${XKB_OUTPUT}" | grep "variant" | awk -F ':' '{print $2}' | tr -d ' ') - -# Keymap has not been specific, so it's not configured properly -if [[ "${VC_KEYMAP}" == "" ]]; then - exit 1 -fi - -KEYMAP_FILE="${VC_KEYMAP}*" - -if [[ "${VC_VARIANT}" != "" ]]; then - KEYMAP_FILE="${KEYMAP_FILE}${VC_VARIANT}*" -fi - -KEYMAP_NAME=$(basename $(dirname $(find ${KEYMAP_DIRECTORY} -name "${KEYMAP_FILE}"))) - -if [[ "${KEYMAP_NAME}" ]]; then - echo "${KEYMAP_NAME}" - echo "${KEYMAP_NAME}" - echo "" -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/keystate b/.i3-blocks/blocks/keystate deleted file mode 100755 index e1543d7..0000000 --- a/.i3-blocks/blocks/keystate +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -TYPE="${BLOCK_INSTANCE:-caps}" - -lockLine=$(xset -q | grep "Num Lock") - -capsLock=$(echo "${lockLine}" | awk -F ' ' '{print $4}') -numLock=$(echo "${lockLine}" | awk -F ' ' '{print $8}') -scrollLock=$(echo "${lockLine}" | awk -F ' ' '{print $12}') - -if [[ "${TYPE}" == "caps" ]]; then - checkLock="${capsLock}" -elif [[ "${TYPE}" == "num" ]]; then - checkLock="${numLock}" -elif [[ "${TYPE}" == "scroll" ]]; then - checkLock="${scrollLock}" -else - exit -fi - -if [[ "${checkLock}" == "on" ]]; then - echo "on" - echo "on" - echo "" -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/launcher b/.i3-blocks/blocks/launcher deleted file mode 100755 index 1e39432..0000000 --- a/.i3-blocks/blocks/launcher +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -CONFIG_FILE="${BLOCK_INSTANCE:-~/.config/i3/config}" -CONFIG_FILE=${CONFIG_FILE/\~/$HOME} - -LAUNCH_CMD=$(cat "${CONFIG_FILE}" | grep -v "^#" | grep -wi 'rofi\|dmenu' | awk -F 'exec ' '{print $2}') -LAUNCH_NAME=$(echo "${LAUNCH_CMD}" | awk -F ' ' '{print $1}') - -VARIABLES=$(cat "${CONFIG_FILE}" | grep -E 'set\ \$' | awk -F ' ' '{$1 = "";print $0}') - -while read varPair; do - varName=$(echo "${varPair}" | awk -F ' ' '{print $1}') - varValue=$(echo "${varPair}" | awk -F ' ' '{print $2}') - #echo "Replacing ${varName} with ${varValue}" - LAUNCH_CMD=$(echo ${LAUNCH_CMD} | sed "s|$varName|$varValue|g") -done <<< "$(echo -e "$VARIABLES")" - -#echo "${LAUNCH_CMD}" && exit - -echo "${LAUNCH_NAME}" -echo "${LAUNCH_NAME}" -echo "" - -if [[ "${BLOCK_BUTTON}" -gt 0 ]]; then - eval ${LAUNCH_CMD} & -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/load b/.i3-blocks/blocks/load deleted file mode 100755 index 448876f..0000000 --- a/.i3-blocks/blocks/load +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -INSTANCE="${BLOCK_INSTANCE:-1}" - -URGENT_VALUE=90 - -LOAD=$(cat /proc/loadavg | awk -F ' ' '{print $'"${INSTANCE}"'}') -if [[ "${LOAD}" != "" ]]; then - LOAD_PERC=$(echo "scale=0; ${LOAD} * 100" | bc -l) - LOAD_PERC=${LOAD_PERC%.*} - - echo "${LOAD}" - echo "${LOAD}" - echo "" - - if [[ "${LOAD_PERC}" -ge "${URGENT_VALUE}" ]]; then - exit 33 - fi -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/locale b/.i3-blocks/blocks/locale deleted file mode 100755 index e517c44..0000000 --- a/.i3-blocks/blocks/locale +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -LOCALE_INFO=$(localectl) -LOCALE_NAME=$(echo "${LOCALE_INFO}" | grep "System Locale" | awk -F '=' '{print $2}' | cut -c 1-2) - -if [[ "${LOCALE_NAME}" ]]; then - echo "${LOCALE_NAME}" - echo "${LOCALE_NAME}" - echo "" -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/mail b/.i3-blocks/blocks/mail deleted file mode 100755 index 66b1d0a..0000000 --- a/.i3-blocks/blocks/mail +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -# Requires https://www.google.com/settings/security/lesssecureapps for gmail. - -CONFIG_FILE="${BLOCK_INSTANCE}" -CONFIG_FILE=${CONFIG_FILE/\~/$HOME} - -# Config file needs the following settings: -#MAIL_SERVER="imap.domain.tld:993" -#MAIL_USER="user@domain.tld" -#MAIL_PASSWORD="secret" -#MAIL_FOLDER="INBOX" - -if [[ ! -f "${CONFIG_FILE}" ]]; then - echo "${CONFIG_FILE}" - exit 33 -fi - -source "${CONFIG_FILE}" - -MAIN_DOMAIN=$(expr match "${MAIL_SERVER}" '.*\.\(.*\..*\)' | awk -F ':' '{print $1}') - -# Add https so xdg knows that it's a website -if [[ "${MAIN_DOMAIN}" != http* ]]; then - MAIN_DOMAIN="https://${MAIN_DOMAIN}" -fi - -# Left click -if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then - xdg-open "${MAIN_DOMAIN}" -fi - -MAIL_FILE="/tmp/.mail" -URGENT_VALUE="100" - -GET_UNREAD=$(cat<<EOF -? LOGIN "${MAIL_USER}" "${MAIL_PASSWORD}" -? STATUS "${MAIL_FOLDER}" (unseen) -? LOGOUT -EOF -) - -echo "${GET_UNREAD}" | openssl s_client -connect "${MAIL_SERVER}" -crlf -ign_eof > "${MAIL_FILE}" 2>/dev/null -UNREAD_COUNT=$(cat "${MAIL_FILE}" | grep -i "UNSEEN" | grep -oE "[0-9]*" | head -n 1) - -# For security reasons -rm "${MAIL_FILE}" - -if [[ "${UNREAD_COUNT}" = "" ]]; then - exit -fi - -echo "${UNREAD_COUNT}" -echo "${UNREAD_COUNT}" -echo "" - -if [[ "${UNREAD_COUNT}" -ge URGENT_VALUE ]]; then - exit 33 -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/memory b/.i3-blocks/blocks/memory deleted file mode 100755 index 866e7c3..0000000 --- a/.i3-blocks/blocks/memory +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash - -# First argument is source (mem/swap), second is output value -# Check /proc/meminfo for possible instances -INSTANCE="${BLOCK_INSTANCE:-mem;free}" - -SOURCE=$(echo "${INSTANCE}" | awk -F ';' '{print $1}') -DISPLAY=$(echo "${INSTANCE}" | awk -F ';' '{print $2}') - -if [[ "${SOURCE}" = "mem" ]]; then - URGENT_VALUE=90 -elif [[ "${SOURCE}" = "swap" ]]; then - URGENT_VALUE=50 -fi - -if [[ "${DISPLAY}" = "" ]]; then - DISPLAY="free" -fi - -ONE_KB=1024 -ONE_MB=$(echo "${ONE_KB}*1024" | bc -l) -ONE_GB=$(echo "${ONE_MB}*1024" | bc -l) -ONE_TB=$(echo "${ONE_GB}*1024" | bc -l) - -# Grep the value and remove KB so we can calculate with it later -#MEMINFO=$(cat /proc/meminfo | grep "${INSTANCE}" | awk -F ':' '{print $2}' | tr -d ' kB') -MEMORY_INFOS=$(cat /proc/meminfo) -SOURCE_TOTAL=$(echo "${MEMORY_INFOS}" | grep -i "${SOURCE}total" | awk -F ':' '{print $2}' | tr -d ' kB') - -if [[ "${SOURCE_TOTAL}" -le 0 ]]; then - exit -fi - -SOURCE_FREE=$(echo "${MEMORY_INFOS}" | grep -i "${SOURCE}available" | awk -F ':' '{print $2}' | tr -d ' kB') -SOURCE_USED=$(echo "scale=0; ${SOURCE_TOTAL}-${SOURCE_FREE}" | bc -l) -SOURCE_PERC=$(echo "scale=0; (${SOURCE_USED}*100)/${SOURCE_TOTAL}" | bc -l) - -if [[ "${DISPLAY}" = "free" ]]; then - MEMINFO="${SOURCE_FREE}" -elif [[ "${DISPLAY}" = "used" ]]; then - MEMINFO="${SOURCE_USED}" -elif [[ "${DISPLAY}" = "total" ]]; then - MEMINFO="${SOURCE_TOTAL}" -elif [[ "${DISPLAY}" = "perc" ]]; then - MEMINFO="${SOURCE_PERC}%" -fi - -if [[ "${DISPLAY}" != "perc" ]]; then - # Convert KB meminfo to bytes - MEMINFO=$(echo "${MEMINFO}*${ONE_KB}" | bc -l) - - if [[ "${MEMINFO}" -ge "${ONE_TB}" ]]; then - MEMINFO=$(echo "scale=3;${MEMINFO}/${ONE_TB}" | bc -l)"tb" - elif [[ "${MEMINFO}" -ge "${ONE_GB}" ]]; then - MEMINFO=$(echo "scale=2;${MEMINFO}/${ONE_GB}" | bc -l)"gb" - elif [[ "${MEMINFO}" -ge "${ONE_MB}" ]]; then - MEMINFO=$(echo "scale=1;${MEMINFO}/${ONE_MB}" | bc -l)"mb" - else - MEMINFO=$(echo "scale=0;${MEMINFO}/${ONE_KB}" | bc -l)"kb" - fi -fi - -echo "${MEMINFO}" -echo "${MEMINFO}" -echo "" - -if [[ "${SOURCE_PERC}" -gt "${URGENT_VALUE}" ]]; then - exit 33 -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/microphone b/.i3-blocks/blocks/microphone deleted file mode 100755 index 76ff3f9..0000000 --- a/.i3-blocks/blocks/microphone +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# Left click -if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then - amixer -q sset Capture 5%+ -# Middle click -elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then - amixer -q sset Capture toggle -# Right click -elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then - amixer -q sset Capture 5%- -fi - -statusLine=$(amixer get Capture | tail -n 1) -status=$(echo "${statusLine}" | grep -wo "on") -volume=$(echo "${statusLine}" | awk -F ' ' '{print $5}' | tr -d '[]%') - -if [[ "${status}" == "on" ]]; then - echo "${volume}%" - echo "${volume}%" - echo "" -else - echo "off" - echo "off" - echo "" -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/network b/.i3-blocks/blocks/network deleted file mode 100755 index cb06e87..0000000 --- a/.i3-blocks/blocks/network +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -device="${BLOCK_INSTANCE:-wlan0}" -status=$(cat /sys/class/net/${device}/operstate) - -URGENT_VALUE=20 - -if [[ "${status}" == "up" ]]; then - if [[ -d "/sys/class/net/${device}/wireless" ]]; then - quality=$(grep ${device} /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') - echo "${quality}%" - echo "${quality}%" - echo "" - - if [[ "${quality}" -le "${URGENT_VALUE}" ]]; then - exit 33 - fi - else - echo "on" - echo "on" - echo "" - fi -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/notifier b/.i3-blocks/blocks/notifier deleted file mode 100755 index 35c94f1..0000000 --- a/.i3-blocks/blocks/notifier +++ /dev/null @@ -1,185 +0,0 @@ -#!/bin/bash -# IMPORTANT: -# To make this block work, you have to edit your block-command. -# It should point to this file. For best performance, only use it on blocks -# you want to monitor. -# -# Example: -# command=~/.i3-blocks/blocks/notifier $BLOCK_NAME - -BLOCK_NAME="${1}" - -if [[ "${BLOCK_NAME}" == "" ]] || [[ "${BLOCK_NAME}" == "notifier" ]]; then - exit 1 -fi - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -BLOCK_PATH="${SCRIPT_DIR}/${BLOCK_NAME}" - -if [[ ! -f "${BLOCK_PATH}" ]]; then - exit 1 -fi - -BLOCK_OUT=$(bash "${BLOCK_PATH}") -BLOCK_URGENT=$? - -# Nothing to display. -if [[ "${BLOCK_OUT}" == "" ]]; then - exit "${BLOCK_URGENT}" -fi - -NOTIFY=0 - -NOTIFY_CHANGES="weather display" -NOTIFY_ALWAYS="" -NOTIFY_NEVER="launcher playerctl scroll" - -if [[ "${NOTIFY_NEVER}" != *${BLOCK_NAME}* ]]; then - BLOCK_UCFIRST=$(echo "${BLOCK_NAME}" | head -c 1 | tr [a-z] [A-Z]; echo "${BLOCK_NAME}" | tail -c +2) - - CHECK_SUM=$(echo "${BLOCK_NAME}-${BLOCK_INSTANCE}" | md5sum | awk '{print $1}') - CACHE_FILE="/tmp/.notify-cache-${CHECK_SUM}" - - BLOCK_DESC=$(echo "${BLOCK_OUT}" | head -n 1) - BLOCK_VALUE=$(echo "${BLOCK_OUT}" | tail -n 1) - BLOCK_ICON="" - - if [[ "${NOTIFY_ALWAYS}" == *${BLOCK_NAME}* ]]; then - NOTIFY=1 - elif [[ "${BLOCK_URGENT}" -gt 0 ]]; then - NOTIFY=1 - fi - - VALUE_CHANGED=0 - HAS_CACHEFILE=0 - if [[ -f "${CACHE_FILE}" ]]; then - HAS_CACHEFILE=1 - CACHED_VALUE=$(cat "${CACHE_FILE}") - #MODIFIED_TIME=$(stat -c '%Y' "${CACHE_FILE}") - #CURRENT_TIME=$(date +%s) - #ELAPSED_TIME=$((MODIFIED_TIME - CURRENT_TIME)) - if [[ "${BLOCK_VALUE}" != "${CACHED_VALUE}" ]]; then - VALUE_CHANGED=1 - if [[ "${NOTIFY_CHANGES}" == *${BLOCK_NAME}* ]]; then - NOTIFY=1 - fi - fi - elif [[ "${NOTIFY_CHANGES}" == *${BLOCK_NAME}* ]]; then - NOTIFY=1 - fi - - if [[ "${NOTIFY}" -eq 1 ]]; then - if [[ "${BLOCK_NAME}" == "audio" ]]; then - BLOCK_MESSAGE="Audio level changed to ${BLOCK_VALUE}." - elif [[ "${BLOCK_NAME}" == "bandwidth" ]]; then - BLOCK_MESSAGE="Traffic went to ${BLOCK_VALUE}." - elif [[ "${BLOCK_NAME}" == "battery" ]]; then - BLOCK_MESSAGE="Energy changed to ${BLOCK_VALUE}." - elif [[ "${BLOCK_NAME}" == "countdown" ]]; then - BLOCK_MESSAGE="Remaining time is now ${BLOCK_VALUE}." - elif [[ "${BLOCK_NAME}" == "cpu" ]]; then - BLOCK_MESSAGE="CPU utilization is now ${BLOCK_VALUE}." - elif [[ "${BLOCK_NAME}" == "feed" ]]; then - BLOCK_MESSAGE="Newest article is ${BLOCK_VALUE}." - elif [[ "${BLOCK_NAME}" == "mail" ]]; then - BLOCK_MESSAGE="Unread emails went to ${BLOCK_VALUE}." - elif [[ "${BLOCK_NAME}" == "memory" ]]; then - BLOCK_MESSAGE="Memory utilization is now ${BLOCK_VALUE}." - elif [[ "${BLOCK_NAME}" == "packages" ]]; then - BLOCK_MESSAGE="${BLOCK_VALUE} packages are now ready to update." - elif [[ "${BLOCK_NAME}" == "space" ]]; then - BLOCK_MESSAGE="Space utilization is now ${BLOCK_INSTANCE}." - elif [[ "${BLOCK_NAME}" == "ssid" ]]; then - BLOCK_MESSAGE="SSID changed to ${BLOCK_VALUE}." - elif [[ "${BLOCK_NAME}" == "temperature" ]]; then - BLOCK_MESSAGE="Sensor temperature changed to ${BLOCK_VALUE}." - elif [[ "${BLOCK_NAME}" == "trash" ]]; then - BLOCK_MESSAGE="${BLOCK_VALUE} items are now in the trash." - else - BLOCK_MESSAGE="${BLOCK_UCFIRST} is now ${BLOCK_VALUE}." - fi - - if [[ "${BLOCK_NAME}" == "audio" ]]; then - BLOCK_ICON="audio-volume-high-symbolic" - elif [[ "${BLOCK_NAME}" == "bandwidth" ]]; then - BLOCK_ICON="network-wireless-acquiring-symbolic" - elif [[ "${BLOCK_NAME}" == "battery" ]]; then - BLOCK_ICON="battery-symbolic" - elif [[ "${BLOCK_NAME}" == "bluetooth" ]]; then - BLOCK_ICON="bluetooth-active-symbolic" - elif [[ "${BLOCK_NAME}" == "brightness" ]]; then - BLOCK_ICON="display-brightness-symbolic" - elif [[ "${BLOCK_NAME}" == "cmus" ]]; then - BLOCK_ICON="emblem-music-symbolic" - elif [[ "${BLOCK_NAME}" == "countdown" ]]; then - BLOCK_ICON="document-open-recent-symbolic" - elif [[ "${BLOCK_NAME}" == "cpu" ]]; then - BLOCK_ICON="indicator-cpufreq" - elif [[ "${BLOCK_NAME}" == "datetime" ]]; then - BLOCK_ICON="system-run-symbolic" # TODO - elif [[ "${BLOCK_NAME}" == "device" ]]; then - BLOCK_ICON="system-run-symbolic" # TODO - elif [[ "${BLOCK_NAME}" == "display" ]]; then - BLOCK_ICON="video-display-symbolic" - elif [[ "${BLOCK_NAME}" == "feed" ]]; then - BLOCK_ICON="folder-documents-symbolic" - elif [[ "${BLOCK_NAME}" == "firewall" ]]; then - BLOCK_ICON="changes-prevent-symbolic.svg" # TODO - elif [[ "${BLOCK_NAME}" == "ip-address" ]]; then - BLOCK_ICON="avatar-default-symbolic" # TODO - elif [[ "${BLOCK_NAME}" == "keystate" ]]; then - BLOCK_ICON="format-text-underline-symbolic" # TODO - elif [[ "${BLOCK_NAME}" == "launcher" ]]; then - BLOCK_ICON="system-run-symbolic" - elif [[ "${BLOCK_NAME}" == "load" ]]; then - BLOCK_ICON="indicator-cpufreq" # TODO - elif [[ "${BLOCK_NAME}" == "locale" ]]; then - BLOCK_ICON="format-text-larger-symbolic" - elif [[ "${BLOCK_NAME}" == "mail" ]]; then - BLOCK_ICON="mail-send-symbolic" - elif [[ "${BLOCK_NAME}" == "memory" ]]; then - BLOCK_ICON="drive-harddisk-solidstate-symbolic" # TODO - elif [[ "${BLOCK_NAME}" == "microphone" ]]; then - BLOCK_ICON="audio-input-microphone-symbolic" - elif [[ "${BLOCK_NAME}" == "network" ]]; then - BLOCK_ICON="network-wireless-connected-symbolic" - elif [[ "${BLOCK_NAME}" == "packages" ]]; then - BLOCK_ICON="view-refresh-symbolic" - elif [[ "${BLOCK_NAME}" == "playerctl" ]]; then - BLOCK_ICON="emblem-music-symbolic" - elif [[ "${BLOCK_NAME}" == "process" ]]; then - BLOCK_ICON="process-stop-symbolic" - elif [[ "${BLOCK_NAME}" == "space" ]]; then - BLOCK_ICON="drive-harddisk-solidstate-symbolic" # TODO - elif [[ "${BLOCK_NAME}" == "ssid" ]]; then - BLOCK_ICON="system-users-symbolic" - elif [[ "${BLOCK_NAME}" == "temperature" ]]; then - BLOCK_ICON="object-inverse" # TODO - elif [[ "${BLOCK_NAME}" == "trash" ]]; then - BLOCK_ICON="user-trash-symbolic" - elif [[ "${BLOCK_NAME}" == "usb" ]]; then - BLOCK_ICON="drive-removable-media-usb-symbolic-1" - elif [[ "${BLOCK_NAME}" == "vpn" ]]; then - BLOCK_ICON="dialog-password-symbolic" # TODO - elif [[ "${BLOCK_NAME}" == "weather" ]]; then - BLOCK_ICON="weather-few-clouds-symbolic" - elif [[ "${BLOCK_NAME}" == "webcam" ]]; then - BLOCK_ICON="camera-web-symbolic" - elif [[ "${BLOCK_NAME}" == "window" ]]; then - BLOCK_ICON="view-dual-symbolic" # TODO - fi - - if [[ "${BLOCK_URGENT}" -gt 0 ]]; then - notify-send -u critical -t 5000 -i "${BLOCK_ICON}" -a "i3block-${BLOCK_NAME}" "${BLOCK_UCFIRST}" "${BLOCK_MESSAGE}" - else - notify-send -u normal -t 3500 -i "${BLOCK_ICON}" -a "i3block-${BLOCK_NAME}" "${BLOCK_UCFIRST}" "${BLOCK_MESSAGE}" - fi - fi - - if [[ "${VALUE_CHANGED}" -eq 1 ]] || [[ "${HAS_CACHEFILE}" -eq 0 ]]; then - echo "${BLOCK_VALUE}" > "${CACHE_FILE}" - fi -fi - -echo "${BLOCK_OUT}" -exit "${BLOCK_URGENT}" \ No newline at end of file diff --git a/.i3-blocks/blocks/packages b/.i3-blocks/blocks/packages deleted file mode 100755 index 923d479..0000000 --- a/.i3-blocks/blocks/packages +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/bash - -PACKAGES=$(pacman -Qu) - -URGENT_VALUE=25 - -if [[ $? -gt 0 ]]; then - return -fi - -PACKAGE_COUNT=$(echo "${PACKAGES}" | wc -l) - -if [[ "${PACKAGE_COUNT}" -gt 0 ]]; then - echo "${PACKAGE_COUNT}" # full-text - echo "${PACKAGE_COUNT}" # short-text - echo "" - if [[ "${PACKAGE_COUNT}" -gt "${URGENT_VALUE}" ]]; then - exit 33 - fi -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/playerctl b/.i3-blocks/blocks/playerctl deleted file mode 100755 index 6d613ed..0000000 --- a/.i3-blocks/blocks/playerctl +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# Based on https://aur.archlinux.org/packages/playerctl/ - -INSTANCE="${BLOCK_INSTANCE}" - -if [[ "${INSTANCE}" != "" ]]; then - ARGUMENTS="--player ${INSTANCE}" -fi - -ICON_PLAY="➤" -ICON_PAUSE="Ⅱ" -ICON_STOP="≠" -CUR_ICON="" - -if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then - $(playerctl ${ARGUMENTS} previous) -elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then - $(playerctl ${ARGUMENTS} play-pause) -elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then - $(playerctl ${ARGUMENTS} next) -fi - -PLAYER_STATUS=$(playerctl ${ARGUMENTS} status) -INFO_TITLE=$(playerctl ${ARGUMENTS} metadata title) -INFO_ALBUM=$(playerctl ${ARGUMENTS} metadata album) -INFO_ARTIST=$(playerctl ${ARGUMENTS} metadata artist) - -if [[ "${PLAYER_STATUS}" = "Paused" ]]; then - CUR_ICON="${ICON_PAUSE}" -elif [[ "${PLAYER_STATUS}" = "Playing" ]]; then - CUR_ICON="${ICON_PLAY}" -else - CUR_ICON="${ICON_STOP}" -fi - -if [[ "${INFO_TITLE}" != "" ]] && [[ "${INFO_ARTIST}" != "" ]]; then - echo "${INFO_ARTIST} - ${INFO_TITLE} ${CUR_ICON}" - echo "${INFO_ARTIST} - ${INFO_TITLE} ${CUR_ICON}" -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/process b/.i3-blocks/blocks/process deleted file mode 100755 index 078a241..0000000 --- a/.i3-blocks/blocks/process +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -PROG="${BLOCK_INSTANCE:-i3}" - -PROG_REGEX="["$(echo "${PROG}" | cut -c 1)"]"$(echo "${PROG}" | cut -c 2-)" " -PROCESS=$(ps -eo pid,cmd | grep -w ${PROG_REGEX}) - -if [[ "${PROCESS}" ]]; then - echo "ok" - echo "ok" - echo "" -else - echo "na" - echo "na" - echo "" - exit 33 -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/scroll b/.i3-blocks/blocks/scroll deleted file mode 100755 index 677a7fc..0000000 --- a/.i3-blocks/blocks/scroll +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -# IMPORTANT: -# To make this block work, you have to edit your block-command. -# It should point to this file. For best performance, only use it on blocks -# which are wide and that you need to scroll. -# -# Example: -# command=~/.i3-blocks/blocks/scroll $BLOCK_NAME -# markup=pango -# interval=repeat - -PROG="${1}" - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -BLOCK_PATH="${SCRIPT_DIR}/${PROG}" - -INTERVAL=0.17 -MAX_LENGTH=25 -ADD_STR=" | " -ADD_LENGTH=${#ADD_STR} - -if [[ -f "${BLOCK_PATH}" ]]; then - BLOCK_OUT=$(bash "${BLOCK_PATH}") - OUT_TEXT=$(echo "${BLOCK_OUT}" | tail -n 1) -elif [[ "${PROG}" != "" ]]; then - OUT_TEXT=$(${PROG}) - if [[ $? -ne 0 ]]; then - sleep 1 - echo "${PROG}" - echo "${PROG}" - exit 33 - fi -fi - -if [[ "${OUT_TEXT}" ]]; then - CHECK_SUM=$(echo "${PROG}-${BLOCK_INSTANCE}" | md5sum | awk '{print $1}') - - TMP_FILE="/tmp/.scroll-${CHECK_SUM}" - - if [[ -f "${TMP_FILE}" ]]; then - SCROLL_POS=$(cat "${TMP_FILE}") - else - SCROLL_POS=0 - fi - - TEXT_LENGTH=${#OUT_TEXT} - MAX_OFFSET=$((TEXT_LENGTH +ADD_LENGTH -1)) - - if [[ "${TEXT_LENGTH}" -lt "${MAX_LENGTH}" ]]; then - MAX_LENGTH="${TEXT_LENGTH}" - fi - - if [[ "${SCROLL_POS}" -gt "${MAX_OFFSET}" ]]; then - SCROLL_POS=0 - fi - - TEXT_LINE="${OUT_TEXT}${ADD_STR}${OUT_TEXT}${ADD_STR}${OUT_TEXT}" - TEXT_LINE=${TEXT_LINE:$SCROLL_POS:$MAX_LENGTH} - - echo "<span font_family='monospace'>${TEXT_LINE}</span>" - echo "<span font_family='monospace'>${TEXT_LINE}</span>" - - SCROLL_POS=$((SCROLL_POS +1)) - - echo "${SCROLL_POS}" > "${TMP_FILE}" - sleep "${INTERVAL}" -else - sleep 1 -fi diff --git a/.i3-blocks/blocks/space b/.i3-blocks/blocks/space deleted file mode 100755 index 6e78d19..0000000 --- a/.i3-blocks/blocks/space +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -INSTANCE="${BLOCK_INSTANCE}" -URGENT_VALUE=90 - -if [[ "${INSTANCE}" = "" ]]; then - INSTANCE="$HOME;free" -fi - -DISPLAY=$(echo "${INSTANCE}" | awk -F ';' '{print $2}') -INSTANCE=$(echo "${INSTANCE}" | awk -F ';' '{print $1}') - -if [[ "${DISPLAY}" = "" ]]; then - DISPLAY="free" -fi - -SPACE_VARS=$(df -h "${INSTANCE}" | tail -n 1 | awk '{$1="";$6="";print $0}') -PERC_SPACE=$(echo "${SPACE_VARS}" | awk -F ' ' '{print $4}' | tr -d '%') - -if [[ "${DISPLAY}" = "max" ]]; then - VALUE=$(echo "${SPACE_VARS}" | awk -F ' ' '{print $1}') -elif [[ "${DISPLAY}" = "used" ]]; then - VALUE=$(echo "${SPACE_VARS}" | awk -F ' ' '{print $2}') -elif [[ "${DISPLAY}" = "free" ]]; then - VALUE=$(echo "${SPACE_VARS}" | awk -F ' ' '{print $3}') -elif [[ "${DISPLAY}" = "perc" ]]; then - VALUE="${PERC_SPACE}%" -fi - -if [[ "${VALUE}" ]]; then - echo "${VALUE}" - echo "${VALUE}" - echo "" -fi - -if [[ "${PERC_SPACE}" -gt "${URGENT_VALUE}" ]]; then - exit 33 -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/ssid b/.i3-blocks/blocks/ssid deleted file mode 100755 index d95c721..0000000 --- a/.i3-blocks/blocks/ssid +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -SSID_NAME=$(iwgetid -r) - -# You can put any urgent name so the block will give warning -# if a network with this name is used, like public wifi or alike. -# You can separate multiple values with \| -URGENT_VALUE="" - -if [[ "${SSID_NAME}" != "" ]]; then - echo "${SSID_NAME}" - echo "${SSID_NAME}" - echo "" - - if [[ "${URGENT_VALUE}" != "" ]] && [[ $(echo "${SSID_NAME}" | grep -we "${URGENT_VALUE}") != "" ]]; then - exit 33 - fi -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/temperature b/.i3-blocks/blocks/temperature deleted file mode 100755 index 0c4b858..0000000 --- a/.i3-blocks/blocks/temperature +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -TEMP_DEVICE="${BLOCK_INSTANCE:-Core}" -TEMP_OUTPUT=$(sensors | grep "${TEMP_DEVICE}") - -IS_URGENT=0 - -TOTAL_TEMP=0 -TOTAL_COUNT=0 -while read RESULT_LINE; do - TOTAL_COUNT=$((TOTAL_COUNT +1)) - CURRENT_TEMP=$(echo "${RESULT_LINE}" | grep -o -E "[\+\-]?[0-9]*.[0-9]*°C" | sed -n '1p' | tr -d '+°C') - URGENT_VALUE=$(echo "${RESULT_LINE}" | grep -o -E "[\+\-]?[0-9]*.[0-9]*°C" | sed -n '2p' | tr -d '+°C') - - TOTAL_TEMP=$(echo "scale=2;${TOTAL_TEMP}+${CURRENT_TEMP}" | bc -l) - IS_CRITICAL=$(echo "scale=0;${CURRENT_TEMP}-${URGENT_VALUE} >= 0" | bc -l) - - if [[ "${IS_CRITICAL}" -eq 1 ]]; then - IS_URGENT=1 - fi -done <<< "$(echo -e "$TEMP_OUTPUT")" - -AVERAGE_TEMP=$(echo "scale=0;${TOTAL_TEMP}/${TOTAL_COUNT}" | bc -l) - -if [[ "${TOTAL_COUNT}" -gt 1 ]]; then - AVERAGE_TEMP="~ ${AVERAGE_TEMP}" -fi - -echo "${AVERAGE_TEMP}°C" -echo "${AVERAGE_TEMP}°C" -echo "" - -if [[ "${IS_URGENT}" -eq 1 ]]; then - exit 33 -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/trash b/.i3-blocks/blocks/trash deleted file mode 100755 index b567a54..0000000 --- a/.i3-blocks/blocks/trash +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -TRASH_DIRECTORY="${BLOCK_INSTANCE}" - -if [[ "${TRASH_DIRECTORY}" = "" ]]; then - TRASH_DIRECTORY="${XDG_DATA_HOME:-${HOME}/.local/share}/Trash" -fi - -# Left click -if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then - xdg-open "${TRASH_DIRECTORY}/files" -# Right click -elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then - # Delete all files permanently (unlink them) - rm -r "${TRASH_DIRECTORY}/files" - rm -r "${TRASH_DIRECTORY}/info" - # Create new directory - mkdir "${TRASH_DIRECTORY}/files" - mkdir "${TRASH_DIRECTORY}/info" -fi - -TRASH_COUNT=$(ls -U -1 "${TRASH_DIRECTORY}/files" | wc -l) - -URGENT_VALUE=100 - -echo "${TRASH_COUNT}" -echo "${TRASH_COUNT}" -echo "" - -if [[ "${TRASH_COUNT}" -ge "${URGENT_VALUE}" ]]; then - exit 33 -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/usb b/.i3-blocks/blocks/usb deleted file mode 100755 index e294e7d..0000000 --- a/.i3-blocks/blocks/usb +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -DEVICE_NAME="${BLOCK_INSTANCE:-Keyboard}" - -DEVICE_INFO=$(lsusb | grep -i "${DEVICE_NAME}") - -if [[ "${DEVICE_INFO}" != "" ]]; then - echo "on" - echo "on" - echo "" -else - echo "na" - echo "na" - echo "" -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/user b/.i3-blocks/blocks/user deleted file mode 100755 index f9391ad..0000000 --- a/.i3-blocks/blocks/user +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/bash - -echo "${USER}" -echo "${USER}" -echo "" - -if [[ $(id -u) -eq 0 ]]; then - exit 33 -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/vpn b/.i3-blocks/blocks/vpn deleted file mode 100755 index 8e54938..0000000 --- a/.i3-blocks/blocks/vpn +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -VPNC_FILE='/var/run/vpnc.pid' - -if [[ -e "${VPNC_FILE}" ]]; then - echo "on" - echo "on" - echo "" -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/weather b/.i3-blocks/blocks/weather deleted file mode 100755 index 4eb3efe..0000000 --- a/.i3-blocks/blocks/weather +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# Based on http://openweathermap.org/current - -API_KEY="44db6a862fba0b067b1930da0d769e98" - -# Check on http://openweathermap.org/find -CITY_ID="${BLOCK_INSTANCE}" - -URGENT_LOWER=0 -URGENT_HIGHER=30 - -ICON_SUNNY="" -ICON_CLOUDY="" -ICON_RAINY="" -ICON_STORM="" -ICON_SNOW="" -ICON_FOG="" - -SYMBOL_CELSIUS="℃" - -WEATHER_URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&appid=${API_KEY}&units=metric" - -WEATHER_INFO=$(wget -qO- "${WEATHER_URL}") -WEATHER_MAIN=$(echo "${WEATHER_INFO}" | grep -o -e '\"main\":\"[a-Z]*\"' | awk -F ':' '{print $2}' | tr -d '"') -WEATHER_TEMP=$(echo "${WEATHER_INFO}" | grep -o -e '\"temp\":\-\?[0-9]*' | awk -F ':' '{print $2}' | tr -d '"') - -if [[ "${WEATHER_MAIN}" = *Snow* ]]; then - echo "${ICON_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" - echo "${ICON_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" - echo "" -elif [[ "${WEATHER_MAIN}" = *Rain* ]] || [[ "${WEATHER_MAIN}" = *Drizzle* ]]; then - echo "${ICON_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" - echo "${ICON_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" - echo "" -elif [[ "${WEATHER_MAIN}" = *Cloud* ]]; then - echo "${ICON_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" - echo "${ICON_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" - echo "" -elif [[ "${WEATHER_MAIN}" = *Clear* ]]; then - echo "${ICON_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" - echo "${ICON_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" - echo "" -elif [[ "${WEATHER_MAIN}" = *Fog* ]] || [[ "${WEATHER_MAIN}" = *Mist* ]]; then - echo "${ICON_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" - echo "${ICON_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" - echo "" -else - echo "${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" - echo "${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" - echo "" -fi - -if [[ "${WEATHER_TEMP}" -lt "${URGENT_LOWER}" ]] || [[ "${WEATHER_TEMP}" -gt "${URGENT_HIGHER}" ]]; then - exit 33 -fi diff --git a/.i3-blocks/blocks/webcam b/.i3-blocks/blocks/webcam deleted file mode 100755 index 3c8eae9..0000000 --- a/.i3-blocks/blocks/webcam +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -if [[ -c /dev/video0 ]]; then - if [[ "$(fuser /dev/video0)" != "" ]]; then - echo "rec" - echo "rec" - echo "" - else - echo "on" - echo "on" - echo "" - else - echo "off" - echo "off" - echo "" - fi -fi \ No newline at end of file diff --git a/.i3-blocks/blocks/window b/.i3-blocks/blocks/window deleted file mode 100644 index 9ef155a..0000000 --- a/.i3-blocks/blocks/window +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -ACTIVE_WINDOW=$(xprop -id $(xprop -root _NET_ACTIVE_WINDOW | cut -d ' ' -f 5) WM_NAME | cut -d '"' -f 2) - -if [[ "${ACTIVE_WINDOW}" != "" ]]; then - echo "${ACTIVE_WINDOW}" - echo "${ACTIVE_WINDOW}" - echo "" -fi \ No newline at end of file diff --git a/.i3blocks.conf b/.i3blocks.conf deleted file mode 100644 index 2be3871..0000000 --- a/.i3blocks.conf +++ /dev/null @@ -1,159 +0,0 @@ -# i3blocks config file -# -# Please see man i3blocks for a complete reference! -# The man page is also hosted at http://vivien.github.io/i3blocks -# -# List of valid properties: -# -# align -# color -# command -# full_text -# instance -# interval -# label -# min_width -# name -# separator -# separator_block_width -# short_text -# signal -# urgent - -# Global properties -# -# The top properties below are applied to every block, but can be overridden. -# Each block command defaults to the script name to avoid boilerplate. -command=/usr/lib/i3blocks/$BLOCK_NAME -separator_block_width=15 -markup=none - -[cmus] -command=~/.i3-blocks/blocks/cmus -label= -markup=pango -interval=repeat - -# Volume indicator -# -# The first parameter sets the step (and units to display) -# The second parameter overrides the mixer selection -# See the script for details. -[volume] -label= -#label=♪ -instance=Master -#instance=PCM -interval=once -signal=10 - -# Memory usage -# -# The type defaults to "mem" if the instance is not specified. -[memory] -label=MEM -separator=false -interval=30 - -#[memory] -#label=SWAP -#instance=swap -#separator=false -#interval=30 - -# Disk usage -# -# The directory defaults to $HOME if the instance is not specified. -# The script may be called with a optional argument to set the alert -# (defaults to 10 for 10%). -[disk] -label=HOME -#instance=/mnt/data -interval=30 - -# Network interface monitoring -# -# If the instance is not specified, use the interface used for default route. -# The address can be forced to IPv4 or IPv6 with -4 or -6 switches. -[iface] -#instance=wlan0 -color=#00FF00 -interval=10 -separator=false - -[wifi] -#instance=wlp3s0 -interval=10 -separator=false - -[bandwidth] -#instance=eth0 -interval=5 - -# CPU usage -# -# The script may be called with -w and -c switches to specify thresholds, -# see the script for details. -[cpu_usage] -label=CPU -interval=10 -min_width=CPU: 100.00% -#separator=false - -#[load_average] -#interval=10 - -# Battery indicator -# -# The battery instance defaults to 0. -#[battery] -#label=BAT -#label=⚡ -#instance=1 -#interval=30 - -# Date Time -# -[time] -command=date '+%Y-%m-%d %H:%M:%S' -interval=1 - -# Generic media player support -# -# This displays "ARTIST - SONG" if a music is playing. -# Supported players are: spotify, vlc, audacious, xmms2, mplayer, and others. -#[mediaplayer] -#instance=spotify -#interval=5 -#signal=10 - -# OpenVPN support -# -# Support multiple VPN, with colors. -#[openvpn] -#interval=20 - -# Temperature -# -# Support multiple chips, though lm-sensors. -# The script may be called with -w and -c switches to specify thresholds, -# see the script for details. -#[temperature] -#label=TEMP -#interval=10 - -# Key indicators -# -# Add the following bindings to i3 config file: -# -# bindsym --release Caps_Lock exec pkill -SIGRTMIN+11 i3blocks -# bindsym --release Num_Lock exec pkill -SIGRTMIN+11 i3blocks -#[keyindicator] -#instance=CAPS -#interval=once -#signal=11 - -#[keyindicator] -#instance=NUM -#interval=once -#signal=11 diff --git a/.vimrc b/.vimrc index b5bbb6f..fde799d 100644 --- a/.vimrc +++ b/.vimrc @@ -1,3 +1,6 @@ +execute pathogen#infect() +autocmd vimenter * NERDTree + """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " MiniVim " Details on : https://github.com/sd65/MiniVim diff --git a/README.md b/README.md index 56f9241..651ec14 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,27 @@ -- i3-gaps -- i3blocks +# i3 + +## packages + - i3-gaps + - i3blocks + +## files paths + - config -> ~/.config/i3/config + - myconf.sh -> ~/.config/i3/myconf.sh + - who.sh -> ~/.config/i3/who.sh + - blocks/* -> ~/.i3-blocks/blocks/ + - .i3blocks.conf -> ~/.i3blocks.conf + +# vim + +## files paths + - .vimrc -> ~/.vimrc + +## khal + +## files paths + -khal.conf -> ~/.config/khal/khal.conf + +## khard + +## files paths + - khard.conf -> ~/.config/khard/khard.conf diff --git a/i3/.i3blocks.conf b/i3/.i3blocks.conf new file mode 100644 index 0000000..2be3871 --- /dev/null +++ b/i3/.i3blocks.conf @@ -0,0 +1,159 @@ +# i3blocks config file +# +# Please see man i3blocks for a complete reference! +# The man page is also hosted at http://vivien.github.io/i3blocks +# +# List of valid properties: +# +# align +# color +# command +# full_text +# instance +# interval +# label +# min_width +# name +# separator +# separator_block_width +# short_text +# signal +# urgent + +# Global properties +# +# The top properties below are applied to every block, but can be overridden. +# Each block command defaults to the script name to avoid boilerplate. +command=/usr/lib/i3blocks/$BLOCK_NAME +separator_block_width=15 +markup=none + +[cmus] +command=~/.i3-blocks/blocks/cmus +label= +markup=pango +interval=repeat + +# Volume indicator +# +# The first parameter sets the step (and units to display) +# The second parameter overrides the mixer selection +# See the script for details. +[volume] +label= +#label=♪ +instance=Master +#instance=PCM +interval=once +signal=10 + +# Memory usage +# +# The type defaults to "mem" if the instance is not specified. +[memory] +label=MEM +separator=false +interval=30 + +#[memory] +#label=SWAP +#instance=swap +#separator=false +#interval=30 + +# Disk usage +# +# The directory defaults to $HOME if the instance is not specified. +# The script may be called with a optional argument to set the alert +# (defaults to 10 for 10%). +[disk] +label=HOME +#instance=/mnt/data +interval=30 + +# Network interface monitoring +# +# If the instance is not specified, use the interface used for default route. +# The address can be forced to IPv4 or IPv6 with -4 or -6 switches. +[iface] +#instance=wlan0 +color=#00FF00 +interval=10 +separator=false + +[wifi] +#instance=wlp3s0 +interval=10 +separator=false + +[bandwidth] +#instance=eth0 +interval=5 + +# CPU usage +# +# The script may be called with -w and -c switches to specify thresholds, +# see the script for details. +[cpu_usage] +label=CPU +interval=10 +min_width=CPU: 100.00% +#separator=false + +#[load_average] +#interval=10 + +# Battery indicator +# +# The battery instance defaults to 0. +#[battery] +#label=BAT +#label=⚡ +#instance=1 +#interval=30 + +# Date Time +# +[time] +command=date '+%Y-%m-%d %H:%M:%S' +interval=1 + +# Generic media player support +# +# This displays "ARTIST - SONG" if a music is playing. +# Supported players are: spotify, vlc, audacious, xmms2, mplayer, and others. +#[mediaplayer] +#instance=spotify +#interval=5 +#signal=10 + +# OpenVPN support +# +# Support multiple VPN, with colors. +#[openvpn] +#interval=20 + +# Temperature +# +# Support multiple chips, though lm-sensors. +# The script may be called with -w and -c switches to specify thresholds, +# see the script for details. +#[temperature] +#label=TEMP +#interval=10 + +# Key indicators +# +# Add the following bindings to i3 config file: +# +# bindsym --release Caps_Lock exec pkill -SIGRTMIN+11 i3blocks +# bindsym --release Num_Lock exec pkill -SIGRTMIN+11 i3blocks +#[keyindicator] +#instance=CAPS +#interval=once +#signal=11 + +#[keyindicator] +#instance=NUM +#interval=once +#signal=11 diff --git a/i3/blocks/audio b/i3/blocks/audio new file mode 100755 index 0000000..c401c68 --- /dev/null +++ b/i3/blocks/audio @@ -0,0 +1,26 @@ +#!/bin/bash + +# Left click +if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then + amixer -q sset Master 5%+ +# Middle click +elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then + amixer -q sset Master toggle +# Right click +elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then + amixer -q sset Master 5%- +fi + +statusLine=$(amixer get Master | tail -n 1) +status=$(echo "${statusLine}" | grep -wo "on") +volume=$(echo "${statusLine}" | awk -F ' ' '{print $5}' | tr -d '[]%') + +if [[ "${status}" == "on" ]]; then + echo "${volume}%" + echo "${volume}%" + echo "" +else + echo "off" + echo "off" + echo "" +fi \ No newline at end of file diff --git a/i3/blocks/bandwidth b/i3/blocks/bandwidth new file mode 100755 index 0000000..f0b18cf --- /dev/null +++ b/i3/blocks/bandwidth @@ -0,0 +1,96 @@ +#!/bin/bash +# Source: http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html + +INSTANCE="${BLOCK_INSTANCE}" + +if [[ "${INSTANCE}" = "" ]]; then + INSTANCE="wlp3s0;both" +fi + +DISPLAY=$(echo "${INSTANCE}" | awk -F ';' '{print $2}') +INSTANCE=$(echo "${INSTANCE}" | awk -F ';' '{print $1}') + +if [[ "${DISPLAY}" = "" ]]; then + DISPLAY="both" +fi + +ONE_KB=1024 +ONE_MB=$(echo "${ONE_KB}*1024" | bc -l) +TEN_MB=$(echo "${ONE_MB}*10" | bc -l) +OHD_MB=$(echo "${TEN_MB}*10" | bc -l) + +URGENT_VALUE="${ONE_MB}" + +PREV_IN=0 +PREV_OUT=0 + +PREV_FILE="/tmp/.bandwidth" + +if [[ -f "${PREV_FILE}" ]]; then + PREV_CONT=$(cat "${PREV_FILE}") + PREV_IN=$(echo "${PREV_CONT}" | head -n 1) + PREV_OUT=$(echo "${PREV_CONT}" | tail -n 1) +fi + +BANDWIDTH=$(grep "${INSTANCE}" /proc/net/dev | awk -F: '{print $2}' | awk '{print $1" "$9}') + +if [[ "${BANDWIDTH}" = "" ]]; then + exit +fi + +BYTES_IN=$(echo "${BANDWIDTH}" | awk -F ' ' '{print $1}') +BYTES_OUT=$(echo "${BANDWIDTH}" | awk -F ' ' '{print $2}') + +function FormatNumber() { + if [[ "${1}" -ge "${OHD_MB}" ]]; then + echo $(echo "scale=0;${1}/${ONE_MB}" | bc -l)"mb" + elif [[ "${1}" -ge "${TEN_MB}" ]]; then + echo $(echo "scale=1;${1}/${ONE_MB}" | bc -l)"mb" + elif [[ "${1}" -ge "${ONE_MB}" ]]; then + echo $(echo "scale=2;${1}/${ONE_MB}" | bc -l)"mb" + elif [[ "${1}" -ge "${ONE_KB}" ]]; then + echo $(echo "scale=0;${1}/${ONE_KB}" | bc -l)"kb" + else + echo "${1}""b" + fi +} + +if [[ "${PREV_IN}" != "" ]] && [[ "${PREV_OUT}" != "" ]]; then + # Calculate the CPU usage since we last checked. + DIFF_IN=$(echo "scale=0;${BYTES_IN} - ${PREV_IN}" | bc -l) + DIFF_OUT=$(echo "scale=0;${BYTES_OUT} - ${PREV_OUT}" | bc -l) + DIFF_TOTAL=0 + + USAGE_IN=$(FormatNumber "${DIFF_IN}") + USAGE_OUT=$(FormatNumber "${DIFF_OUT}") + + if [[ "${DISPLAY}" = "both" ]]; then + echo "${USAGE_IN} : ${USAGE_OUT}" + echo "${USAGE_IN} : ${USAGE_OUT}" + echo "" + DIFF_TOTAL=$((DIFF_TOTAL+DIFF_IN)) + DIFF_TOTAL=$((DIFF_TOTAL+DIFF_OUT)) + elif [[ "${DISPLAY}" = "in" ]]; then + echo "${USAGE_IN}" + echo "${USAGE_IN}" + echo "" + DIFF_TOTAL=$((DIFF_TOTAL+DIFF_IN)) + elif [[ "${DISPLAY}" = "out" ]]; then + echo "${USAGE_OUT}" + echo "${USAGE_OUT}" + echo "" + DIFF_TOTAL=$((DIFF_TOTAL+DIFF_OUT)) + fi +else + echo "?" + echo "?" + echo "" +fi + +# Remember the total and idle CPU times for the next check. +echo "${BYTES_IN}" > "${PREV_FILE}" +echo "${BYTES_OUT}" >> "${PREV_FILE}" + +if [[ "${DIFF_TOTAL}" -ge "${URGENT_VALUE}" ]]; then + exit 33 +fi \ No newline at end of file diff --git a/i3/blocks/battery b/i3/blocks/battery new file mode 100755 index 0000000..3058f36 --- /dev/null +++ b/i3/blocks/battery @@ -0,0 +1,26 @@ +#!/bin/bash + +BATTERY=0 +BATTERY_INFO=$(acpi -b | grep "Battery ${BATTERY}") +BATTERY_STATE=$(echo "${BATTERY_INFO}" | grep -wo "Full\|Charging\|Discharging") +BATTERY_POWER=$(echo "${BATTERY_INFO}" | grep -o '[0-9]\+%' | tr -d '%') + +URGENT_VALUE=10 + +if [[ "${BATTERY_STATE}" = "Charging" ]]; then + echo "${BATTERY_POWER}%+" + echo "${BATTERY_POWER}%+" + echo "" +elif [[ "${BATTERY_STATE}" = "Discharging" ]]; then + echo "${BATTERY_POWER}%-" + echo "${BATTERY_POWER}%-" + echo "" +else + echo "${BATTERY_POWER}%" + echo "${BATTERY_POWER}%" + echo "" +fi + +if [[ "${BATTERY_POWER}" -le "${URGENT_VALUE}" ]]; then + exit 33 +fi \ No newline at end of file diff --git a/i3/blocks/bluetooth b/i3/blocks/bluetooth new file mode 100755 index 0000000..c9673a5 --- /dev/null +++ b/i3/blocks/bluetooth @@ -0,0 +1,20 @@ +#!/bin/bash + +# Left click +if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then + sudo bluetooth on +# Middle click +elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then + sudo bluetooth toggle +# Right click +elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then + sudo bluetooth off +fi + +STATUS=$(bluetooth | grep -wo 'on') + +if [[ "${STATUS}" = "on" ]]; then + echo "on" + echo "on" + echo "" +fi \ No newline at end of file diff --git a/i3/blocks/brightness b/i3/blocks/brightness new file mode 100755 index 0000000..f6294e4 --- /dev/null +++ b/i3/blocks/brightness @@ -0,0 +1,57 @@ +#!/bin/bash + +# One of the following: xrandr, xbacklight, kernel +METHOD="xbacklight" + +# Left click +if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then + xbacklight -inc 5 +# Right click +elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then + xbacklight -dec 5 +fi + +URGENT_VALUE=10 + +if [[ "${METHOD}" = "xrandr" ]]; then + device="${BLOCK_INSTANCE:-primary}" + xrandrOutput=$(xrandr --verbose) + + if [[ "${device}" = "primary" ]]; then + device=$(echo "${xrandrOutput}" | grep 'primary' | head -n 1 | awk -F ' ' '{print $1}') + fi + + curBrightness=$(echo "${xrandrOutput}" | grep "${device}" -A 5 | grep -i "Brightness" | awk -F ':' '{print $2}') +elif [[ "${METHOD}" = "kernel" ]]; then + device="${BLOCK_INSTANCE:-intel_backlight}" + maxBrightness=$(cat /sys/class/backlight/${device}/max_brightness) + curBrightness=$(cat /sys/class/backlight/${device}/brightness) +elif [[ "${METHOD}" = "xbacklight" ]]; then + curBrightness=$(xbacklight -get) +fi + +if [[ "${curBrightness}" -le 0 ]]; then + exit +fi + +if [[ "${METHOD}" = "xrandr" ]]; then + percent=$(echo "scale=0;${curBrightness} * 100" | bc -l) +elif [[ "${METHOD}" = "kernel" ]]; then + percent=$(echo "scale=0;${curBrightness} / ${maxBrightness} * 100" | bc -l) +elif [[ "${METHOD}" = "xbacklight" ]]; then + percent=$(echo "scale=0;${curBrightness}" | bc -l) +fi + +percent=${percent%.*} + +if [[ "${percent}" -le 0 ]]; then + exit +fi + +echo "${percent}%" +echo "${percent}%" +echo "" + +if [[ "${percent}" -le "${URGENT_VALUE}" ]]; then + exit 33 +fi \ No newline at end of file diff --git a/i3/blocks/cmus b/i3/blocks/cmus new file mode 100755 index 0000000..f4d15b3 --- /dev/null +++ b/i3/blocks/cmus @@ -0,0 +1,20 @@ +#!/bin/bash + +INFO_CMUS=$(cmus-remote -Q 2>/dev/null) +if [[ $? -eq 0 ]]; then + INFO_TITLE=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*title//p' | head -n 1) + INFO_ALBUM=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*album//p' | head -n 1) + INFO_ARTIST=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*artist//p' | head -n 1) +else + exit +fi + +if [[ "${INFO_ARTIST}" ]] && [[ "${INFO_TITLE}" ]]; then + OUT_TEXT=$(echo "${INFO_ARTIST} - ${INFO_TITLE}" | xargs) +elif [[ "${INFO_TITLE}" ]]; then + OUT_TEXT=$(echo "${INFO_TITLE}" | xargs) +fi + +echo "${OUT_TEXT}" +echo "${OUT_TEXT}" +exit \ No newline at end of file diff --git a/i3/blocks/countdown b/i3/blocks/countdown new file mode 100755 index 0000000..311a3b7 --- /dev/null +++ b/i3/blocks/countdown @@ -0,0 +1,36 @@ +#!/bin/bash + +END_DATE="${BLOCK_INSTANCE}" + +URGENT_VALUE=86400 + +if [[ "${END_DATE}" = "" ]]; then + END_DATE=$(date --date "next Friday" "+%m/%d/%Y %H:%M:%S") +fi + +END_DATE=$(date --date="${END_DATE}" '+%s') +CUR_DATE=$(date "+%s") +DIFF_DATE=$((END_DATE - CUR_DATE)) +DIFF="" + +if [[ "${DIFF_DATE}" -le 0 ]]; then + echo "${END_DATE}" + echo "${END_DATE}" + echo "" + exit 33 +fi + +if [[ "${DIFF_DATE}" -ge 86400 ]]; then + DIFF="[$((DIFF_DATE / 86400))] " + #DIFF_DATE=$((DIFF_DATE % 86400)) +fi + +DIFF+=$(date -u -d "@${DIFF_DATE}" +"%H:%M:%S") + +echo "${DIFF}" +echo "${DIFF}" +echo "" + +if [[ "${DIFF_DATE}" -le "${URGENT_VALUE}" ]]; then + exit 33 +fi \ No newline at end of file diff --git a/i3/blocks/cpu b/i3/blocks/cpu new file mode 100755 index 0000000..2cb27ad --- /dev/null +++ b/i3/blocks/cpu @@ -0,0 +1,48 @@ +#!/bin/bash +# Source: http://askubuntu.com/a/450136 + +URGENT_VALUE=90 + +PREV_TOTAL=0 +PREV_IDLE=0 + +cpuFile="/tmp/.cpu" + +if [[ -f "${cpuFile}" ]]; then + fileCont=$(cat "${cpuFile}") + PREV_TOTAL=$(echo "${fileCont}" | head -n 1) + PREV_IDLE=$(echo "${fileCont}" | tail -n 1) +fi + +CPU=(`cat /proc/stat | grep '^cpu '`) # Get the total CPU statistics. +unset CPU[0] # Discard the "cpu" prefix. +IDLE=${CPU[4]} # Get the idle CPU time. + +# Calculate the total CPU time. +TOTAL=0 + +for VALUE in "${CPU[@]:0:4}"; do + let "TOTAL=$TOTAL+$VALUE" +done + +if [[ "${PREV_TOTAL}" != "" ]] && [[ "${PREV_IDLE}" != "" ]]; then + # Calculate the CPU usage since we last checked. + let "DIFF_IDLE=$IDLE-$PREV_IDLE" + let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL" + let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10" + echo "${DIFF_USAGE}%" + echo "${DIFF_USAGE}%" + echo "" +else + echo "?" + echo "?" + echo "" +fi + +# Remember the total and idle CPU times for the next check. +echo "${TOTAL}" > "${cpuFile}" +echo "${IDLE}" >> "${cpuFile}" + +if [[ "${DIFF_USAGE}" -gt 0 ]] && [[ "${DIFF_USAGE}" -gt "${URGENT_VALUE}" ]]; then + exit 33 +fi \ No newline at end of file diff --git a/i3/blocks/datetime b/i3/blocks/datetime new file mode 100755 index 0000000..178073f --- /dev/null +++ b/i3/blocks/datetime @@ -0,0 +1,8 @@ +#!/bin/bash + +FORMAT="${BLOCK_INSTANCE:-%H:%M}" +DATETIME=$(date "+${FORMAT}") + +echo "${DATETIME}" +echo "${DATETIME}" +echo "" \ No newline at end of file diff --git a/i3/blocks/display b/i3/blocks/display new file mode 100755 index 0000000..9071900 --- /dev/null +++ b/i3/blocks/display @@ -0,0 +1,68 @@ +#!/bin/bash + +xrandrOut=$(xrandr) + +hdmiName=$(echo "${xrandrOut}" | grep -i 'HDMI' | awk '{print $1}') +vgaName=$(echo "${xrandrOut}" | grep -i 'VGA' | awk '{print $1}') +edpName=$(echo "${xrandrOut}" | grep -i 'EDP' | awk '{print $1}') + +activeDisplays=$(echo "${xrandrOut}" | grep " connected" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/" | tr -s '\n' ' ') +displayFile='/tmp/.displays' + +if [[ -f "${displayFile}" ]]; then + oldDisplays=$(cat "${displayFile}") +else + oldDisplays="" +fi + +if [[ "${oldDisplays}" != "${activeDisplays}" ]]; then + change="yes" +else + change="no" +fi + +# External, HDMI + VGA +if [[ "$activeDisplays" =~ "${hdmiName}" && "$activeDisplays" =~ "${vgaName}" ]]; then + if [[ "${change}" = "yes" ]]; then + $(xrandr --output "${edpName}" --off) + $(xrandr --output "${vgaName}" --auto) + $(xrandr --output "${hdmiName}" --primary --auto) + fi + echo "VGA1 & HDMI" + echo "VGA1 & HDMI" + echo "" +# External, HDMI +elif [[ "$activeDisplays" =~ "${hdmiName}" ]]; then + if [[ "${change}" = "yes" ]]; then + $(xrandr --output "${edpName}" --off) + $(xrandr --output "${vgaName}" --off) + $(xrandr --output "${hdmiName}" --primary --auto) + fi + echo "HDMI" + echo "HDMI" + echo "" +# External, VGA +elif [[ "$activeDisplays" =~ "${vgaName}" ]]; then + if [[ "${change}" = "yes" ]]; then + $(xrandr --output "${edpName}" --off) + $(xrandr --output "${vgaName}" --primary --auto) + $(xrandr --output "${hdmiName}" --off) + fi + echo "VGA" + echo "VGA" + echo +# Only one internal +elif [[ "$activeDisplays" =~ "${edpName}" ]]; then + if [[ "${change}" = "yes" ]]; then + $(xrandr --output "${edpName}" --primary --auto) + $(xrandr --output "${vgaName}" --off) + $(xrandr --output "${hdmiName}" --off) + fi + echo "eDP" + echo "eDP" + echo "" +fi + +if [[ "${change}" = "yes" ]]; then + echo "${activeDisplays}" > "${displayFile}" +fi \ No newline at end of file diff --git a/i3/blocks/feed b/i3/blocks/feed new file mode 100755 index 0000000..0030939 --- /dev/null +++ b/i3/blocks/feed @@ -0,0 +1,31 @@ +#!/bin/bash + +# WARNING: This has a LIMIT of 32 characters for now! +# If your URL is longer you should use an URL shortener +# Caused by https://github.com/vivien/i3blocks/blob/01a4f4a9ca1e3d0b3c95d1d62000ad8506bdff1a/include/block.h#L50 +# Example: https://goo.gl/ +FEED_URL="${BLOCK_INSTANCE:-https://www.archlinux.org/feeds/news/}" + +if [[ "${FEED_URL}" = "" ]]; then + exit +fi + +# Follows redirects! +FEED_CONTENT=$(curl ${FEED_URL} -s -L) +FEED_TITLE=$(echo "${FEED_CONTENT}" | grep -v "xmlns:atom" | grep -o '<title>.*' | head -n 1 | sed 's/\(\|<\/title>\)//g') +FEED_LINK=$(echo "${FEED_CONTENT}" | grep -v "xmlns:atom" | grep -o '<link>.*</link>' | head -n 1 | sed 's/\(<link>\|<\/link>\)//g') + +if [[ "${FEED_TITLE}" = *404* ]]; then + echo "${FEED_URL}" + echo "${FEED_URL}" + echo "" + exit 33 +fi + +if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then + xdg-open "${FEED_LINK}" +fi + +echo "${FEED_TITLE}" +echo "${FEED_TITLE}" +echo "" \ No newline at end of file diff --git a/i3/blocks/firewall b/i3/blocks/firewall new file mode 100755 index 0000000..6fe26f6 --- /dev/null +++ b/i3/blocks/firewall @@ -0,0 +1,28 @@ +#!/bin/bash + +# Left click +if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then + sudo ufw enable +# Middle click +elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then + sudo ufw reload +# Right click +elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then + sudo ufw disable +fi + +status=$(sudo ufw status 2>/dev/null) + +if [[ $? -gt 0 ]]; then + exit +fi + +if [[ "${status}" != *inactive* ]]; then + echo "on" + echo "on" + echo "" +else + echo "off" + echo "off" + echo "" +fi \ No newline at end of file diff --git a/i3/blocks/ip-address b/i3/blocks/ip-address new file mode 100755 index 0000000..d91ab56 --- /dev/null +++ b/i3/blocks/ip-address @@ -0,0 +1,9 @@ +#!/bin/bash + +IP_ADDRESS=$(ip route get 1 | awk '{print $NF;exit}') + +if [[ "${IP_ADDRESS}" != "" ]]; then + echo "${IP_ADDRESS}" + echo "${IP_ADDRESS}" + echo "" +fi \ No newline at end of file diff --git a/i3/blocks/keymap b/i3/blocks/keymap new file mode 100755 index 0000000..f25ee98 --- /dev/null +++ b/i3/blocks/keymap @@ -0,0 +1,27 @@ +#!/bin/bash + +KEYMAP_DIRECTORY='/usr/share/kbd/keymaps' + +# Aprrently localectl status does not update on keymap change. However, setxkbmap does. +XKB_OUTPUT=$(setxkbmap -query) +VC_KEYMAP=$(echo "${XKB_OUTPUT}" | grep "layout" | awk -F ':' '{print $2}' | tr -d ' ') +VC_VARIANT=$(echo "${XKB_OUTPUT}" | grep "variant" | awk -F ':' '{print $2}' | tr -d ' ') + +# Keymap has not been specific, so it's not configured properly +if [[ "${VC_KEYMAP}" == "" ]]; then + exit 1 +fi + +KEYMAP_FILE="${VC_KEYMAP}*" + +if [[ "${VC_VARIANT}" != "" ]]; then + KEYMAP_FILE="${KEYMAP_FILE}${VC_VARIANT}*" +fi + +KEYMAP_NAME=$(basename $(dirname $(find ${KEYMAP_DIRECTORY} -name "${KEYMAP_FILE}"))) + +if [[ "${KEYMAP_NAME}" ]]; then + echo "${KEYMAP_NAME}" + echo "${KEYMAP_NAME}" + echo "" +fi \ No newline at end of file diff --git a/i3/blocks/keystate b/i3/blocks/keystate new file mode 100755 index 0000000..e1543d7 --- /dev/null +++ b/i3/blocks/keystate @@ -0,0 +1,25 @@ +#!/bin/bash + +TYPE="${BLOCK_INSTANCE:-caps}" + +lockLine=$(xset -q | grep "Num Lock") + +capsLock=$(echo "${lockLine}" | awk -F ' ' '{print $4}') +numLock=$(echo "${lockLine}" | awk -F ' ' '{print $8}') +scrollLock=$(echo "${lockLine}" | awk -F ' ' '{print $12}') + +if [[ "${TYPE}" == "caps" ]]; then + checkLock="${capsLock}" +elif [[ "${TYPE}" == "num" ]]; then + checkLock="${numLock}" +elif [[ "${TYPE}" == "scroll" ]]; then + checkLock="${scrollLock}" +else + exit +fi + +if [[ "${checkLock}" == "on" ]]; then + echo "on" + echo "on" + echo "" +fi \ No newline at end of file diff --git a/i3/blocks/launcher b/i3/blocks/launcher new file mode 100755 index 0000000..1e39432 --- /dev/null +++ b/i3/blocks/launcher @@ -0,0 +1,26 @@ +#!/bin/bash + +CONFIG_FILE="${BLOCK_INSTANCE:-~/.config/i3/config}" +CONFIG_FILE=${CONFIG_FILE/\~/$HOME} + +LAUNCH_CMD=$(cat "${CONFIG_FILE}" | grep -v "^#" | grep -wi 'rofi\|dmenu' | awk -F 'exec ' '{print $2}') +LAUNCH_NAME=$(echo "${LAUNCH_CMD}" | awk -F ' ' '{print $1}') + +VARIABLES=$(cat "${CONFIG_FILE}" | grep -E 'set\ \$' | awk -F ' ' '{$1 = "";print $0}') + +while read varPair; do + varName=$(echo "${varPair}" | awk -F ' ' '{print $1}') + varValue=$(echo "${varPair}" | awk -F ' ' '{print $2}') + #echo "Replacing ${varName} with ${varValue}" + LAUNCH_CMD=$(echo ${LAUNCH_CMD} | sed "s|$varName|$varValue|g") +done <<< "$(echo -e "$VARIABLES")" + +#echo "${LAUNCH_CMD}" && exit + +echo "${LAUNCH_NAME}" +echo "${LAUNCH_NAME}" +echo "" + +if [[ "${BLOCK_BUTTON}" -gt 0 ]]; then + eval ${LAUNCH_CMD} & +fi \ No newline at end of file diff --git a/i3/blocks/load b/i3/blocks/load new file mode 100755 index 0000000..448876f --- /dev/null +++ b/i3/blocks/load @@ -0,0 +1,19 @@ +#!/bin/bash + +INSTANCE="${BLOCK_INSTANCE:-1}" + +URGENT_VALUE=90 + +LOAD=$(cat /proc/loadavg | awk -F ' ' '{print $'"${INSTANCE}"'}') +if [[ "${LOAD}" != "" ]]; then + LOAD_PERC=$(echo "scale=0; ${LOAD} * 100" | bc -l) + LOAD_PERC=${LOAD_PERC%.*} + + echo "${LOAD}" + echo "${LOAD}" + echo "" + + if [[ "${LOAD_PERC}" -ge "${URGENT_VALUE}" ]]; then + exit 33 + fi +fi \ No newline at end of file diff --git a/i3/blocks/locale b/i3/blocks/locale new file mode 100755 index 0000000..e517c44 --- /dev/null +++ b/i3/blocks/locale @@ -0,0 +1,10 @@ +#!/bin/bash + +LOCALE_INFO=$(localectl) +LOCALE_NAME=$(echo "${LOCALE_INFO}" | grep "System Locale" | awk -F '=' '{print $2}' | cut -c 1-2) + +if [[ "${LOCALE_NAME}" ]]; then + echo "${LOCALE_NAME}" + echo "${LOCALE_NAME}" + echo "" +fi \ No newline at end of file diff --git a/i3/blocks/mail b/i3/blocks/mail new file mode 100755 index 0000000..66b1d0a --- /dev/null +++ b/i3/blocks/mail @@ -0,0 +1,59 @@ +#!/bin/bash + +# Requires https://www.google.com/settings/security/lesssecureapps for gmail. + +CONFIG_FILE="${BLOCK_INSTANCE}" +CONFIG_FILE=${CONFIG_FILE/\~/$HOME} + +# Config file needs the following settings: +#MAIL_SERVER="imap.domain.tld:993" +#MAIL_USER="user@domain.tld" +#MAIL_PASSWORD="secret" +#MAIL_FOLDER="INBOX" + +if [[ ! -f "${CONFIG_FILE}" ]]; then + echo "${CONFIG_FILE}" + exit 33 +fi + +source "${CONFIG_FILE}" + +MAIN_DOMAIN=$(expr match "${MAIL_SERVER}" '.*\.\(.*\..*\)' | awk -F ':' '{print $1}') + +# Add https so xdg knows that it's a website +if [[ "${MAIN_DOMAIN}" != http* ]]; then + MAIN_DOMAIN="https://${MAIN_DOMAIN}" +fi + +# Left click +if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then + xdg-open "${MAIN_DOMAIN}" +fi + +MAIL_FILE="/tmp/.mail" +URGENT_VALUE="100" + +GET_UNREAD=$(cat<<EOF +? LOGIN "${MAIL_USER}" "${MAIL_PASSWORD}" +? STATUS "${MAIL_FOLDER}" (unseen) +? LOGOUT +EOF +) + +echo "${GET_UNREAD}" | openssl s_client -connect "${MAIL_SERVER}" -crlf -ign_eof > "${MAIL_FILE}" 2>/dev/null +UNREAD_COUNT=$(cat "${MAIL_FILE}" | grep -i "UNSEEN" | grep -oE "[0-9]*" | head -n 1) + +# For security reasons +rm "${MAIL_FILE}" + +if [[ "${UNREAD_COUNT}" = "" ]]; then + exit +fi + +echo "${UNREAD_COUNT}" +echo "${UNREAD_COUNT}" +echo "" + +if [[ "${UNREAD_COUNT}" -ge URGENT_VALUE ]]; then + exit 33 +fi \ No newline at end of file diff --git a/i3/blocks/memory b/i3/blocks/memory new file mode 100755 index 0000000..866e7c3 --- /dev/null +++ b/i3/blocks/memory @@ -0,0 +1,69 @@ +#!/bin/bash + +# First argument is source (mem/swap), second is output value +# Check /proc/meminfo for possible instances +INSTANCE="${BLOCK_INSTANCE:-mem;free}" + +SOURCE=$(echo "${INSTANCE}" | awk -F ';' '{print $1}') +DISPLAY=$(echo "${INSTANCE}" | awk -F ';' '{print $2}') + +if [[ "${SOURCE}" = "mem" ]]; then + URGENT_VALUE=90 +elif [[ "${SOURCE}" = "swap" ]]; then + URGENT_VALUE=50 +fi + +if [[ "${DISPLAY}" = "" ]]; then + DISPLAY="free" +fi + +ONE_KB=1024 +ONE_MB=$(echo "${ONE_KB}*1024" | bc -l) +ONE_GB=$(echo "${ONE_MB}*1024" | bc -l) +ONE_TB=$(echo "${ONE_GB}*1024" | bc -l) + +# Grep the value and remove KB so we can calculate with it later +#MEMINFO=$(cat /proc/meminfo | grep "${INSTANCE}" | awk -F ':' '{print $2}' | tr -d ' kB') +MEMORY_INFOS=$(cat /proc/meminfo) +SOURCE_TOTAL=$(echo "${MEMORY_INFOS}" | grep -i "${SOURCE}total" | awk -F ':' '{print $2}' | tr -d ' kB') + +if [[ "${SOURCE_TOTAL}" -le 0 ]]; then + exit +fi + +SOURCE_FREE=$(echo "${MEMORY_INFOS}" | grep -i "${SOURCE}available" | awk -F ':' '{print $2}' | tr -d ' kB') +SOURCE_USED=$(echo "scale=0; ${SOURCE_TOTAL}-${SOURCE_FREE}" | bc -l) +SOURCE_PERC=$(echo "scale=0; (${SOURCE_USED}*100)/${SOURCE_TOTAL}" | bc -l) + +if [[ "${DISPLAY}" = "free" ]]; then + MEMINFO="${SOURCE_FREE}" +elif [[ "${DISPLAY}" = "used" ]]; then + MEMINFO="${SOURCE_USED}" +elif [[ "${DISPLAY}" = "total" ]]; then + MEMINFO="${SOURCE_TOTAL}" +elif [[ "${DISPLAY}" = "perc" ]]; then + MEMINFO="${SOURCE_PERC}%" +fi + +if [[ "${DISPLAY}" != "perc" ]]; then + # Convert KB meminfo to bytes + MEMINFO=$(echo "${MEMINFO}*${ONE_KB}" | bc -l) + + if [[ "${MEMINFO}" -ge "${ONE_TB}" ]]; then + MEMINFO=$(echo "scale=3;${MEMINFO}/${ONE_TB}" | bc -l)"tb" + elif [[ "${MEMINFO}" -ge "${ONE_GB}" ]]; then + MEMINFO=$(echo "scale=2;${MEMINFO}/${ONE_GB}" | bc -l)"gb" + elif [[ "${MEMINFO}" -ge "${ONE_MB}" ]]; then + MEMINFO=$(echo "scale=1;${MEMINFO}/${ONE_MB}" | bc -l)"mb" + else + MEMINFO=$(echo "scale=0;${MEMINFO}/${ONE_KB}" | bc -l)"kb" + fi +fi + +echo "${MEMINFO}" +echo "${MEMINFO}" +echo "" + +if [[ "${SOURCE_PERC}" -gt "${URGENT_VALUE}" ]]; then + exit 33 +fi \ No newline at end of file diff --git a/i3/blocks/microphone b/i3/blocks/microphone new file mode 100755 index 0000000..76ff3f9 --- /dev/null +++ b/i3/blocks/microphone @@ -0,0 +1,26 @@ +#!/bin/bash + +# Left click +if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then + amixer -q sset Capture 5%+ +# Middle click +elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then + amixer -q sset Capture toggle +# Right click +elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then + amixer -q sset Capture 5%- +fi + +statusLine=$(amixer get Capture | tail -n 1) +status=$(echo "${statusLine}" | grep -wo "on") +volume=$(echo "${statusLine}" | awk -F ' ' '{print $5}' | tr -d '[]%') + +if [[ "${status}" == "on" ]]; then + echo "${volume}%" + echo "${volume}%" + echo "" +else + echo "off" + echo "off" + echo "" +fi \ No newline at end of file diff --git a/i3/blocks/network b/i3/blocks/network new file mode 100755 index 0000000..cb06e87 --- /dev/null +++ b/i3/blocks/network @@ -0,0 +1,23 @@ +#!/bin/bash + +device="${BLOCK_INSTANCE:-wlan0}" +status=$(cat /sys/class/net/${device}/operstate) + +URGENT_VALUE=20 + +if [[ "${status}" == "up" ]]; then + if [[ -d "/sys/class/net/${device}/wireless" ]]; then + quality=$(grep ${device} /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') + echo "${quality}%" + echo "${quality}%" + echo "" + + if [[ "${quality}" -le "${URGENT_VALUE}" ]]; then + exit 33 + fi + else + echo "on" + echo "on" + echo "" + fi +fi \ No newline at end of file diff --git a/i3/blocks/notifier b/i3/blocks/notifier new file mode 100755 index 0000000..35c94f1 --- /dev/null +++ b/i3/blocks/notifier @@ -0,0 +1,185 @@ +#!/bin/bash +# IMPORTANT: +# To make this block work, you have to edit your block-command. +# It should point to this file. For best performance, only use it on blocks +# you want to monitor. +# +# Example: +# command=~/.i3-blocks/blocks/notifier $BLOCK_NAME + +BLOCK_NAME="${1}" + +if [[ "${BLOCK_NAME}" == "" ]] || [[ "${BLOCK_NAME}" == "notifier" ]]; then + exit 1 +fi + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +BLOCK_PATH="${SCRIPT_DIR}/${BLOCK_NAME}" + +if [[ ! -f "${BLOCK_PATH}" ]]; then + exit 1 +fi + +BLOCK_OUT=$(bash "${BLOCK_PATH}") +BLOCK_URGENT=$? + +# Nothing to display. +if [[ "${BLOCK_OUT}" == "" ]]; then + exit "${BLOCK_URGENT}" +fi + +NOTIFY=0 + +NOTIFY_CHANGES="weather display" +NOTIFY_ALWAYS="" +NOTIFY_NEVER="launcher playerctl scroll" + +if [[ "${NOTIFY_NEVER}" != *${BLOCK_NAME}* ]]; then + BLOCK_UCFIRST=$(echo "${BLOCK_NAME}" | head -c 1 | tr [a-z] [A-Z]; echo "${BLOCK_NAME}" | tail -c +2) + + CHECK_SUM=$(echo "${BLOCK_NAME}-${BLOCK_INSTANCE}" | md5sum | awk '{print $1}') + CACHE_FILE="/tmp/.notify-cache-${CHECK_SUM}" + + BLOCK_DESC=$(echo "${BLOCK_OUT}" | head -n 1) + BLOCK_VALUE=$(echo "${BLOCK_OUT}" | tail -n 1) + BLOCK_ICON="" + + if [[ "${NOTIFY_ALWAYS}" == *${BLOCK_NAME}* ]]; then + NOTIFY=1 + elif [[ "${BLOCK_URGENT}" -gt 0 ]]; then + NOTIFY=1 + fi + + VALUE_CHANGED=0 + HAS_CACHEFILE=0 + if [[ -f "${CACHE_FILE}" ]]; then + HAS_CACHEFILE=1 + CACHED_VALUE=$(cat "${CACHE_FILE}") + #MODIFIED_TIME=$(stat -c '%Y' "${CACHE_FILE}") + #CURRENT_TIME=$(date +%s) + #ELAPSED_TIME=$((MODIFIED_TIME - CURRENT_TIME)) + if [[ "${BLOCK_VALUE}" != "${CACHED_VALUE}" ]]; then + VALUE_CHANGED=1 + if [[ "${NOTIFY_CHANGES}" == *${BLOCK_NAME}* ]]; then + NOTIFY=1 + fi + fi + elif [[ "${NOTIFY_CHANGES}" == *${BLOCK_NAME}* ]]; then + NOTIFY=1 + fi + + if [[ "${NOTIFY}" -eq 1 ]]; then + if [[ "${BLOCK_NAME}" == "audio" ]]; then + BLOCK_MESSAGE="Audio level changed to ${BLOCK_VALUE}." + elif [[ "${BLOCK_NAME}" == "bandwidth" ]]; then + BLOCK_MESSAGE="Traffic went to ${BLOCK_VALUE}." + elif [[ "${BLOCK_NAME}" == "battery" ]]; then + BLOCK_MESSAGE="Energy changed to ${BLOCK_VALUE}." + elif [[ "${BLOCK_NAME}" == "countdown" ]]; then + BLOCK_MESSAGE="Remaining time is now ${BLOCK_VALUE}." + elif [[ "${BLOCK_NAME}" == "cpu" ]]; then + BLOCK_MESSAGE="CPU utilization is now ${BLOCK_VALUE}." + elif [[ "${BLOCK_NAME}" == "feed" ]]; then + BLOCK_MESSAGE="Newest article is ${BLOCK_VALUE}." + elif [[ "${BLOCK_NAME}" == "mail" ]]; then + BLOCK_MESSAGE="Unread emails went to ${BLOCK_VALUE}." + elif [[ "${BLOCK_NAME}" == "memory" ]]; then + BLOCK_MESSAGE="Memory utilization is now ${BLOCK_VALUE}." + elif [[ "${BLOCK_NAME}" == "packages" ]]; then + BLOCK_MESSAGE="${BLOCK_VALUE} packages are now ready to update." + elif [[ "${BLOCK_NAME}" == "space" ]]; then + BLOCK_MESSAGE="Space utilization is now ${BLOCK_INSTANCE}." + elif [[ "${BLOCK_NAME}" == "ssid" ]]; then + BLOCK_MESSAGE="SSID changed to ${BLOCK_VALUE}." + elif [[ "${BLOCK_NAME}" == "temperature" ]]; then + BLOCK_MESSAGE="Sensor temperature changed to ${BLOCK_VALUE}." + elif [[ "${BLOCK_NAME}" == "trash" ]]; then + BLOCK_MESSAGE="${BLOCK_VALUE} items are now in the trash." + else + BLOCK_MESSAGE="${BLOCK_UCFIRST} is now ${BLOCK_VALUE}." + fi + + if [[ "${BLOCK_NAME}" == "audio" ]]; then + BLOCK_ICON="audio-volume-high-symbolic" + elif [[ "${BLOCK_NAME}" == "bandwidth" ]]; then + BLOCK_ICON="network-wireless-acquiring-symbolic" + elif [[ "${BLOCK_NAME}" == "battery" ]]; then + BLOCK_ICON="battery-symbolic" + elif [[ "${BLOCK_NAME}" == "bluetooth" ]]; then + BLOCK_ICON="bluetooth-active-symbolic" + elif [[ "${BLOCK_NAME}" == "brightness" ]]; then + BLOCK_ICON="display-brightness-symbolic" + elif [[ "${BLOCK_NAME}" == "cmus" ]]; then + BLOCK_ICON="emblem-music-symbolic" + elif [[ "${BLOCK_NAME}" == "countdown" ]]; then + BLOCK_ICON="document-open-recent-symbolic" + elif [[ "${BLOCK_NAME}" == "cpu" ]]; then + BLOCK_ICON="indicator-cpufreq" + elif [[ "${BLOCK_NAME}" == "datetime" ]]; then + BLOCK_ICON="system-run-symbolic" # TODO + elif [[ "${BLOCK_NAME}" == "device" ]]; then + BLOCK_ICON="system-run-symbolic" # TODO + elif [[ "${BLOCK_NAME}" == "display" ]]; then + BLOCK_ICON="video-display-symbolic" + elif [[ "${BLOCK_NAME}" == "feed" ]]; then + BLOCK_ICON="folder-documents-symbolic" + elif [[ "${BLOCK_NAME}" == "firewall" ]]; then + BLOCK_ICON="changes-prevent-symbolic.svg" # TODO + elif [[ "${BLOCK_NAME}" == "ip-address" ]]; then + BLOCK_ICON="avatar-default-symbolic" # TODO + elif [[ "${BLOCK_NAME}" == "keystate" ]]; then + BLOCK_ICON="format-text-underline-symbolic" # TODO + elif [[ "${BLOCK_NAME}" == "launcher" ]]; then + BLOCK_ICON="system-run-symbolic" + elif [[ "${BLOCK_NAME}" == "load" ]]; then + BLOCK_ICON="indicator-cpufreq" # TODO + elif [[ "${BLOCK_NAME}" == "locale" ]]; then + BLOCK_ICON="format-text-larger-symbolic" + elif [[ "${BLOCK_NAME}" == "mail" ]]; then + BLOCK_ICON="mail-send-symbolic" + elif [[ "${BLOCK_NAME}" == "memory" ]]; then + BLOCK_ICON="drive-harddisk-solidstate-symbolic" # TODO + elif [[ "${BLOCK_NAME}" == "microphone" ]]; then + BLOCK_ICON="audio-input-microphone-symbolic" + elif [[ "${BLOCK_NAME}" == "network" ]]; then + BLOCK_ICON="network-wireless-connected-symbolic" + elif [[ "${BLOCK_NAME}" == "packages" ]]; then + BLOCK_ICON="view-refresh-symbolic" + elif [[ "${BLOCK_NAME}" == "playerctl" ]]; then + BLOCK_ICON="emblem-music-symbolic" + elif [[ "${BLOCK_NAME}" == "process" ]]; then + BLOCK_ICON="process-stop-symbolic" + elif [[ "${BLOCK_NAME}" == "space" ]]; then + BLOCK_ICON="drive-harddisk-solidstate-symbolic" # TODO + elif [[ "${BLOCK_NAME}" == "ssid" ]]; then + BLOCK_ICON="system-users-symbolic" + elif [[ "${BLOCK_NAME}" == "temperature" ]]; then + BLOCK_ICON="object-inverse" # TODO + elif [[ "${BLOCK_NAME}" == "trash" ]]; then + BLOCK_ICON="user-trash-symbolic" + elif [[ "${BLOCK_NAME}" == "usb" ]]; then + BLOCK_ICON="drive-removable-media-usb-symbolic-1" + elif [[ "${BLOCK_NAME}" == "vpn" ]]; then + BLOCK_ICON="dialog-password-symbolic" # TODO + elif [[ "${BLOCK_NAME}" == "weather" ]]; then + BLOCK_ICON="weather-few-clouds-symbolic" + elif [[ "${BLOCK_NAME}" == "webcam" ]]; then + BLOCK_ICON="camera-web-symbolic" + elif [[ "${BLOCK_NAME}" == "window" ]]; then + BLOCK_ICON="view-dual-symbolic" # TODO + fi + + if [[ "${BLOCK_URGENT}" -gt 0 ]]; then + notify-send -u critical -t 5000 -i "${BLOCK_ICON}" -a "i3block-${BLOCK_NAME}" "${BLOCK_UCFIRST}" "${BLOCK_MESSAGE}" + else + notify-send -u normal -t 3500 -i "${BLOCK_ICON}" -a "i3block-${BLOCK_NAME}" "${BLOCK_UCFIRST}" "${BLOCK_MESSAGE}" + fi + fi + + if [[ "${VALUE_CHANGED}" -eq 1 ]] || [[ "${HAS_CACHEFILE}" -eq 0 ]]; then + echo "${BLOCK_VALUE}" > "${CACHE_FILE}" + fi +fi + +echo "${BLOCK_OUT}" +exit "${BLOCK_URGENT}" \ No newline at end of file diff --git a/i3/blocks/packages b/i3/blocks/packages new file mode 100755 index 0000000..923d479 --- /dev/null +++ b/i3/blocks/packages @@ -0,0 +1,20 @@ +#!/usr/bin/bash + +PACKAGES=$(pacman -Qu) + +URGENT_VALUE=25 + +if [[ $? -gt 0 ]]; then + return +fi + +PACKAGE_COUNT=$(echo "${PACKAGES}" | wc -l) + +if [[ "${PACKAGE_COUNT}" -gt 0 ]]; then + echo "${PACKAGE_COUNT}" # full-text + echo "${PACKAGE_COUNT}" # short-text + echo "" + if [[ "${PACKAGE_COUNT}" -gt "${URGENT_VALUE}" ]]; then + exit 33 + fi +fi \ No newline at end of file diff --git a/i3/blocks/playerctl b/i3/blocks/playerctl new file mode 100755 index 0000000..6d613ed --- /dev/null +++ b/i3/blocks/playerctl @@ -0,0 +1,39 @@ +#!/bin/bash +# Based on https://aur.archlinux.org/packages/playerctl/ + +INSTANCE="${BLOCK_INSTANCE}" + +if [[ "${INSTANCE}" != "" ]]; then + ARGUMENTS="--player ${INSTANCE}" +fi + +ICON_PLAY="➤" +ICON_PAUSE="Ⅱ" +ICON_STOP="≠" +CUR_ICON="" + +if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then + $(playerctl ${ARGUMENTS} previous) +elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then + $(playerctl ${ARGUMENTS} play-pause) +elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then + $(playerctl ${ARGUMENTS} next) +fi + +PLAYER_STATUS=$(playerctl ${ARGUMENTS} status) +INFO_TITLE=$(playerctl ${ARGUMENTS} metadata title) +INFO_ALBUM=$(playerctl ${ARGUMENTS} metadata album) +INFO_ARTIST=$(playerctl ${ARGUMENTS} metadata artist) + +if [[ "${PLAYER_STATUS}" = "Paused" ]]; then + CUR_ICON="${ICON_PAUSE}" +elif [[ "${PLAYER_STATUS}" = "Playing" ]]; then + CUR_ICON="${ICON_PLAY}" +else + CUR_ICON="${ICON_STOP}" +fi + +if [[ "${INFO_TITLE}" != "" ]] && [[ "${INFO_ARTIST}" != "" ]]; then + echo "${INFO_ARTIST} - ${INFO_TITLE} ${CUR_ICON}" + echo "${INFO_ARTIST} - ${INFO_TITLE} ${CUR_ICON}" +fi \ No newline at end of file diff --git a/i3/blocks/process b/i3/blocks/process new file mode 100755 index 0000000..078a241 --- /dev/null +++ b/i3/blocks/process @@ -0,0 +1,17 @@ +#!/bin/bash + +PROG="${BLOCK_INSTANCE:-i3}" + +PROG_REGEX="["$(echo "${PROG}" | cut -c 1)"]"$(echo "${PROG}" | cut -c 2-)" " +PROCESS=$(ps -eo pid,cmd | grep -w ${PROG_REGEX}) + +if [[ "${PROCESS}" ]]; then + echo "ok" + echo "ok" + echo "" +else + echo "na" + echo "na" + echo "" + exit 33 +fi \ No newline at end of file diff --git a/i3/blocks/scroll b/i3/blocks/scroll new file mode 100755 index 0000000..677a7fc --- /dev/null +++ b/i3/blocks/scroll @@ -0,0 +1,69 @@ +#!/bin/bash +# IMPORTANT: +# To make this block work, you have to edit your block-command. +# It should point to this file. For best performance, only use it on blocks +# which are wide and that you need to scroll. +# +# Example: +# command=~/.i3-blocks/blocks/scroll $BLOCK_NAME +# markup=pango +# interval=repeat + +PROG="${1}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +BLOCK_PATH="${SCRIPT_DIR}/${PROG}" + +INTERVAL=0.17 +MAX_LENGTH=25 +ADD_STR=" | " +ADD_LENGTH=${#ADD_STR} + +if [[ -f "${BLOCK_PATH}" ]]; then + BLOCK_OUT=$(bash "${BLOCK_PATH}") + OUT_TEXT=$(echo "${BLOCK_OUT}" | tail -n 1) +elif [[ "${PROG}" != "" ]]; then + OUT_TEXT=$(${PROG}) + if [[ $? -ne 0 ]]; then + sleep 1 + echo "${PROG}" + echo "${PROG}" + exit 33 + fi +fi + +if [[ "${OUT_TEXT}" ]]; then + CHECK_SUM=$(echo "${PROG}-${BLOCK_INSTANCE}" | md5sum | awk '{print $1}') + + TMP_FILE="/tmp/.scroll-${CHECK_SUM}" + + if [[ -f "${TMP_FILE}" ]]; then + SCROLL_POS=$(cat "${TMP_FILE}") + else + SCROLL_POS=0 + fi + + TEXT_LENGTH=${#OUT_TEXT} + MAX_OFFSET=$((TEXT_LENGTH +ADD_LENGTH -1)) + + if [[ "${TEXT_LENGTH}" -lt "${MAX_LENGTH}" ]]; then + MAX_LENGTH="${TEXT_LENGTH}" + fi + + if [[ "${SCROLL_POS}" -gt "${MAX_OFFSET}" ]]; then + SCROLL_POS=0 + fi + + TEXT_LINE="${OUT_TEXT}${ADD_STR}${OUT_TEXT}${ADD_STR}${OUT_TEXT}" + TEXT_LINE=${TEXT_LINE:$SCROLL_POS:$MAX_LENGTH} + + echo "<span font_family='monospace'>${TEXT_LINE}</span>" + echo "<span font_family='monospace'>${TEXT_LINE}</span>" + + SCROLL_POS=$((SCROLL_POS +1)) + + echo "${SCROLL_POS}" > "${TMP_FILE}" + sleep "${INTERVAL}" +else + sleep 1 +fi diff --git a/i3/blocks/space b/i3/blocks/space new file mode 100755 index 0000000..6e78d19 --- /dev/null +++ b/i3/blocks/space @@ -0,0 +1,38 @@ +#!/bin/bash + +INSTANCE="${BLOCK_INSTANCE}" +URGENT_VALUE=90 + +if [[ "${INSTANCE}" = "" ]]; then + INSTANCE="$HOME;free" +fi + +DISPLAY=$(echo "${INSTANCE}" | awk -F ';' '{print $2}') +INSTANCE=$(echo "${INSTANCE}" | awk -F ';' '{print $1}') + +if [[ "${DISPLAY}" = "" ]]; then + DISPLAY="free" +fi + +SPACE_VARS=$(df -h "${INSTANCE}" | tail -n 1 | awk '{$1="";$6="";print $0}') +PERC_SPACE=$(echo "${SPACE_VARS}" | awk -F ' ' '{print $4}' | tr -d '%') + +if [[ "${DISPLAY}" = "max" ]]; then + VALUE=$(echo "${SPACE_VARS}" | awk -F ' ' '{print $1}') +elif [[ "${DISPLAY}" = "used" ]]; then + VALUE=$(echo "${SPACE_VARS}" | awk -F ' ' '{print $2}') +elif [[ "${DISPLAY}" = "free" ]]; then + VALUE=$(echo "${SPACE_VARS}" | awk -F ' ' '{print $3}') +elif [[ "${DISPLAY}" = "perc" ]]; then + VALUE="${PERC_SPACE}%" +fi + +if [[ "${VALUE}" ]]; then + echo "${VALUE}" + echo "${VALUE}" + echo "" +fi + +if [[ "${PERC_SPACE}" -gt "${URGENT_VALUE}" ]]; then + exit 33 +fi \ No newline at end of file diff --git a/i3/blocks/ssid b/i3/blocks/ssid new file mode 100755 index 0000000..d95c721 --- /dev/null +++ b/i3/blocks/ssid @@ -0,0 +1,18 @@ +#!/bin/bash + +SSID_NAME=$(iwgetid -r) + +# You can put any urgent name so the block will give warning +# if a network with this name is used, like public wifi or alike. +# You can separate multiple values with \| +URGENT_VALUE="" + +if [[ "${SSID_NAME}" != "" ]]; then + echo "${SSID_NAME}" + echo "${SSID_NAME}" + echo "" + + if [[ "${URGENT_VALUE}" != "" ]] && [[ $(echo "${SSID_NAME}" | grep -we "${URGENT_VALUE}") != "" ]]; then + exit 33 + fi +fi \ No newline at end of file diff --git a/i3/blocks/temperature b/i3/blocks/temperature new file mode 100755 index 0000000..0c4b858 --- /dev/null +++ b/i3/blocks/temperature @@ -0,0 +1,35 @@ +#!/bin/bash + +TEMP_DEVICE="${BLOCK_INSTANCE:-Core}" +TEMP_OUTPUT=$(sensors | grep "${TEMP_DEVICE}") + +IS_URGENT=0 + +TOTAL_TEMP=0 +TOTAL_COUNT=0 +while read RESULT_LINE; do + TOTAL_COUNT=$((TOTAL_COUNT +1)) + CURRENT_TEMP=$(echo "${RESULT_LINE}" | grep -o -E "[\+\-]?[0-9]*.[0-9]*°C" | sed -n '1p' | tr -d '+°C') + URGENT_VALUE=$(echo "${RESULT_LINE}" | grep -o -E "[\+\-]?[0-9]*.[0-9]*°C" | sed -n '2p' | tr -d '+°C') + + TOTAL_TEMP=$(echo "scale=2;${TOTAL_TEMP}+${CURRENT_TEMP}" | bc -l) + IS_CRITICAL=$(echo "scale=0;${CURRENT_TEMP}-${URGENT_VALUE} >= 0" | bc -l) + + if [[ "${IS_CRITICAL}" -eq 1 ]]; then + IS_URGENT=1 + fi +done <<< "$(echo -e "$TEMP_OUTPUT")" + +AVERAGE_TEMP=$(echo "scale=0;${TOTAL_TEMP}/${TOTAL_COUNT}" | bc -l) + +if [[ "${TOTAL_COUNT}" -gt 1 ]]; then + AVERAGE_TEMP="~ ${AVERAGE_TEMP}" +fi + +echo "${AVERAGE_TEMP}°C" +echo "${AVERAGE_TEMP}°C" +echo "" + +if [[ "${IS_URGENT}" -eq 1 ]]; then + exit 33 +fi \ No newline at end of file diff --git a/i3/blocks/trash b/i3/blocks/trash new file mode 100755 index 0000000..b567a54 --- /dev/null +++ b/i3/blocks/trash @@ -0,0 +1,32 @@ +#!/bin/bash + +TRASH_DIRECTORY="${BLOCK_INSTANCE}" + +if [[ "${TRASH_DIRECTORY}" = "" ]]; then + TRASH_DIRECTORY="${XDG_DATA_HOME:-${HOME}/.local/share}/Trash" +fi + +# Left click +if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then + xdg-open "${TRASH_DIRECTORY}/files" +# Right click +elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then + # Delete all files permanently (unlink them) + rm -r "${TRASH_DIRECTORY}/files" + rm -r "${TRASH_DIRECTORY}/info" + # Create new directory + mkdir "${TRASH_DIRECTORY}/files" + mkdir "${TRASH_DIRECTORY}/info" +fi + +TRASH_COUNT=$(ls -U -1 "${TRASH_DIRECTORY}/files" | wc -l) + +URGENT_VALUE=100 + +echo "${TRASH_COUNT}" +echo "${TRASH_COUNT}" +echo "" + +if [[ "${TRASH_COUNT}" -ge "${URGENT_VALUE}" ]]; then + exit 33 +fi \ No newline at end of file diff --git a/i3/blocks/usb b/i3/blocks/usb new file mode 100755 index 0000000..e294e7d --- /dev/null +++ b/i3/blocks/usb @@ -0,0 +1,15 @@ +#!/bin/bash + +DEVICE_NAME="${BLOCK_INSTANCE:-Keyboard}" + +DEVICE_INFO=$(lsusb | grep -i "${DEVICE_NAME}") + +if [[ "${DEVICE_INFO}" != "" ]]; then + echo "on" + echo "on" + echo "" +else + echo "na" + echo "na" + echo "" +fi \ No newline at end of file diff --git a/i3/blocks/user b/i3/blocks/user new file mode 100755 index 0000000..f9391ad --- /dev/null +++ b/i3/blocks/user @@ -0,0 +1,9 @@ +#!/usr/bin/bash + +echo "${USER}" +echo "${USER}" +echo "" + +if [[ $(id -u) -eq 0 ]]; then + exit 33 +fi \ No newline at end of file diff --git a/i3/blocks/vpn b/i3/blocks/vpn new file mode 100755 index 0000000..8e54938 --- /dev/null +++ b/i3/blocks/vpn @@ -0,0 +1,9 @@ +#!/bin/bash + +VPNC_FILE='/var/run/vpnc.pid' + +if [[ -e "${VPNC_FILE}" ]]; then + echo "on" + echo "on" + echo "" +fi \ No newline at end of file diff --git a/i3/blocks/weather b/i3/blocks/weather new file mode 100755 index 0000000..4eb3efe --- /dev/null +++ b/i3/blocks/weather @@ -0,0 +1,55 @@ +#!/bin/bash +# Based on http://openweathermap.org/current + +API_KEY="44db6a862fba0b067b1930da0d769e98" + +# Check on http://openweathermap.org/find +CITY_ID="${BLOCK_INSTANCE}" + +URGENT_LOWER=0 +URGENT_HIGHER=30 + +ICON_SUNNY="" +ICON_CLOUDY="" +ICON_RAINY="" +ICON_STORM="" +ICON_SNOW="" +ICON_FOG="" + +SYMBOL_CELSIUS="℃" + +WEATHER_URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&appid=${API_KEY}&units=metric" + +WEATHER_INFO=$(wget -qO- "${WEATHER_URL}") +WEATHER_MAIN=$(echo "${WEATHER_INFO}" | grep -o -e '\"main\":\"[a-Z]*\"' | awk -F ':' '{print $2}' | tr -d '"') +WEATHER_TEMP=$(echo "${WEATHER_INFO}" | grep -o -e '\"temp\":\-\?[0-9]*' | awk -F ':' '{print $2}' | tr -d '"') + +if [[ "${WEATHER_MAIN}" = *Snow* ]]; then + echo "${ICON_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" + echo "${ICON_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" + echo "" +elif [[ "${WEATHER_MAIN}" = *Rain* ]] || [[ "${WEATHER_MAIN}" = *Drizzle* ]]; then + echo "${ICON_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" + echo "${ICON_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" + echo "" +elif [[ "${WEATHER_MAIN}" = *Cloud* ]]; then + echo "${ICON_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" + echo "${ICON_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" + echo "" +elif [[ "${WEATHER_MAIN}" = *Clear* ]]; then + echo "${ICON_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" + echo "${ICON_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" + echo "" +elif [[ "${WEATHER_MAIN}" = *Fog* ]] || [[ "${WEATHER_MAIN}" = *Mist* ]]; then + echo "${ICON_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" + echo "${ICON_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" + echo "" +else + echo "${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" + echo "${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}" + echo "" +fi + +if [[ "${WEATHER_TEMP}" -lt "${URGENT_LOWER}" ]] || [[ "${WEATHER_TEMP}" -gt "${URGENT_HIGHER}" ]]; then + exit 33 +fi diff --git a/i3/blocks/webcam b/i3/blocks/webcam new file mode 100755 index 0000000..3c8eae9 --- /dev/null +++ b/i3/blocks/webcam @@ -0,0 +1,17 @@ +#!/bin/bash + +if [[ -c /dev/video0 ]]; then + if [[ "$(fuser /dev/video0)" != "" ]]; then + echo "rec" + echo "rec" + echo "" + else + echo "on" + echo "on" + echo "" + else + echo "off" + echo "off" + echo "" + fi +fi \ No newline at end of file diff --git a/i3/blocks/window b/i3/blocks/window new file mode 100644 index 0000000..9ef155a --- /dev/null +++ b/i3/blocks/window @@ -0,0 +1,9 @@ +#!/bin/bash + +ACTIVE_WINDOW=$(xprop -id $(xprop -root _NET_ACTIVE_WINDOW | cut -d ' ' -f 5) WM_NAME | cut -d '"' -f 2) + +if [[ "${ACTIVE_WINDOW}" != "" ]]; then + echo "${ACTIVE_WINDOW}" + echo "${ACTIVE_WINDOW}" + echo "" +fi \ No newline at end of file diff --git a/vim/.vimrc b/vim/.vimrc new file mode 100644 index 0000000..fde799d --- /dev/null +++ b/vim/.vimrc @@ -0,0 +1,541 @@ +execute pathogen#infect() +autocmd vimenter * NERDTree + +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" MiniVim +" Details on : https://github.com/sd65/MiniVim +let g:UseCustomKeyBindings = get(g:, 'UseCustomKeyBindings', "1") +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +""" General options +syntax enable " Enable syntax highlights +set ttyfast " Faster refraw +set mouse=nv " Mouse activated in Normal and Visual Mode +set shortmess+=I " No intro when starting Vim +set smartindent " Smart... indent +set expandtab " Insert spaces instead of tabs +set softtabstop=2 " ... and insert two spaces +set shiftwidth=2 " Indent with two spaces +set incsearch " Search as typing +set hlsearch " Highlight search results +set cursorline " Highligt the cursor line +set showmatch " When a bracket is inserted, briefly jump to the matching one +set matchtime=3 " ... during this time +set virtualedit=onemore " Allow the cursor to move just past the end of the line +set history=100 " Keep 100 undo +set wildmenu " Better command-line completion +set scrolloff=10 " Always keep 10 lines after or before when scrolling +set sidescrolloff=5 " Always keep 5 lines after or before when side scrolling +set noshowmode " Don't display the current mode +set gdefault " The substitute flag g is on +set hidden " Hide the buffer instead of closing when switching +set backspace=indent,eol,start " The normal behaviour of backspace +set showtabline=2 " Always show tabs +set laststatus=2 " Always show status bar +set number " Show the line number +set updatetime=1000 +set ignorecase " Search insensitive +set smartcase " ... but smart +let &showbreak="\u21aa " " Show a left arrow when wrapping text +set encoding=utf-8 " The encoding displayed. +set fileencoding=utf-8 " The encoding written to file. +set synmaxcol=300 " Don't try to highlight long lines +set guioptions-=T " Don't show toolbar in Gvim +set iskeyword+=\- " Complete words containing a dash +" Open all cmd args in new tabs +execute ":silent tab all" + +""" Prevent lag when hitting escape +set ttimeoutlen=0 +set timeoutlen=1000 +au InsertEnter * set timeout +au InsertLeave * set notimeout + +""" When opening a file : - Reopen at last position - Display info +function! GetFileInfo() + let permissions = getfperm(expand('%:p')) + echon &filetype . ", " . GetFileSize() . ", " . permissions +endfunction +function! GetFileSize() + let bytes = getfsize(expand('%:p')) + if bytes <= 0 + return "" + elseif bytes > 1024*1000*1000 + return (bytes / 1024*1000*1000) . "GB" + elseif bytes > 1024*1000 + return (bytes / 1024*1000) . "MB" + elseif bytes > 1024 + return (bytes / 1024) . "KB" + else + return bytes . "B" + endif +endfunction +au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif | call GetFileInfo() + +""" Custom backup and swap files +let myVimDir = expand("$HOME/.vim") +let myBackupDir = myVimDir . '/backup' +let mySwapDir = myVimDir . '/swap' +function! EnsureDirExists (dir) + if !isdirectory(a:dir) + call mkdir(a:dir,'p') + endif +endfunction +call EnsureDirExists(myVimDir) +call EnsureDirExists(myBackupDir) +call EnsureDirExists(mySwapDir) +set backup +set backupskip=/tmp/* +set backupext=.bak +let &directory = mySwapDir +let &backupdir = myBackupDir +set writebackup + +""" Smart Paste +let &t_ti .= "\<Esc>[?2004h" +let &t_te .= "\<Esc>[?2004l" +function! XTermPasteBegin(ret) + set pastetoggle=<f29> + set paste + return a:ret +endfunction +execute "set <f28>=\<Esc>[200~" +execute "set <f29>=\<Esc>[201~" +map <expr> <f28> XTermPasteBegin("i") +imap <expr> <f28> XTermPasteBegin("") +vmap <expr> <f28> XTermPasteBegin("c") +cmap <f28> <nop> +cmap <f29> <nop> + +""" Key mappings +if g:UseCustomKeyBindings + +" Helper functions +function! CreateShortcut(keys, cmd, where, ...) + let keys = "<" . a:keys . ">" + if a:where =~ "i" + let i = (index(a:000,"noTrailingIInInsert") > -1) ? "" : "i" + let e = (index(a:000,"noLeadingEscInInsert") > -1) ? "" : "<esc>" + execute "imap " . keys . " " . e . a:cmd . i + endif + if a:where =~ "n" + execute "nmap " . keys . " " . a:cmd + endif + if a:where =~ "v" + let k = (index(a:000,"restoreSelectionAfter") > -1) ? "gv" : "" + let c = a:cmd + if index(a:000,"cmdInVisual") > -1 + let c = ":<C-u>" . strpart(a:cmd,1) + endif + execute "vmap " . keys . " " . c . k + endif +endfunction +function! TabIsEmpty() + return winnr('$') == 1 && len(expand('%')) == 0 && line2byte(line('$') + 1) <= 2 +endfunction +function! MyQuit() + if TabIsEmpty() == 1 + q! + else + if &modified + if (confirm("YOU HAVE UNSAVED CHANGES! Wanna quit anyway?", "&Yes\n&No", 2)==1) + q! + endif + else + q + endif + endif +endfunction +function! MySave() + let cantSave = "echo \"Can't save the file: \" . v:exception | return" + let notSaved = "redraw | echo 'This buffer was NOT saved!' | return" + try + silent w + catch /:E45:\|:E505:\|:E212:/ + if (confirm("This buffer is read only! Wanna save it anyway?", "&Yes\n&No", 2)==1) + try + silent w! + catch /:E212:/ + if (confirm("Can't open the file, do you want to save it as root?", "&Yes\n&No", 2)==1) + try + w !sudo tee % > /dev/null + edit! + catch + exe cantSave + endtry + else + exe notSaved + endif + catch + exe cantSave + endtry + else + exe notSaved + endif + catch /:E32:/ + if (confirm("This buffer has no file to be saved in! Wanna choose it?", "&Yes\n&No", 2)==1) + call feedkeys("\<Esc>:w ") + else + exe notSaved + endif + catch + exe cantSave + endtry + let time = strftime("%T") + let file = expand('%:p') + let permissions = getfperm(file) + echom file . " saved at " . time | redraw + echohl iGreen | echon " SAVED " + echohl Green | echon " " . GetFileSize() . ", " . time . ", " . permissions + echohl None +endfunction +function! OpenLastBufferInNewTab() + redir => ls_output + silent exec 'ls' + redir END + let ListBuffers = reverse(split(ls_output, "\n")) + for line in ListBuffers + let title = split(line, "\"")[1] + if title !~ "\[No Name" + execute "tabnew +" . split(line, " ")[0] . "buf" + break + endif + endfor +endfunction +function! ToggleColorColumn() + if &colorcolumn != 0 + windo let &colorcolumn = 0 + else + windo let &colorcolumn = 80 + endif +endfunction +function! MyPasteToggle() + set invpaste + echo "Paste" (&paste) ? "On" : "Off" +endfunction +function! OpenNetrw() + if TabIsEmpty() == 1 + Explore + else + Texplore + endif +endfunction +function! MenuNetrw() + let c = input("What to you want to do? (M)ake a dir, Make a (F)ile, (R)ename, (D)elete : ") + if (c == "m" || c == "M") + normal d + elseif (c == "f" || c == "F") + normal % + elseif (c == "r" || c == "R") + normal R + elseif (c == "d" || c == "D") + normal D + endif +endfunction + +" Usefull shortcuts to enter insert mode +nnoremap <CR> i<CR> +nnoremap <Backspace> i<Backspace> +nnoremap <Space> i<Space> + +" Ctrl A - Begin Line +call CreateShortcut("C-a", "0", "inv") + +" Ctrl E - End Line +call CreateShortcut("C-e", "$l", "inv") + +" Ctrl S - Save +call CreateShortcut("C-s", ":call MySave()<CR>", "nv", "cmdInVisual", "restoreSelectionAfter") +call CreateShortcut("C-s", ":call MySave()<CR>i<Right>", "i", "noTrailingIInInsert") + +" Home - Go To Begin +call CreateShortcut("Home", "gg", "inv") + +" End - Go To End +call CreateShortcut("End", "G", "inv") + +" Ctrl K - Delete Line +call CreateShortcut("C-k", "dd", "in") +call CreateShortcut("C-k", "d", "v") + +" Ctrl Q - Duplicate Line +call CreateShortcut("C-q", "mjyyp`jjl", "i") +call CreateShortcut("C-q", "mjyyp`jj", "n") +call CreateShortcut("C-q", "y`]p", "v") + +" Ctrl Down - Pagedown +call CreateShortcut("C-Down", "15j", "inv") + +" Ctrl Up - Pageup +call CreateShortcut("C-Up", "15k", "inv") + +" Ctrl Right - Next Word +call CreateShortcut("C-Right", "w", "nv") + +" Ctrl Left - Previous Word +call CreateShortcut("C-Left", "b", "nv") + +" Ctrl F - Find +call CreateShortcut("C-f", "/", "in", "noTrailingIInInsert") + +" Ctrl H - Search and Replace +call CreateShortcut("C-h", ":%s/", "in", "noTrailingIInInsert") + +" Ctrl G - Search and Replace on the line only +call CreateShortcut("C-g", ":s/", "in", "noTrailingIInInsert") + +" Ctrl L - Delete all lines +call CreateShortcut("C-l", "ggdG", "in") + +" Pageup - Move up Line +call CreateShortcut("PageUp", ":m-2<CR>", "in") +call CreateShortcut("PageUp", "dkP", "v") + +" Pagedown - Move down Line +call CreateShortcut("PageDown", ":m+<CR>", "in") +call CreateShortcut("PageDown", "dp", "v") + +" Ctrl C - Quit +call CreateShortcut("C-c", ":call MyQuit()<CR>", "inv", "cmdInVisual") + +" Tab - Indent +call CreateShortcut("Tab", ">>", "n") +call CreateShortcut("Tab", ">", "v", "restoreSelectionAfter") + +" Shift Tab - UnIndent +call CreateShortcut("S-Tab", "<<", "in") +call CreateShortcut("S-Tab", "<", "v", "restoreSelectionAfter") + +" Ctrl Z - Undo +call CreateShortcut("C-z", "u", "in") + +" Ctrl R - Redo +call CreateShortcut("C-r", "<C-r>", "in") + +" Ctrl D - Suppr (the key) +call CreateShortcut("C-d", "<del>", "iv", "noLeadingEscInInsert", "noTrailingIInInsert") +call CreateShortcut("C-d", "x", "n") + +" Ctrl T - New tab +call CreateShortcut("C-t", ":tabnew<CR>i", "inv", "noTrailingIInInsert", "cmdInVisual") + +" Alt Right - Next tab +call CreateShortcut("A-Right", "gt", "inv") + +" Alt Left - Previous tab +call CreateShortcut("A-Left", "gT", "inv") + +" F2 - Paste toggle +call CreateShortcut("f2",":call MyPasteToggle()<CR>", "n") + +" F3 - Line numbers toggle +call CreateShortcut("f3",":set nonumber!<CR>", "in") + +" F4 - Panic Button +call CreateShortcut("f4","mzggg?G`z", "inv") + +" F6 - Toggle color column at 80th char +call CreateShortcut("f6",":call ToggleColorColumn()<CR>", "inv") + +" Ctrl O - Netrw (:Explore) +call CreateShortcut("C-o",":call OpenNetrw()<CR>", "inv", "noTrailingIInInsert", "cmdInVisual") +let g:netrw_banner=0 " Hide banner +let g:netrw_list_hide='\(^\|\s\s\)\zs\.\S\+' " Hide hidden files +autocmd FileType netrw call KeysInNetrw() +function! KeysInNetrw() + " Right to enter + nmap <buffer> <Right> <CR> + " Left to go up + nmap <buffer> <Left> - + " l - Display info + nmap <buffer> l qf + " n - Menu + nmap <buffer> n :call MenuNetrw()<CR> +endfunction + +endif " End custom key bindings + +""" Custom commands + +" :UndoCloseTab - To undo close tab +command! UndoCloseTab call OpenLastBufferInNewTab() + +" :RemoveTrailingSpaces - To remove unwanted space(s) at the end of lines +command! RemoveTrailingSpaces %s/\s\+$ + +""" Colors and Statusline + +let defaultAccentColor=161 +let colorsAndModes= { + \ 'i' : 39, + \ 'v' : 82, + \ 'V' : 226, + \ '' : 208, +\} +let defaultAccentColorGui='#d7005f' +let colorsAndModesGui= { + \ 'i' : '#00afff', + \ 'v' : '#5fff00', + \ 'V' : '#ffff00', + \ '' : '#ff8700', +\} +function! ChangeAccentColor() + let accentColor=get(g:colorsAndModes, mode(), g:defaultAccentColor) + let accentColorGui=get(g:colorsAndModesGui, mode(), g:defaultAccentColorGui) + execute 'hi User1 ctermfg=0 guifg=#000000 ctermbg=' . accentColor . ' guibg=' . accentColorGui + execute 'hi User2 ctermbg=0 guibg=#2e3436 ctermfg=' . accentColor . ' guifg=' . accentColorGui + execute 'hi User3 ctermfg=0 guifg=#000000 cterm=bold gui=bold ctermbg=' . accentColor . ' guibg=' . accentColorGui + execute 'hi TabLineSel ctermfg=0 cterm=bold ctermbg=' . accentColor + execute 'hi TabLine ctermbg=0 ctermfg=' . accentColor + execute 'hi CursorLineNr ctermfg=' . accentColor . ' guifg=' . accentColorGui + return '' +endfunction +function! ReadOnly() + return (&readonly || !&modifiable) ? 'Read Only ' : '' +endfunction +function! Modified() + return (&modified) ? 'Modified' : 'Not modified' +endfunction +let g:currentmode={ + \ 'n' : 'Normal', + \ 'no' : 'N·Operator Pending', + \ 'v' : 'Visual', + \ 'V' : 'V·Line', + \ '' : 'V·Block', + \ 's' : 'Select', + \ 'S' : 'S·Line', + \ '^S' : 'S·Block', + \ 'i' : 'Insert', + \ 'R' : 'Replace', + \ 'Rv' : 'VReplace', + \ 'c' : 'Command', + \ 'cv' : 'Vim Ex', + \ 'ce' : 'Ex', + \ 'r' : 'Prompt', + \ 'rm' : 'More', + \ 'r?' : 'Confirm', + \ '!' : 'Shell', + \ 't' : 'Terminal', +\} +set statusline= +set statusline+=%{ChangeAccentColor()} +set statusline+=%1*\ ***%{toupper(g:currentmode[mode()])}***\ " Current mode +set statusline+=%2*\ %<%F\ " Filepath +set statusline+=%2*\ %= " To the right +set statusline+=%2*\ %{toupper((&fenc!=''?&fenc:&enc))}\[%{&ff}] " Encoding & Fileformat +set statusline+=%2*\ %{Modified()}\ %{ReadOnly()} " Flags +set statusline+=%1*\ \%l/%L(%P)-%c\ " Position +" Speed up the redraw +au InsertLeave * call ChangeAccentColor() +au CursorHold * let &ro = &ro + +"""" Color Scheme + +"" Placed here for convenience. +"" Copied from sickill Monokai on Github, +"" and slightly modified. + +set background=dark +highlight clear +syntax reset +set t_Co=256 +hi Green ctermfg=34 ctermbg=NONE cterm=NONE guifg=#00af00 guibg=NONE gui=NONE +hi iGreen ctermfg=0 ctermbg=34 cterm=NONE guifg=#000000 guibg=#00af00 gui=NONE +hi Cursor ctermfg=235 ctermbg=231 cterm=NONE guifg=#272822 guibg=#f8f8f0 gui=NONE +hi Visual ctermfg=NONE ctermbg=59 cterm=NONE guifg=NONE guibg=#49483e gui=NONE +hi CursorLine ctermfg=NONE ctermbg=237 cterm=NONE guifg=NONE guibg=#3c3d37 gui=NONE +hi CursorColumn ctermfg=NONE ctermbg=237 cterm=NONE guifg=NONE guibg=#3c3d37 gui=NONE +hi ColorColumn ctermfg=NONE ctermbg=237 cterm=NONE guifg=NONE guibg=#3c3d37 gui=NONE +hi LineNr ctermfg=102 ctermbg=237 cterm=NONE guifg=#90908a guibg=#3c3d37 gui=NONE +hi VertSplit ctermfg=241 ctermbg=241 cterm=NONE guifg=#64645e guibg=#64645e gui=NONE +hi MatchParen ctermfg=197 ctermbg=NONE cterm=underline guifg=#f92672 guibg=NONE gui=underline +hi StatusLine ctermfg=231 ctermbg=241 cterm=bold guifg=#f8f8f2 guibg=#64645e gui=bold +hi StatusLineNC ctermfg=231 ctermbg=241 cterm=NONE guifg=#f8f8f2 guibg=#64645e gui=NONE +hi Pmenu ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi PmenuSel ctermfg=NONE ctermbg=59 cterm=NONE guifg=NONE guibg=#49483e gui=NONE +hi IncSearch ctermfg=235 ctermbg=186 cterm=NONE guifg=#272822 guibg=#e6db74 gui=NONE +hi Search ctermfg=NONE ctermbg=NONE cterm=underline guifg=NONE guibg=NONE gui=underline +hi Directory ctermfg=161 ctermbg=NONE cterm=NONE guifg=#d7005f guibg=NONE gui=NONE +hi Folded ctermfg=242 ctermbg=235 cterm=NONE guifg=#75715e guibg=#272822 gui=NONE +hi SignColumn ctermfg=NONE ctermbg=237 cterm=NONE guifg=NONE guibg=#3c3d37 gui=NONE +hi Normal ctermfg=231 ctermbg=235 cterm=NONE guifg=#f8f8f2 guibg=#272822 gui=NONE +hi Boolean ctermfg=141 ctermbg=NONE cterm=NONE guifg=#ae81ff guibg=NONE gui=NONE +hi Character ctermfg=141 ctermbg=NONE cterm=NONE guifg=#ae81ff guibg=NONE gui=NONE +hi Comment ctermfg=242 ctermbg=NONE cterm=NONE guifg=#75715e guibg=NONE gui=NONE +hi Conditional ctermfg=197 ctermbg=NONE cterm=NONE guifg=#f92672 guibg=NONE gui=NONE +hi Constant ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi Define ctermfg=197 ctermbg=NONE cterm=NONE guifg=#f92672 guibg=NONE gui=NONE +hi DiffAdd ctermfg=231 ctermbg=64 cterm=bold guifg=#f8f8f2 guibg=#46830c gui=bold +hi DiffDelete ctermfg=88 ctermbg=NONE cterm=NONE guifg=#8b0807 guibg=NONE gui=NONE +hi DiffChange ctermfg=NONE ctermbg=NONE cterm=NONE guifg=#f8f8f2 guibg=#243955 gui=NONE +hi DiffText ctermfg=231 ctermbg=24 cterm=bold guifg=#f8f8f2 guibg=#204a87 gui=bold +hi ErrorMsg ctermfg=231 ctermbg=197 cterm=NONE guifg=#f8f8f0 guibg=#f92672 gui=NONE +hi WarningMsg ctermfg=231 ctermbg=197 cterm=NONE guifg=#f8f8f0 guibg=#f92672 gui=NONE +hi Float ctermfg=141 ctermbg=NONE cterm=NONE guifg=#ae81ff guibg=NONE gui=NONE +hi Function ctermfg=148 ctermbg=NONE cterm=NONE guifg=#a6e22e guibg=NONE gui=NONE +hi Identifier ctermfg=81 ctermbg=NONE cterm=NONE guifg=#66d9ef guibg=NONE gui=italic +hi Keyword ctermfg=197 ctermbg=NONE cterm=NONE guifg=#f92672 guibg=NONE gui=NONE +hi Label ctermfg=186 ctermbg=NONE cterm=NONE guifg=#e6db74 guibg=NONE gui=NONE +hi NonText ctermfg=59 ctermbg=236 cterm=NONE guifg=#49483e guibg=#31322c gui=NONE +hi Number ctermfg=141 ctermbg=NONE cterm=NONE guifg=#ae81ff guibg=NONE gui=NONE +hi Operator ctermfg=197 ctermbg=NONE cterm=NONE guifg=#f92672 guibg=NONE gui=NONE +hi PreProc ctermfg=197 ctermbg=NONE cterm=NONE guifg=#f92672 guibg=NONE gui=NONE +hi Special ctermfg=231 ctermbg=NONE cterm=NONE guifg=#f8f8f2 guibg=NONE gui=NONE +hi SpecialKey ctermfg=59 ctermbg=237 cterm=NONE guifg=#49483e guibg=#3c3d37 gui=NONE +hi Statement ctermfg=197 ctermbg=NONE cterm=NONE guifg=#f92672 guibg=NONE gui=NONE +hi StorageClass ctermfg=81 ctermbg=NONE cterm=NONE guifg=#66d9ef guibg=NONE gui=italic +hi String ctermfg=186 ctermbg=NONE cterm=NONE guifg=#e6db74 guibg=NONE gui=NONE +hi Tag ctermfg=197 ctermbg=NONE cterm=NONE guifg=#f92672 guibg=NONE gui=NONE +hi Title ctermfg=231 ctermbg=NONE cterm=bold guifg=#f8f8f2 guibg=NONE gui=bold +hi Todo ctermfg=95 ctermbg=NONE cterm=inverse,bold guifg=#75715e guibg=NONE gui=inverse,bold +hi Type ctermfg=197 ctermbg=NONE cterm=NONE guifg=#f92672 guibg=NONE gui=NONE +hi Underlined ctermfg=NONE ctermbg=NONE cterm=underline guifg=NONE guibg=NONE gui=underline +hi rubyClass ctermfg=197 ctermbg=NONE cterm=NONE guifg=#f92672 guibg=NONE gui=NONE +hi rubyFunction ctermfg=148 ctermbg=NONE cterm=NONE guifg=#a6e22e guibg=NONE gui=NONE +hi rubyInterpolationDelimiter ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi rubySymbol ctermfg=141 ctermbg=NONE cterm=NONE guifg=#ae81ff guibg=NONE gui=NONE +hi rubyConstant ctermfg=81 ctermbg=NONE cterm=NONE guifg=#66d9ef guibg=NONE gui=italic +hi rubyStringDelimiter ctermfg=186 ctermbg=NONE cterm=NONE guifg=#e6db74 guibg=NONE gui=NONE +hi rubyBlockParameter ctermfg=208 ctermbg=NONE cterm=NONE guifg=#fd971f guibg=NONE gui=italic +hi rubyInstanceVariable ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi rubyInclude ctermfg=197 ctermbg=NONE cterm=NONE guifg=#f92672 guibg=NONE gui=NONE +hi rubyGlobalVariable ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi rubyRegexp ctermfg=186 ctermbg=NONE cterm=NONE guifg=#e6db74 guibg=NONE gui=NONE +hi rubyRegexpDelimiter ctermfg=186 ctermbg=NONE cterm=NONE guifg=#e6db74 guibg=NONE gui=NONE +hi rubyEscape ctermfg=141 ctermbg=NONE cterm=NONE guifg=#ae81ff guibg=NONE gui=NONE +hi rubyControl ctermfg=197 ctermbg=NONE cterm=NONE guifg=#f92672 guibg=NONE gui=NONE +hi rubyClassVariable ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi rubyOperator ctermfg=197 ctermbg=NONE cterm=NONE guifg=#f92672 guibg=NONE gui=NONE +hi rubyException ctermfg=197 ctermbg=NONE cterm=NONE guifg=#f92672 guibg=NONE gui=NONE +hi rubyPseudoVariable ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi rubyRailsUserClass ctermfg=81 ctermbg=NONE cterm=NONE guifg=#66d9ef guibg=NONE gui=italic +hi rubyRailsARAssociationMethod ctermfg=81 ctermbg=NONE cterm=NONE guifg=#66d9ef guibg=NONE gui=NONE +hi rubyRailsARMethod ctermfg=81 ctermbg=NONE cterm=NONE guifg=#66d9ef guibg=NONE gui=NONE +hi rubyRailsRenderMethod ctermfg=81 ctermbg=NONE cterm=NONE guifg=#66d9ef guibg=NONE gui=NONE +hi rubyRailsMethod ctermfg=81 ctermbg=NONE cterm=NONE guifg=#66d9ef guibg=NONE gui=NONE +hi erubyDelimiter ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi erubyComment ctermfg=95 ctermbg=NONE cterm=NONE guifg=#75715e guibg=NONE gui=NONE +hi erubyRailsMethod ctermfg=81 ctermbg=NONE cterm=NONE guifg=#66d9ef guibg=NONE gui=NONE +hi htmlTag ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi htmlEndTag ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi htmlTagName ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi htmlArg ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi htmlSpecialChar ctermfg=141 ctermbg=NONE cterm=NONE guifg=#ae81ff guibg=NONE gui=NONE +hi javaScriptFunction ctermfg=81 ctermbg=NONE cterm=NONE guifg=#66d9ef guibg=NONE gui=italic +hi javaScriptRailsFunction ctermfg=81 ctermbg=NONE cterm=NONE guifg=#66d9ef guibg=NONE gui=NONE +hi javaScriptBraces ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi yamlKey ctermfg=197 ctermbg=NONE cterm=NONE guifg=#f92672 guibg=NONE gui=NONE +hi yamlAnchor ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi yamlAlias ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi yamlDocumentHeader ctermfg=186 ctermbg=NONE cterm=NONE guifg=#e6db74 guibg=NONE gui=NONE +hi cssURL ctermfg=208 ctermbg=NONE cterm=NONE guifg=#fd971f guibg=NONE gui=italic +hi cssFunctionName ctermfg=81 ctermbg=NONE cterm=NONE guifg=#66d9ef guibg=NONE gui=NONE +hi cssColor ctermfg=141 ctermbg=NONE cterm=NONE guifg=#ae81ff guibg=NONE gui=NONE +hi cssPseudoClassId ctermfg=148 ctermbg=NONE cterm=NONE guifg=#a6e22e guibg=NONE gui=NONE +hi cssClassName ctermfg=148 ctermbg=NONE cterm=NONE guifg=#a6e22e guibg=NONE gui=NONE +hi cssValueLength ctermfg=141 ctermbg=NONE cterm=NONE guifg=#ae81ff guibg=NONE gui=NONE +hi cssCommonAttr ctermfg=81 ctermbg=NONE cterm=NONE guifg=#66d9ef guibg=NONE gui=NONE +hi cssBraces ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE +hi TabLineFill cterm=bold ctermbg=0 +" Final redraw +call ChangeAccentColor() -- cgit v1.2.1