Large update, remove old scripts & gorice, merge some together

This commit is contained in:
natemaia
2018-02-05 19:31:56 -08:00
parent 9718b4bd71
commit f041702ae0
77 changed files with 1704 additions and 3307 deletions

View File

@ -1,36 +0,0 @@
#!/usr/bin/env bash
BAR_ICON=""
ICON=/usr/share/icons/gnome/32x32/apps/system-software-update.png
while true; do
count=$(checkupdates | wc -l)
if hash notify-send &>/dev/null; then
if [[ $count -gt 50 ]]; then
notify-send -u critical -i $ICON \
"You really need to update soon!!" "$count New package updates"
elif [[ $count -gt 25 ]]; then
notify-send -u normal -i $ICON \
"You should update soon" "$count New package updates"
elif [[ $count -gt 2 ]]; then
notify-send -u low -i $ICON \
"$count New package updates"
fi
fi
while [[ $count -gt 0 ]]; do
if [[ $count -eq 1 ]]; then
echo "$count Update"
elif [[ $count -gt 1 ]]; then
echo "$count Updates"
fi
sleep 8
count=$(checkupdates | wc -l)
done
while [[ $count -eq 0 ]]; do
echo $BAR_ICON
sleep 1200
count=$(checkupdates | wc -l)
done
done

View File

@ -1,147 +0,0 @@
#!/usr/bin/env python
import os
import struct
import subprocess
import yaml
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, Pango
# This is the name of the group where your configs are stored.
GROUP = 'i3'
PATH = '{}/bin/gorice'.format(os.environ['HOME'])
class Selection(Gtk.EventBox):
def __init__(self, name, colours, foreground, background, selected,
working=True):
super().__init__()
self.name = name
self.background = background
self.selected_colour = selected
if not working:
name = 'x ' + name
text = Gtk.Label(name)
hbox = Gtk.HBox()
hbox.set_size_request(0, 30)
hbox.pack_start(text, False, True, 20)
hbox.override_color(Gtk.StateType.NORMAL, Gdk.RGBA(*foreground))
hbox.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(*background))
colour_widgets = Gtk.HBox()
for colour in colours:
box = Gtk.Box()
box.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(*colour))
box.set_size_request(15, 15)
padding = Gtk.Alignment()
padding.set_padding(10, 10, 0, 0)
padding.add(box)
colour_widgets.pack_start(padding, False, True, 2)
hbox.pack_end(colour_widgets, False, True, 20)
self.hbox = hbox
self.connect('enter-notify-event', self.selected)
self.connect('leave-notify-event', self.unselected)
self.connect('button-press-event', self.clicked)
self.add(self.hbox)
def clicked(self, widget, button):
_, index = button.get_button()
if index == 1:
proc = subprocess.run([PATH, 'load', self.name])
Gtk.main_quit()
return None
def selected(self, *args):
# self.hbox.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(*self.selected))
return None
def unselected(self, *args):
# self.hbox.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(*self.selected))
return None
def load_configs():
broken = subprocess.check_output([PATH, 'check', GROUP])
broken = broken.decode('utf-8').split('\n')
output = []
path = '{}/.gorice/output.yaml'.format(os.environ['HOME'])
with open(path, 'r') as f:
data = yaml.load(f.read())
names = sorted(data['configs'])
for config in names:
info = data['configs'][config]
config, ext = os.path.splitext(config)
if config == 'i3/default':
continue
_, name = config.split('/', 1)
foreground = rgb(info['foreground'])
background = rgb(info['background'])
selection = [x+0.02 for x in background]
colours = [rgb(x) for x in info['colors']]
item = Selection(config, colours, foreground, background, selection,
working=name not in broken)
output.append(item)
return output
def rgb(colour):
colour = colour[1:]
return [x/255 for x in struct.unpack('BBB', bytes.fromhex(colour))]
def keypress(window, key):
if key.keyval == 65307:
Gtk.main_quit()
return None
def main():
configs = load_configs()
window = Gtk.Window()
window.modify_font(Pango.FontDescription('xos4 Terminus 9'))
window.set_property('type-hint', Gdk.WindowTypeHint.SPLASHSCREEN)
window.set_decorated(False)
window.set_resizable(False)
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)
scrolled = Gtk.ScrolledWindow()
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
box = Gtk.VBox()
for config in configs:
box.pack_start(config, False, False, 0)
scrolled.add(box)
window.add(scrolled)
window.set_size_request(200, 420)
window.show_all()
window.move(10, 35)
window.connect('key-press-event', keypress)
window.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
Gtk.main()
return None
if __name__ == "__main__":
main()

Binary file not shown.

View File

