Update and clean up user scripts

This commit is contained in:
natemaia 2017-12-01 23:06:11 -08:00
parent dcf56fc86a
commit 5be5c23629
17 changed files with 62 additions and 122 deletions

View File

@ -8,7 +8,6 @@
XDG_CONFIG_HOME="$HOME/.config" XDG_CONFIG_HOME="$HOME/.config"
export XDG_CONFIG_HOME export XDG_CONFIG_HOME
if [ -d /etc/X11/xinit/xinitrc.d ]; then if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "$f" ] && . "$f" [ -x "$f" ] && . "$f"
@ -16,7 +15,6 @@ if [ -d /etc/X11/xinit/xinitrc.d ]; then
unset f unset f
fi fi
if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then
eval `dbus-launch --sh-syntax --exit-with-session` eval `dbus-launch --sh-syntax --exit-with-session`
fi fi

View File

@ -1,7 +1,8 @@
# .xprofile # .xprofile
XDG_CONFIG_HOME="$HOME/.config" XDG_CONFIG_HOME=$HOME/.config
export XDG_CONFIG_HOME export XDG_CONFIG_HOME
export PATH=$HOME/bin:$PATH
# include sbin in PATH # include sbin in PATH
if [ -d "/sbin" ] ; then if [ -d "/sbin" ] ; then
@ -12,11 +13,6 @@ if [ -d "/usr/sbin" ] ; then
PATH="/usr/sbin:$PATH" PATH="/usr/sbin:$PATH"
fi fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then
eval `dbus-launch --sh-syntax --exit-with-session` eval `dbus-launch --sh-syntax --exit-with-session`
fi fi

View File

@ -2,18 +2,11 @@
connected="" connected=""
disconnected="" disconnected=""
# Infinite loop
while true; do while true; do
if ping -c1 8.8.8.8 >/dev/null; then if ping -c1 8.8.8.8 >/dev/null; then
echo "$connected"; sleep 5 echo "$connected"; sleep 5
else else
echo "$disconnected"; sleep 1 echo "$disconnected"; sleep 1
echo "$connected"; sleep 1 echo "$connected"; sleep 1
fi fi
done done

View File

@ -1,56 +1,36 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# update checking script for polybar
# written by Nathaniel Maia
BAR_ICON="" BAR_ICON=""
ICON=/usr/share/icons/gnome/32x32/apps/system-software-update.png ICON=/usr/share/icons/gnome/32x32/apps/system-software-update.png
# Infinite loop
while true; do while true; do
# initial check
count=$(checkupdates | wc -l) count=$(checkupdates | wc -l)
# notifications
if hash notify-send >/dev/null 2>&1; then if hash notify-send >/dev/null 2>&1; then
if [ $count -gt 50 ]; then if [ $count -gt 50 ]; then
notify-send -u critical -i $ICON \ notify-send -u critical -i $ICON \
"You really need to update soon!!" "$count New package updates" "You really need to update soon!!" "$count New package updates"
elif [ $count -gt 25 ]; then elif [ $count -gt 25 ]; then
notify-send -u normal -i $ICON \ notify-send -u normal -i $ICON \
"You should update soon" "$count New package updates" "You should update soon" "$count New package updates"
elif [ $count -gt 5 ]; then elif [ $count -gt 5 ]; then
notify-send -u low -i $ICON \ notify-send -u low -i $ICON \
"$count New package updates" "$count New package updates"
fi fi
fi fi
# while greater than 0 check every 8s
while [ "$count" -gt 0 ]; do while [ "$count" -gt 0 ]; do
# update or updates
if [ $count -eq 1 ]; then if [ $count -eq 1 ]; then
echo "$count Update" echo "$count Update"
elif [ $count -gt 1 ]; then elif [ $count -gt 1 ]; then
echo "$count Updates" echo "$count Updates"
fi fi
sleep 8 sleep 8
count=$(checkupdates | wc -l) count=$(checkupdates | wc -l)
done done
# while no updates, check every 20 min
while [ "$count" -eq 0 ]; do while [ "$count" -eq 0 ]; do
echo $BAR_ICON echo $BAR_ICON
sleep 1200 sleep 1200
count=$(checkupdates | wc -l) count=$(checkupdates | wc -l)
done done
done done

View File

