]> www.git.dmfe.net Git - dotfiles/commitdiff
Added scripts. Modified .bash_profile.
authorDmitry Fedotov <dm.fe@yandex.ru>
Thu, 26 Mar 2020 14:10:23 +0000 (17:10 +0300)
committerDmitry Fedotov <dm.fe@yandex.ru>
Thu, 26 Mar 2020 14:10:23 +0000 (17:10 +0300)
12 files changed:
scripts/cpu-temp.sh [new file with mode: 0755]
scripts/dmenumount.sh [new file with mode: 0755]
scripts/idea-reset.sh [new file with mode: 0755]
scripts/iface.sh [new file with mode: 0755]
scripts/key-map.sh [new file with mode: 0755]
scripts/keymap-switch.sh [new file with mode: 0755]
scripts/mem.sh [new file with mode: 0755]
scripts/screen-locker.sh [new file with mode: 0755]
scripts/shutdown.sh [new file with mode: 0755]
scripts/volume.sh [new file with mode: 0755]
scripts/wallpaper.sh [new file with mode: 0755]
shell/.bash_profile.symlink

diff --git a/scripts/cpu-temp.sh b/scripts/cpu-temp.sh
new file mode 100755 (executable)
index 0000000..4ffbcd9
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+sensors | awk '/^k10temp/ {getline; getline; print $2}'
diff --git a/scripts/dmenumount.sh b/scripts/dmenumount.sh
new file mode 100755 (executable)
index 0000000..a282181
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+font="System San Francisco Display 12"
+
+pgrep -x dmenu && exit
+
+mountable=$(lsblk -lp | grep "part $" | awk '{print $1, "(" $4 ")"}')
+[[ "${mountable}" = "" ]] && exit 1
+chosen=$(echo "${mountable}" | dmenu -fn "${font}" -i -p "Mount which drive?" | awk '{print $1}')
+[[ "${chosen}" = "" ]] && exit 1
+mount "${chosen}" > /dev/null 2>&1 && notify-send "${chosen} mounted based on fstab" && exit 0
+dirs=$(find /mnt /media /home -type d -maxdepth 3 2>/dev/null)
+mountpoint=$(echo "${dirs}" | dmenu -fn "${font}" -i -p "Type in mount point.")
+[[ "${mountpoint}" = "" ]] && exit 1
+if [[ ! -d "${mountpoint}" ]]; then
+  mkdiryn=$(echo -e "Yes\nNo" | dmenu -fn "${font}" -i -p "${mountpoint} does not exist. Create it?")
+  [[ "${mkdiryn}" = Yes ]] && sudo mkdir -p "${mountpoint}"
+fi
+sudo mount $chosen $mountpoint -o uid="$(id -u `whoami`)",gid="$(id -g `whoami`)" && \
+notify-send "${chosen} mounted to ${mountpoint}"
diff --git a/scripts/idea-reset.sh b/scripts/idea-reset.sh
new file mode 100755 (executable)
index 0000000..292e14d
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+idea_config_loc=~/.IntelliJIdea2018.3/config
+jetbrain_prefs=~/.java/.userPrefs/jetbrains/idea/30a67a02
+
+echo "Clearing idea eval configs:"
+echo "Idea local config: ${idea_config_loc}"
+echo "Jetbrains java config: ${jetbrain_prefs}"
+
+rm -rf $idea_config_loc/eval && \
+sed -i '/.*evl.*/d' $idea_config_loc/options/other.xml && \
+rm -rf $jetbrain_prefs/evl*
+
+echo "Idea eval configs wiped out!"
diff --git a/scripts/iface.sh b/scripts/iface.sh
new file mode 100755 (executable)
index 0000000..231e541
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+icon=
+iface=$(ip route | awk '/^default/ { print $5 ; exit }')
+
+[[ ! -d /sys/class/net/${iface} ]] && exit
+
+if [[ "$(cat /sys/class/net/$iface/operstate)" = 'down' ]]; then
+  printf '<span foreground="#ff0000">%s</span>' "${icon} down"
+  exit
+fi
+
+case $1 in
+  -4)
+    af=inet ;;
+  -6)
+    af=inet6 ;;
+  *)
+    af=inet6? ;;
+esac
+
+ipaddr=$(ip addr show enp3s0 | awk '/inet/ { print $2 ; exit }' | sed 's/\/.*//g')
+#echo $ipaddr
+printf '<span foreground="#66ff33">%s</span>' "${icon} ${ipaddr}"
diff --git a/scripts/key-map.sh b/scripts/key-map.sh
new file mode 100755 (executable)
index 0000000..391ac29
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+setxkbmap -layout us,ru -option grp:ctrls_toggle
diff --git a/scripts/keymap-switch.sh b/scripts/keymap-switch.sh
new file mode 100755 (executable)
index 0000000..6fefaed
--- /dev/null
@@ -0,0 +1,4 @@
+ #!/bin/bash
+
+xkb-switch
+xkb-switch -W
diff --git a/scripts/mem.sh b/scripts/mem.sh
new file mode 100755 (executable)
index 0000000..50d4bc9
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+mem_info() {
+    ps_out="$(ps axch -o cmd:15,pid,%mem --sort -%mem | head)"
+
+    IFS=$(echo -en "\n\b")
+    fmt_msg=""
+    num=1
+    for row in ${ps_out[@]}; do
+        name="$(echo -e $row | awk '{NF-=2; print $OFS}')"
+        pid="$(echo -e $row | awk '{NF-=1; print $NF}')"
+        mem="$(echo -e $row | awk '{print $NF}')"
+        fmt_msg=${fmt_msg}$(printf "%s\t%s|%s|%s" "$num" "$name" "$pid" "$mem%")"\n"
+        num=$(( $num + 1 ))
+    done
+
+    fmt_msg=$(echo -e "${fmt_msg}" | column -s "|" -t -o " > ")
+    echo "${fmt_msg}"
+}
+
+case $BLOCK_BUTTON in
+    1) notify-send "Top 10 memory consumption" "$(mem_info)" -t 30000;;
+esac
+
+free -h | awk '/^Mem:/ {print $3 "/" $2}' | sed 's/i//g'
diff --git a/scripts/screen-locker.sh b/scripts/screen-locker.sh
new file mode 100755 (executable)
index 0000000..b5322fc
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+icons_dir=Pictures/Icons
+icon_file="$(ls $icons_dir | sort -R | head -n 1)"
+icon=$HOME/$icons_dir/$icon_file
+tmp_bg=/tmp/screen.png
+
+#echo $icon
+
+scrot $tmp_bg
+convert $tmp_bg -scale 10% -scale 1000% $tmp_bg
+convert $tmp_bg $icon -gravity center -composite -matte $tmp_bg
+i3lock -u -i $tmp_bg
diff --git a/scripts/shutdown.sh b/scripts/shutdown.sh
new file mode 100755 (executable)
index 0000000..75c5673
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+font="System San Francisco Display 12"
+
+pgrep -x dmenu && exit
+
+chosen=$(echo -e "Shutdown\nReboot" | dmenu -fn "${font}" -i -p "What would you like to do?")
+if [[ "${chosen}" = Shutdown ]]; then
+    yesno=$(echo -e "Yes\nNo" | dmenu -fn "${font}" -i -p "Do you really want to shutdown?")
+    [[ "${yesno}" = Yes ]] && sudo shutdown -h now
+elif [[ "${chosen}" = Reboot ]]; then
+    yesno=$(echo -e "Yes\nNo" | dmenu -fn "${font}" -i -p "Do you really want to reboot?")
+    [[ "${yesno}" = Yes ]] && sudo reboot
+fi
diff --git a/scripts/volume.sh b/scripts/volume.sh
new file mode 100755 (executable)
index 0000000..e762517
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+sink=$( pactl list short sinks | sed -e 's,^\([0-9][0-9]*\)[^0-9].*,\1,' | tail -n 1 )
+
+case $BLOCK_BUTTON in
+     2) pactl set-sink-mute $sink toggle ;;
+     4) pactl set-sink-volume $sink +5% ;;
+     5) pactl set-sink-volume $sink -5% ;;
+esac
+
+muted=$( awk '/muted/ {print $2}' <(pacmd list-sinks | grep '^[[:space:]]muted:' | head -n $(( $sink + 1 )) | tail -n 1 ) )
+
+if [ "$muted" = "yes" ]; then
+  icon=""
+  printf "%s\\n" "$icon"
+else
+  vol=$( pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $sink + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' )
+  if [ "$vol" -gt 60 ]; then
+    icon=""
+  elif [[ "$vol" -le 60 && "$vol" -gt 30 ]]; then
+    icon=""
+  else
+    icon=""
+  fi
+  
+  printf "%s %s%%\\n" "$icon" "$vol"
+fi
diff --git a/scripts/wallpaper.sh b/scripts/wallpaper.sh
new file mode 100755 (executable)
index 0000000..2ffc7f6
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+period=$1
+wp_dir=~/Pictures/wallpapers
+
+while true
+do
+    cur_wp_name=$(ls -1 $wp_dir | shuf | head -n 1)
+
+#    echo $cur_wp_name
+    feh --bg-scale $wp_dir/$cur_wp_name
+
+    sleep ${period}m
+done
index 5e1ef835cd35a51bafdb92ccefd0bd19cd8b8be9..dfac0ac695b8528988196a54c6cfebc8945e5c3c 100644 (file)
@@ -16,6 +16,7 @@ export DOT_FILES_VIM="${DOT_FILES}/vim"
 export DOT_FILES_VIM_C_DEV="${DOT_FILES_VIM}/c-dev"
 export DOT_FILES_SHELL="${DOT_FILES}/shell"
 export DOT_FILES_SHELL_INIT="${DOT_FILES_SHELL}/init_scripts"
+export SCRIPTS="${HOME}/scripts"
 
 if [[ -d ${DOT_FILES_SHELL_INIT} ]]; then
     for s in $(ls -a ${DOT_FILES_SHELL_INIT} | grep -v "\.$"); do