@ -1,32 +1,25 @@
#!/usr/bin/env bash
TRASH_DIRECTORY="${BLOCK_INSTANCE}"
if [[ "${TRASH_DIRECTORY}" = "" ]]; then
TRASH_DIRECTORY="${XDG_DATA_HOME:-${HOME}/.local/share}/Trash"
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"
if [[ $BLOCK_BUTTON -eq 1 ]]; then
xdg-open "$TRASH_DIRECTORY/files"
elif [[ $BLOCK_BUTTON -eq 3 ]]; then
rm -r "$TRASH_DIRECTORY/files"
rm -r "$TRASH_DIRECTORY/info"
mkdir "$TRASH_DIRECTORY/files"
mkdir "$TRASH_DIRECTORY/info"
fi
TRASH_COUNT=$(ls -U -1 "${TRASH_DIRECTORY}/files" | wc -l)
TRASH_COUNT=$(ls -U -1 "$TRASH_DIRECTORY/files" | wc -l)
URGENT_VALUE=30
echo "${TRASH_COUNT}"
echo "${TRASH_COUNT}"
echo "$TRASH_COUNT"
echo "$TRASH_COUNT"
echo ""
if [[ "${TRASH_COUNT}" -ge "${URGENT_VALUE}" ]]; then
if [[ $TRASH_COUNT -ge $URGENT_VALUE ]]; then
exit 31
fi

View File

@ -1,6 +0,0 @@
#!/usr/bin/env bash
# do the launcher
rofi -modi run,drun,window -show drun \
-show-icons -me-select-entry '' \
-me-accept-entry 'Mouse1' -sidebar-mode

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
rofi -no-config -modi run,drun,window -show drun \
-eh 1 -line-padding 4 -padding 50 -sidebar-mode \
-show-icons -drun-icon-theme "ArchLabs-Light" \
-font "Ubuntu 11" -color-enabled \
-color-window "#2b303b, #8fa1b3, #2b303b" \
-color-normal "#2b303b, #8fa1b3, #2b303b, #8fa1b3, #2b303b"

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
rofi -no-config -modi run,drun,window -show drun \
-eh 1 -line-padding 4 -padding 50 -sidebar-mode \
-show-icons -drun-icon-theme "ArchLabs-Light" \
-font "Ubuntu 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,25 +0,0 @@
#!/usr/bin/env bash
question=$(echo " lock| logout| reboot| shutdown" | rofi -sep "|" \
-dmenu -i -p 'System: ' "" -width 20 -hide-scrollbar -font "Ubuntu 11" \
-eh 1 -line-padding 4 -padding 20 -no-config -lines 4 -color-enabled \
-color-window "#2b303b, #8fa1b3, #2b303b" \
-color-normal "#2b303b, #8fa1b3, #2b303b, #8fa1b3, #2b303b")
case $question in
*lock)
i3lock-fancy
;;
*logout)
session-logout
;;
*reboot)
systemctl reboot
;;
*shutdown)
systemctl poweroff
;;
*)
exit 0 # do nothing on wrong response
;;
esac

View File

@ -1,25 +0,0 @@
#!/usr/bin/env bash
question=$(echo " lock| logout| reboot| shutdown" | rofi -sep "|" \
-dmenu -i -p 'System: ' "" -width 20 -hide-scrollbar -font "Ubuntu 11" \
-eh 1 -line-padding 4 -padding 20 -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}}")
case $question in
*lock)
i3lock-fancy
;;
*logout)
session-logout
;;
*reboot)
systemctl reboot
;;
*shutdown)
systemctl poweroff
;;
*)
exit 0 # do nothing on wrong response
;;
esac

View File

@ -1,6 +0,0 @@
#!/bin/bash
rofi -no-config -modi window -show window -hide-scrollbar -eh 1 \
-padding 50 -line-padding 4 -font "Fantasque Sans Mono 12" -color-enabled \
-color-window "#1F2326, #1F2326, #1F2326" \
-color-normal "#1F2326, #F1F1F1, #1F2326, #4E88CF, #1F2326"

View File

@ -1,6 +0,0 @@
#!/bin/bash
rofi -no-config -modi window -show window -hide-scrollbar -eh 1 \
-padding 50 -line-padding 4 -font "Fantasque Sans Mono 12" -color-enabled \
-color-window "{{.Data.terminal_background}}, {{.Data.terminal_background}}, {{.Data.terminal_background}}" \
-color-normal "{{.Data.terminal_background}}, {{.Data.terminal_foreground}}, {{.Data.terminal_background}}, {{index .Data.terminal_colors 4}}, {{.Data.terminal_background}}"

81
home/bin/rofr.sh Executable file
View File