@ -2,10 +2,10 @@
import os import os
import gi
import yaml
import struct import struct
import subprocess import subprocess
import yaml
import gi
gi.require_version('Gtk', '3.0') gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, Pango from gi.repository import Gtk, Gdk, Pango
@ -58,11 +58,11 @@ class Selection(Gtk.EventBox):
return None return None
def selected(self, *args): def selected(self, *args):
self.hbox.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(*self.selected_colour)) # self.hbox.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(*self.selected))
return None return None
def unselected(self, *args): def unselected(self, *args):
self.hbox.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(*self.background)) # self.hbox.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(*self.selected))
return None return None
@ -110,15 +110,17 @@ def keypress(window, key):
def main(): def main():
configs = load_configs() configs = load_configs()
window = Gtk.Window() window = Gtk.Window()
window.modify_font( Pango.FontDescription('Ubuntu 10') )
window.connect('leave-notify-event', Gtk.main_quit) window.modify_font(Pango.FontDescription('xos4 Terminus 9'))
window.set_property('type-hint', Gdk.WindowTypeHint.SPLASHSCREEN) window.set_property('type-hint', Gdk.WindowTypeHint.SPLASHSCREEN)
window.set_property('skip-taskbar-hint', True)
window.set_decorated(False) window.set_decorated(False)
window.set_title('bar-dropdown')
window.set_border_width(0)
window.set_resizable(False) window.set_resizable(False)
window.stick()
window.connect('leave-notify-event', Gtk.main_quit)
# window.set_property('skip-taskbar-hint', False)
# window.set_title('bar-dropdown')
# window.set_border_width(0)
# window.stick()
window.connect('delete-event', Gtk.main_quit) window.connect('delete-event', Gtk.main_quit)
@ -130,11 +132,10 @@ def main():
box.pack_start(config, False, False, 0) box.pack_start(config, False, False, 0)
scrolled.add(box) scrolled.add(box)
window.add(scrolled) window.add(scrolled)
window.set_size_request(200, 300) window.set_size_request(200, 420)
window.show_all() window.show_all()
window.move(10, 27) window.move(10, 35)
window.connect('key-press-event', keypress) window.connect('key-press-event', keypress)
window.set_events(Gdk.EventMask.BUTTON_PRESS_MASK) window.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
killall -q polybar killall -q polybar
while pgrep -u $UID -x polybar >/dev/null; do
while pgrep -u $UID -x polybar >/dev/null; do sleep 0.5; done sleep 0.5
done
echo "Bars stopped..." echo "Bars stopped..."

View File

@ -1,24 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#
# Polybar launcher script written by Nathaniel Maia for use in ArchLabs
#
# Will launch bars depending on WM and can reload openbox session
# Can also be used to reload openbox session with [--reload] or [-r]
# Enter your bar names here (seperated by spaces) eg BARS=(bar bar1 my-bar) # Enter your bar names here (seperated by spaces) eg BARS=(bar bar1 my-bar)
# This will be combined with CUR_WM eg. Openbox-bar, bspwm-bar, i3-bar # This will be combined with CUR_WM eg. openbox-bar, bspwm-bar, i3-bar
BARS=(bar) BARS=(bar)
CONFIG=$HOME/.config/polybar/config
CONF=$HOME/.config/polybar CUR_WM=$(xprop -root | grep "_NET_WM_NAME(UTF8_STRING)" | cut -d " " -f 3 | sed 's/"//g' | awk '{print tolower($0)}')
CUR_WM=$(wmctrl -m | grep Name | cut -d " " -f2)
# used to reload openbox session
if [[ $1 == "--reload" ]] || [[ $1 == "-r" ]]; then if [[ $1 == "--reload" ]] || [[ $1 == "-r" ]]; then
if [[ $CUR_WM == "Openbox" ]]; then if [[ $CUR_WM == "openbox" ]]; then
openbox --restart openbox --restart
al-compositor --restart al-compositor --restart
al-tint2restart al-tint2restart
@ -27,21 +16,18 @@ if [[ $1 == "--reload" ]] || [[ $1 == "-r" ]]; then
fi fi
fi fi
# drop out if tint2 is running
if pgrep -x "tint2" >/dev/null; then if pgrep -x "tint2" >/dev/null; then
echo "Tint is running... Exiting" echo "Tint is running... Exiting"
exit 1 exit 1
fi fi
# Terminate already running Bars
while pgrep -x polybar >/dev/null; do while pgrep -x polybar >/dev/null; do
killall -q polybar killall -q polybar
sleep 0.5 sleep 0.5
done done
# Launch each bar in BARS=() above
echo "Using $CUR_WM... Launching Bars" echo "Using $CUR_WM... Launching Bars"
for bar in "${BARS[@]}"; do for bar in "${BARS[@]}"; do
polybar -r --config=$CONF/config ${CUR_WM}-$bar & polybar -r --config=$CONFIG ${CUR_WM}-$bar &
done done
echo "Bars launched..." echo "Bars launched..."

View File

@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
rofi -no-config -modi run,drun,window -show drun -eh 1 -width 50 -padding 30 -color-enabled -color-window "#2b303b, #8fa1b3, #2b303b" -color-normal "#2b303b, #8fa1b3, #2b303b, #8fa1b3, #2b303b" -sidebar-mode -font "Ubuntu Light 11" rofi -no-config -modi run,drun,window -show drun -eh 1 -width 50 -padding 30 -sidebar-mode -font "Ubuntu Light 11" -color-enabled -color-window "#2b303b, #8fa1b3, #2b303b" -color-normal "#2b303b, #8fa1b3, #2b303b, #8fa1b3, #2b303b"

View File

@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
rofi -no-config -modi run,drun,window -show drun -eh 1 -width 50 -padding 30 -color-enabled -color-window "{{.Data.terminal_background}}, {{index .Data.terminal_colors 4}}, {{.Data.terminal_background}}" -color-normal "{{.Data.terminal_background}}, {{index .Data.terminal_colors 4}}, {{.Data.terminal_background}}, {{index .Data.terminal_colors 4}}, {{.Data.terminal_background}}" -sidebar-mode -font "Ubuntu Light 11" rofi -no-config -modi run,drun,window -show drun -eh 1 -width 50 -padding 30 -sidebar-mode -font "Ubuntu Light 11" -color-enabled -color-window "{{.Data.terminal_background}}, {{index .Data.terminal_colors 4}}, {{.Data.terminal_background}}" -color-normal "{{.Data.terminal_background}}, {{index .Data.terminal_colors 4}}, {{.Data.terminal_background}}, {{index .Data.terminal_colors 4}}, {{.Data.terminal_background}}"

View File

@ -1,11 +1,26 @@
#!/usr/bin/env bash #!/usr/bin/env bash
ANS=$(echo " lock| logout| reboot| shutdown" | rofi -sep "|" -dmenu -i -p 'System: ' "" -width 20 -hide-scrollbar -location 0 -yoffset -200 -font "xos4 Terminus 10" -eh 1 -line-padding 2 -padding 30 -no-config -lines 4 -color-enabled -color-window "#1F2326, #F1F1F1, #1F2326" -color-normal "#1F2326, #F1F1F1, #1F2326, #4E88CF, #1F2326") CUR_WM=$(xprop -root | grep "_NET_WM_NAME(UTF8_STRING)" | cut -d " " -f 3 | sed 's/"//g' | awk '{print tolower($0)}')
ANS=$(echo " lock| logout| reboot| shutdown" | rofi -sep "|" -dmenu -i -p 'System: ' "" -width 20 -hide-scrollbar -location 0 -yoffset -200 -font "Ubuntu 11" -eh 1 -line-padding 2 -padding 30 -no-config -lines 4 -color-enabled -color-window "#1F2326, #F1F1F1, #1F2326" -color-normal "#1F2326, #F1F1F1, #1F2326, #4E88CF, #1F2326")
if [[ "$ANS" == *lock ]]; then if [[ "$ANS" == *lock ]]; then
i3lock-fancy i3lock-fancy
elif [[ "$ANS" == *logout ]]; then elif [[ "$ANS" == *logout ]]; then
i3-msg exit if [[ "$CUR_WM" == "i3" ]]; then
i3-msg exit
elif [[ "$CUR_WM" == "bspwm" ]]; then
for window_id in $(bspc query -W); do
bspc window $window_id -c
done
killall sxhkd
bspc quit
elif [[ "$CUR_WM" == "bspwm" ]]; then
openbox --exit
else
echo "Unknown WM... Exiting"
exit 1
fi
elif [[ "$ANS" == *reboot ]]; then elif [[ "$ANS" == *reboot ]]; then
systemctl reboot systemctl reboot
elif [[ "$ANS" == *shutdown ]]; then elif [[ "$ANS" == *shutdown ]]; then

View File