@ -0,0 +1,81 @@
#!/usr/bin/env bash
Name=$(basename "$0")
Version="0.1"
_usage() {
cat <<- EOF
Usage: $Name [options]
Options:
-h Display this message
-v Display script version
-q Persistant calculator dialog
-w Switch between open windows
-r Program launcher & run dialog
-c Select previous clipboard entries
-b Browser search by keyword
-l Session logout choice
EOF
}
# Handle command line arguments
while getopts ":hvqwcbrl" opt; do
case $opt in
h)
_usage
exit 0
;;
v)
echo -e "$Name -- Version $Version"
exit 0
;;
r)
rofi -modi run,drun -show drun -line-padding 4 \
-columns 2 -padding 50 -hide-scrollbar \
-show-icons -drun-icon-theme "ArchLabs-Light"
;;
w)
rofi -modi window -show window -hide-scrollbar \
-eh 1 -padding 50 -line-padding 4
;;
q)
rofi -modi "calc:qalc +u8 -nocurrencies" -padding 50 \
-show "calc:qalc +u8 -nocurrencies" -line-padding 4 \
-hide-scrollbar
;;
c)
rofi -modi "clipboard:greenclip print" -padding 50 \
-line-padding 4 -show "clipboard:greenclip print" \
-hide-scrollbar
;;
b)
surfraw -browser="$BROWSER" $(sr -elvi | awk -F'-' '{print $1}' \
| sed '/:/d' | awk '{$1=$1};1' | rofi -hide-scrollbar \
-kb-row-select 'Tab' -kb-row-tab 'Control+space' \
-dmenu -mesg 'Tab for Autocomplete' -i -p 'Web Search: ' \
-padding 50 -line-padding 4)
;;
l)
ANS=$(echo " Lock| Logout| Reboot| Shutdown" | \
rofi -sep "|" -dmenu -i -p 'System: ' "" -width 20 \
-hide-scrollbar -eh 1 -line-padding 4 -padding 20 -lines 4)
case "$ANS" in
*Lock) i3lock-fancy ;;
*Logout) session-logout ;;
*Reboot) systemctl reboot ;;
*Shutdown) systemctl poweroff
esac
;;
*)
echo -e "Option does not exist: -$OPTARG"
_usage
exit 1
esac
done
shift $((OPTIND - 1))
exit 0

View File

@ -1,6 +1,5 @@
#!/usr/bin/env bash
if [[ "$(pidof compton)" ]]; then
al-compositor --restart
else

View File

@ -1,25 +0,0 @@
#!/usr/bin/env bash
on=""
off=""
# if the script is passed --toggle
if [[ "$1" ]]; then
if [[ "$1" == *toggle* ]] && [[ "$(pidof caffeine)" ]]; then
killall caffeine
elif [[ "$1" == *toggle* ]]; then
caffeine &
fi
exit 0
fi
while true; do
# caffeine is running
if [[ "$(pidof caffeine)" ]]; then
echo "%{F#0000FF}$on"
else
echo "%{F#FF0000}$off"
fi
sleep 2
done

View File

@ -1,22 +0,0 @@
#!/usr/bin/env bash
on=""
off=""
if [[ "$1" ]]; then
if [[ "$1" == *toggle* ]] && [[ "$(pidof compton)" ]]; then
al-compositor --stop
elif [[ "$1" == *toggle* ]]; then
al-compositor --start
fi
exit 0
fi
while true; do
if [[ "$(pidof compton)" ]]; then
echo "$on"
else
echo "%{F#888888}$off"
fi
sleep 2
done

View File

@ -1,9 +0,0 @@
#!/usr/bin/env bash
# small script to kill polybar if it is running
# if it isnt running then start it the default session
if [[ "$(pidof polybar)" ]]; then
pkill polybar
else
al-polybar-session
fi

View File