@ -1,11 +1,26 @@
#!/usr/bin/env bash #!/usr/bin/env bash
ANS=$(echo " lock| logout| reboot| shutdown" | rofi -sep "|" -dmenu -i -p 'System: ' "" -width 20 -hide-scrollbar -location 0 -yoffset -200 -font "xos4 Terminus 10" -eh 1 -line-padding 4 -padding 30 -no-config -lines 4 -color-enabled -color-window "{{.Data.terminal_background}}, {{.Data.terminal_foreground}}, {{.Data.terminal_background}}" -color-normal "{{.Data.terminal_background}}, {{.Data.terminal_foreground}}, {{.Data.terminal_background}}, {{index .Data.terminal_colors 4}}, {{.Data.terminal_background}}") CUR_WM=$(xprop -root | grep "_NET_WM_NAME(UTF8_STRING)" | cut -d " " -f 3 | sed 's/"//g' | awk '{print tolower($0)}')
ANS=$(echo " lock| logout| reboot| shutdown" | rofi -sep "|" -dmenu -i -p 'System: ' "" -width 20 -hide-scrollbar -location 0 -yoffset -200 -font "Ubuntu 11" -eh 1 -line-padding 4 -padding 30 -no-config -lines 4 -color-enabled -color-window "{{.Data.terminal_background}}, {{.Data.terminal_foreground}}, {{.Data.terminal_background}}" -color-normal "{{.Data.terminal_background}}, {{.Data.terminal_foreground}}, {{.Data.terminal_background}}, {{index .Data.terminal_colors 4}}, {{.Data.terminal_background}}")
if [[ "$ANS" == *lock ]]; then if [[ "$ANS" == *lock ]]; then
i3lock-fancy i3lock-fancy
elif [[ "$ANS" == *logout ]]; then elif [[ "$ANS" == *logout ]]; then
i3-msg exit if [[ "$CUR_WM" == "i3" ]]; then
i3-msg exit
elif [[ "$CUR_WM" == "bspwm" ]]; then
for window_id in $(bspc query -W); do
bspc window $window_id -c
done
killall sxhkd
bspc quit
elif [[ "$CUR_WM" == "bspwm" ]]; then
openbox --exit
else
echo "Unknown WM... Exiting"
exit 1
fi
elif [[ "$ANS" == *reboot ]]; then elif [[ "$ANS" == *reboot ]]; then
systemctl reboot systemctl reboot
elif [[ "$ANS" == *shutdown ]]; then elif [[ "$ANS" == *shutdown ]]; then

View File

@ -2,14 +2,10 @@
start="al-compositor --start" start="al-compositor --start"
restart="al-compositor --restart" restart="al-compositor --restart"
if [ -e "${HOME}/.config/.composite_enabled" ]; then if [ -e "${HOME}/.config/.composite_enabled" ]; then
if pgrep compton; then if pgrep compton; then
$restart $restart
else else
$start $start
fi fi
fi fi

View File

@ -1,44 +1,21 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# if the script is passed --toggle # if the script is passed --toggle
if [[ "$1" == *toggle* ]]; then if [[ "$1" == *toggle* ]]; then
# if caffeine is running kill it
if pgrep caffeine >/dev/null; then if pgrep caffeine >/dev/null; then
killall caffeine killall caffeine
else
else # otherwise start it and fork to background
caffeine &>/dev/null & caffeine &>/dev/null &
fi fi
# exit or get caught in the infinite loop
exit 0 exit 0
fi fi
# infinite loop for polybar
while true; do while true; do
# caffeine is running # caffeine is running
if pgrep caffeine >/dev/null; then if pgrep caffeine >/dev/null; then
# Change Me
echo "%{F#0000FF}" echo "%{F#0000FF}"
else
else # otherwise it must not be... LOL
# Change Me
echo "%{F#FF0000}" echo "%{F#FF0000}"
fi fi
# sleep interval... Change the responsiveness
sleep 2 sleep 2
done done

View File

@ -6,21 +6,14 @@ off=""
if [[ $1 == *toggle* ]]; then if [[ $1 == *toggle* ]]; then
if pgrep -x compton > /dev/null 2>&1; then if pgrep -x compton > /dev/null 2>&1; then
al-compositor --stop al-compositor --stop
else else
al-compositor --start al-compositor --start
fi fi
exit 0 exit 0
fi fi
if pgrep -x compton > /dev/null 2>&1; then if pgrep -x compton > /dev/null 2>&1; then
echo "$on" echo "$on"
else else
echo "%{F#888888}$off" echo "%{F#888888}$off"
fi fi

View File

@ -1,11 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if pgrep -x polybar >/dev/null; then if pgrep -x polybar >/dev/null; then
pkill polybar pkill polybar
else else
launch-polybar >/dev/null 2>&1 launch-polybar >/dev/null 2>&1
fi fi

View File

@ -1,6 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [[ $1 = "--toggle" ]] || [[ $1 = "-t" ]]; then if [[ $1 = "--toggle" ]] || [[ $1 = "-t" ]]; then
if pgrep redshift > /dev/null 2>&1; then if pgrep redshift > /dev/null 2>&1; then
killall redshift killall redshift

View File

@ -1,14 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
MATCH=$(pgrep --full 'termite --title=work-term') MATCH=$(pgrep --full 'termite --title=work-term')
if ! $MATCH; then if ! $MATCH; then
pkill --full 'termite --title=work-term' pkill --full 'termite --title=work-term'
else else
termite --title=work-term --class=work-term & termite --title=work-term --class=work-term &
fi fi
exit 0