@ -1,32 +0,0 @@
#!/usr/bin/env bash
icon=""
if [[ $1 = "--toggle" ]] || [[ $1 = "-t" ]]; then
if pgrep redshift >/dev/null; then
pkill redshift
else
redshift-gtk &
fi
exit 0
fi
while true; do
pgrep -x redshift &> /dev/null
if [[ $? -eq 0 ]]; then
temp=$(redshift -p 2>/dev/null | grep temp | cut -d' ' -f3)
temp=${temp//K/}
fi
if [[ -z $temp ]]; then
echo " $icon " # Greyed out (not running)
elif [[ $temp -ge 5000 ]]; then
echo "%{F#8039A0} $icon " # Blue
elif [[ $temp -ge 4000 ]]; then
echo "%{F#F203F0} $icon " # Yellow
else
echo "%{F#FF5B6C} $icon " # Orange
fi
sleep 2
done

View File

@ -1,12 +0,0 @@
#!/usr/bin/env bash
# will check if precisely this termite instance is running
# if it is, then kill it, otherwise launch a new termite with these settings
# This allows a "Toggle-able" terminal, by simply binding a key to
# "toggle-termite"
if pgrep --full 'termite --title=work-term' &>/dev/null; then
pkill --full 'termite --title=work-term'
else
termite --title=work-term --class=work-term &
fi

158
home/bin/toggle.sh Executable file
View File

@ -0,0 +1,158 @@
#!/usr/bin/env bash
Name=$(basename "$0")
Version="0.1"
_usage() {
cat <<EOF
USAGE:
$Name [OPTIONS] [ADDITIONAL]
OPTIONS:
-h,--help Display this message
-v,--version Display script version
-t,--terminal Toggle a floating work terminal, no additional options
-p,--polybar Toggle the configured polybar session, no additional options
-c,--compton Toggle compton or daemon monitoring icon, can use toggle option
-r,--redshift Toggle redshift or daemon monitoring icon, can use toggle option
-f,--caffeine Toggle caffeine or daemon monitoring icon, can use toggle option
ADDITIONAL:
-tg,--toggle Toggle the program off/on, without this flag a monitor process will be started
EOF
}
toggle_terminal() {
if pgrep --full "termite --title=Work --class=Work" &>/dev/null; then
pkill --full "termite --title=Work --class=Work"
else
termite --title=Work --class=Work &
fi
}
toggle_polybar() {
if [[ $(pidof polybar) ]]; then
pkill polybar
else
al-polybar-session
fi
}
toggle_compton() {
if [[ $opt -eq 1 ]]; then
if [[ $(pidof compton) ]]; then
al-compositor --stop
else
al-compositor --start
fi
exit 0
fi
on=""
off=""
while true; do
if [[ $(pidof compton) ]]; then
echo "$on"
else
echo "%{F#888888}$off"
fi
sleep 2
done
}
toggle_redshift() {
if [[ $opt -eq 1 ]]; then
if [[ $(pidof redshift) ]]; then
pkill redshift
else
redshift &
fi
exit 0
fi
icon=""
while true; do
if [[ $(pidof redshift) ]]; then
temp=$(sed 's/K//g' <<< "$(grep -o '[0-9].*K' <<< "$(redshift -p 2>/dev/null)")")
fi
if [[ -z $temp ]]; then
echo " $icon " # Greyed out (not running)
elif [[ $temp -ge 5000 ]]; then
echo "%{F#8039A0} $icon " # Blue
elif [[ $temp -ge 4000 ]]; then
echo "%{F#F203F0} $icon " # Yellow
else
echo "%{F#FF5B6C} $icon " # Orange
fi
sleep 2
done
}
toggle_caffeine() {
if [[ $opt -eq 1 ]]; then
if [[ $(pidof caffeine) ]]; then
killall caffeine
else
caffeine &
fi
exit 0
fi
on=""
off=""
while true; do
if [[ $(pidof caffeine) ]]; then
echo "%{F#0000FF}$on"
else
echo "%{F#FF0000}$off"
fi
sleep 2
done
}
# Catch command line options
case $1 in
-t|--terminal)
toggle_terminal
;;
-p|--polybar)
toggle_polybar
;;
-c|--compton)
case $2 in
-tg|--toggle)
opt=1
esac
toggle_compton
;;
-r|--redshift)
case $2 in
-tg|--toggle)
opt=1
esac
toggle_redshift
;;
-f|--caffeine)
case $2 in
-tg|--toggle)
opt=1
esac
toggle_caffeine
;;
-h|--help)
_usage
;;
-v|--version)
echo -e "$Name -- Version $Version"
;;
*)
echo -e "Option does not exist: $1" && _usage && exit 1
esac
exit 0

36
home/bin/updates.sh Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env bash
BAR_ICON=""
ICON=/usr/share/icons/gnome/32x32/apps/system-software-update.png
while true; do
updates=$(wc -l <<< "$(checkupdates)")
if hash notify-send &>/dev/null; then
if [[ $updates -gt 50 ]]; then
notify-send -u critical -i $ICON \
"You really need to update soon!!" "$updates New package updates"
elif [[ $updates -gt 25 ]]; then
notify-send -u normal -i $ICON \
"You should update soon" "$updates New package updates"
elif [[ $updates -gt 2 ]]; then
notify-send -u low -i $ICON \
"$updates New package updates"
fi
fi
while [[ $updates -gt 0 ]]; do
if [[ $updates -eq 1 ]]; then
echo "$count Update"
elif [[ $updates -gt 1 ]]; then
echo "$updates Updates"
fi
sleep 8
count=$(wc -l <<< "$(checkupdates)")
done
while [[ $count -eq 0 ]]; do
echo $BAR_ICON
sleep 1200
count=$(wc -l <<< "$(checkupdates)")
done
done