From 250938a63a930abf09af990ceaf46f5344e0f193 Mon Sep 17 00:00:00 2001 From: Sheppy Date: Mon, 24 Jul 2017 17:52:24 +0200 Subject: [PATCH 1/5] i --- herbstluftwm/autostart | 1 + herbstluftwm/hl_status_deamon.py | 38 +++++++++++++++++++++++++++++++- zshrc | 7 +++--- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/herbstluftwm/autostart b/herbstluftwm/autostart index b537cde..6309914 100755 --- a/herbstluftwm/autostart +++ b/herbstluftwm/autostart @@ -60,6 +60,7 @@ hc keybind $Mod-q close #spawn shit hc keybind $Mod-Return spawn urxvt +hc keybind $Mod-y spawn urxvt #easier to press with one hand hc keybind $Mod-Shift-Return spawn ~/.config/herbstluftwm/hl_start_urxvt_cwd.py hc keybind $Mod-i spawn urxvt -e nohup zsh -c "chromium &" #need to reliably use the zshconf chromium if [[ $HOST =~ atlantis* ]]; then diff --git a/herbstluftwm/hl_status_deamon.py b/herbstluftwm/hl_status_deamon.py index 9e26b60..f5d8da4 100755 --- a/herbstluftwm/hl_status_deamon.py +++ b/herbstluftwm/hl_status_deamon.py @@ -5,7 +5,7 @@ import time import sys import subprocess from hl_panel_content import color_panel -from hl_utils import error, is_cip, shexec, color_remove, hlpath +from hl_utils import error, is_cip, shexec, color_remove, hlpath, is_laptop RED = 0xff0000 GREEN = 0x32CD32 @@ -41,13 +41,49 @@ def vpn_status(): with open(vpn_path,'w+') as g: g.write(out_vpn) +def battery(): + try: + bat = hl_utils.shexec("acpi -b") + if bat == '': + return color_panel("BATTERY FAILURE",RED) + bat = re.compile(r'Battery [0-9]+: ').sub('',bat) + plain = int(bat.split('%')[0][-3:].rstrip('%').lstrip(',')) + + #cur_time = [bat.split('%, ')[1].split(' ')[0].split(':')] + + if plain > 10: + plain += BAT_COLOR_OFFSET + + if bat.startswith("Charging"): + return color_panel("Charging",GREEN,seper=False) + color_panel(bat.lstrip("Charging ,").strip('\n'),get_color(plain,0,100)) + elif bat.startswith("Full") or bat.startswith('Unknown'): + return color_panel("On Supply and fully charged",GREEN) + elif plain <= 1: + return color_panel(">>>>>>>>>>>>>>>> --------------- WARNING BATTER FAILURE IMMINENT --------------- <<<<<<<<<<<<<",RED) + elif bat.startswith("Discharging"): + return color_panel("Discharging",RED,seper=False) + color_panel(bat.lstrip("Discharging ,").strip('\n'),get_color(plain,0,100)) + else: + return color_panel(bat.strip('\n'),get_color(plain,0,100)) + except ValueError as e: + return color_panel(str(e),RED) + +def battery_status(): + if is_laptop: + with open(hlpatch("battery.log")) as g: + g.write(battery()) + + if __name__ == '__main__': #print('"'+sys.argv[-1]+'"') if sys.argv[-1]=='--refresh': vpn_status() pr_acct_status() + battery() sys.exit() while(True): vpn_status() pr_acct_status() + battery_status() time.sleep(30) + + diff --git a/zshrc b/zshrc index 6e0ca03..77800e8 100644 --- a/zshrc +++ b/zshrc @@ -169,8 +169,8 @@ alias mountcip="sshfs ik15ydit@faui00n.cs.fau.de:/ -o reconnect,idmap=user $CIP_ alias umountcip="fusermount -u $CIP_MOUNTPOINT" ## CONNECT Locally ## -alias -g atlantislaptop="ik15ydit@atlantislaptop.local" -alias -g atlantismedion="ik15ydit@atlantismedion.local" +#alias -g atlantislaptop="ik15ydit@atlantislaptop.local" +#alias -g atlantismedion="ik15ydit@atlantismedion.local" ## DIRECT TO CONFIG ## alias hlconf="vim ~/.config/herbstluftwm/autostart" @@ -197,6 +197,7 @@ fi if [[ $HOST =~ atlantis* ]]; then alias dual="xrandr --output DVI-I-2 --right-of DVI-I-1" alias shutown="/sbin/poweroff" + alias s2disk="sudo /usr/sbin/s2disk" fi if [[ $HOST == "atlantislaptop" ]]; then alias backlightctl="tee /sys/class/backlight/intel_backlight/brightness <<< $1" @@ -253,7 +254,7 @@ else PECO=/usr/bin/ fi -alias cfind='print -z $(cat ~/.config/zshhistory.log | $PECO/peco)' +alias cfind='print -z $(g/zshhistory.log | $PECO/peco)' hhs(){print -z "$(cat ~/.config/zshhistory.log | $PECO/peco)"} zle -N hhstest hhs bindkey ^R hhstest From 16d1a2309b12c71a85dc83a5bce0c981aacf9abe Mon Sep 17 00:00:00 2001 From: Sheppy Date: Tue, 26 Sep 2017 11:40:36 +0200 Subject: [PATCH 2/5] various changes --- .gitignore | 3 +++ herbstluftwm/autostart | 2 +- herbstluftwm/hl_status_deamon.py | 4 ++-- herbstluftwm/test_cal.py | 11 +++++++++++ xconf/.xinitrc | 1 + zshrc | 8 +++++--- 6 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 herbstluftwm/test_cal.py diff --git a/.gitignore b/.gitignore index 6aa3774..f9f345a 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ herbstluftwm/restartpanels.sh htop/ inkscape/ libfm/ +spectaclerc libvirt/ libreoffice mc/ @@ -43,6 +44,7 @@ menus/ mimeapps.list nautilus/ pulse/ +unity3d/ pavucontrol.ini pcmanfm/ ristretto/ @@ -65,6 +67,7 @@ eventviewsrc herbstluftwm/__pycache__/ korgacrc korganizerrc +kolourpaintrc nohup.out specialmailcollectionsrc unity3d/tubus/ diff --git a/herbstluftwm/autostart b/herbstluftwm/autostart index 5b93ef1..e89357c 100755 --- a/herbstluftwm/autostart +++ b/herbstluftwm/autostart @@ -74,7 +74,7 @@ hc keybind $Mod-p spawn pavucontrol hc keybind $Mod-Shift-l spawn libreoffice hc keybind $Mod-t spawn /bin/bash -c "LC_ALL=en_DK.utf8 && export LC_ALL && thunderbird" hc keybind $Mod-Shift-i spawn urxvt -e ssh ik15ydit@ircbox.cs.fau.de -t 'tmux a -d' -hc keybind $Mod-Shift-t spawn urxvt -e ssh ik15ydit@faui06c.cs.fau.de -t "/proj/ciptmp/ik15ydit/Zeug/Telegram/tg/bin/telegram-cli -k tg-server.pub" +hc keybind $Mod-Shift-t spawn urxvt -e ssh telegram-sheppy@atlantishq.de -t "/home/telegram-sheppy/tg/bin/telegram-cli" hc keybind $Mod-j spawn /bin/bash -c "rm $HOME/.config/herbstluftwm/irc.log && herbstclient spawn urxvt -e 'exit'" hc keybind $Mod-e spawn rofi -combi-mode window,run -show combi -modi combi hc keybind $Mod-Shift-e spawn rofi -show run diff --git a/herbstluftwm/hl_status_deamon.py b/herbstluftwm/hl_status_deamon.py index f5d8da4..5790392 100755 --- a/herbstluftwm/hl_status_deamon.py +++ b/herbstluftwm/hl_status_deamon.py @@ -64,8 +64,8 @@ def battery(): return color_panel("Discharging",RED,seper=False) + color_panel(bat.lstrip("Discharging ,").strip('\n'),get_color(plain,0,100)) else: return color_panel(bat.strip('\n'),get_color(plain,0,100)) - except ValueError as e: - return color_panel(str(e),RED) + except ValueError as e: + return color_panel(str(e),RED) def battery_status(): if is_laptop: diff --git a/herbstluftwm/test_cal.py b/herbstluftwm/test_cal.py new file mode 100644 index 0000000..c697d43 --- /dev/null +++ b/herbstluftwm/test_cal.py @@ -0,0 +1,11 @@ +import urllib3 +import socket + +http = urllib3.PoolManager() +socket.setdefaulttimeout(5) +url = 'https://squarez.fauiwg.de:7001/radicale/testuser/cal.ics/' +headers = urllib3.util.make_headers(basic_auth='testuser:test') +r = http.request('GET', url, headers=headers) +f = open(test.log,'w') +f.write(r) +f.close() diff --git a/xconf/.xinitrc b/xconf/.xinitrc index ecb5f13..f2a6ba0 100644 --- a/xconf/.xinitrc +++ b/xconf/.xinitrc @@ -1,3 +1,4 @@ xrdb ~/.Xressources +xset r rate 300 25 eval `ssh-agent` exec herbstluftwm diff --git a/zshrc b/zshrc index c3d33c9..e56dd29 100644 --- a/zshrc +++ b/zshrc @@ -104,6 +104,7 @@ if [[ $HOST =~ atlantis* ]]; then alias i3lock="i3lock --image=/home/ik15ydit/.config/i3lock/bg.png" alias hlock="i3lock --image=/home/ik15ydit/.config/i3lock/bg.png -t" alias -g sq="sheppy@squarez.fauiwg.de" + alias -g pine="sheppy@sheppy.chickenkiller.com" else alias transparent_xlock="xlock -mode blank -geometry 1x1" fi @@ -115,13 +116,12 @@ alias psearch="apt-cache search" if [[ $HOST =~ atlantis* ]]; then #alias gedit="gedit 2&>/dev/null &" alias kpaint="kolourpaint 2&>/dev/null &" - alias telegram='ssh uni -t "/proj/ciptmp/ik15ydit/Zeug/Telegram/tg/bin/telegram-cli -k tg-server.pub"' + alias telegram='ssh telegram-sheppy@atlantishq.de -t "~/tg/bin/telegram-cli"' alias telegram-plain='ssh uni -t "/proj/ciptmp/ik15ydit/Zeug/Telegram/tg/bin/telegram-cli --disable-colors --disable-readline -k tg-server.pub"' alias x='exec startx' alias vpn='sudo /usr/bin/openvpn_cip.sh' else - alias telegram='/proj/ciptmp/ik15ydit/Zeug/Telegram/tg/bin/telegram-cli -k tg-server.pub' alias burp=/home/cip/2013/ik15ydit/ciptmp/reps/WebScan/burpsuite/BurpSuiteFree fi alias rehash="source ~/.config/zshrc" @@ -244,7 +244,7 @@ ssh_func(){ ssh $@; printf '\033]708;black\007' } -alias -g ssh="ssh_func" +alias ssh="ssh_func" ### REVERSE SEARCH ### @@ -271,3 +271,5 @@ else export FIRST_RUN exec zsh fi + +alias hgrep="cat ~/.config/zshhistory.log | grep" From 51586781845c855d92b26d05db056e17e43bc936 Mon Sep 17 00:00:00 2001 From: Sheppy Date: Tue, 26 Sep 2017 11:49:12 +0200 Subject: [PATCH 3/5] vimrc revert --- vim/rc | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/vim/rc b/vim/rc index ee78769..521b4b7 100644 --- a/vim/rc +++ b/vim/rc @@ -27,62 +27,13 @@ set lazyredraw "Shift-i will start inserting at the begin of the line, i will start before curser "Shift-t end of line or t just behind curser (tail) "f does exactly the same but closer to shift, easier to use maybe -nnoremap t a -nnoremap T A -nnoremap f a -nnoremap f A - -"search -set incsearch -set hlsearch -nnoremap Ctrl-l :nohlsearch - -"movement "move by visual line nnoremap w g nnoremap s g nnoremap a nnoremap d -"move by \n or \r\n -nnoremap W -nnoremap S -nnoremap A -nnoremap D -"move to line at bottom/top of current screen -nnoremap g H -nnoremap G L "gg will go to start of file, GG to end of file and M will actually jump to mid of screen - -"move by word (dervied from Egoshooters where you can lean right or left usually with q and e) -nnoremap q b -"words to left (3q would be 3 words left) -nnoremap Q B -"words left, with all non-alphanumeric shit as sperators (i.e. '-') -"e and E same as above for right side - -"textmanipulation -"delete (d is taken by wasd, c is close to d) -nnoremap c d -"delte selected -nnoremap cc dd -"delte line -nnoremap cl dd -"dene (cc works too) -nnoremap ce dw -nnoremap cq cb -"delete next word -"copy/paste (y is the vim default, Ctrl-c is for many GUI programs and windows) -nnoremap yr y$ -"yank (copy) renemaining line behind curser -nnoremap Ctrl-c y -"yank (copy) selected, equivalent to y - -"marocs -nnoremap r q -nnoremap R qq -nnoremap rr qq - "modifier keys let mapleader="," nnoremap l $ From 23cfa22aa98841d50d65c25a6584676763f34baa Mon Sep 17 00:00:00 2001 From: Sheppy Date: Tue, 26 Sep 2017 11:51:34 +0200 Subject: [PATCH 4/5] whateverprovides --- zshrc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/zshrc b/zshrc index b1dcc5b..8b34673 100644 --- a/zshrc +++ b/zshrc @@ -276,3 +276,9 @@ else fi alias hgrep="cat ~/.config/zshhistory.log | grep" + +## APT ## +whateverprovides(){ + apt-file search --regexp "bin/$1""$" +} +export whateverprovide From 00d5087503e65af95b4854002b4d54fdbc80b072 Mon Sep 17 00:00:00 2001 From: Sheppy Date: Fri, 29 Sep 2017 02:49:38 +0200 Subject: [PATCH 5/5] Added IP --- herbstluftwm/hl_panel_content.py | 33 ++++++++------------------------ herbstluftwm/hl_status_deamon.py | 26 +++++++++++++++++-------- herbstluftwm/hl_utils.py | 2 +- 3 files changed, 27 insertions(+), 34 deletions(-) diff --git a/herbstluftwm/hl_panel_content.py b/herbstluftwm/hl_panel_content.py index 15f9859..9f99fd8 100755 --- a/herbstluftwm/hl_panel_content.py +++ b/herbstluftwm/hl_panel_content.py @@ -86,6 +86,12 @@ def vpn(): tmp = ' '+tmp return tmp; +def ip(): + with open(hl_utils.hlpath("ip.log")) as f: + tmp = f.read() + tmp = ' '+tmp + return tmp; + def battery(): if hl_utils.is_laptop(): try: @@ -114,30 +120,7 @@ def battery(): return color_panel(str(e),RED) else: return "" + -def irc(): - if hl_utils.is_cip(): - ret_string = "IRC ERROR" - try: - fname = hl_utils.hlpath("irc.log") - tmp = [] - with open(fname) as f: - for l in f: - tmp+=[l] - if len(tmp) == 0: - return "" - msg = " ".join(tmp[-1].split(" ")[2:])[:50] - user = tmp[-1].split(" ")[1][:15] - if not "%push" in msg: - return "" - pattern = re.compile("\^+[fb]g[(]+#[0-9]+[)]+") - msg = re.sub(pattern,"",msg) - user = re.sub(pattern,"",user) - ret_string = "MSG FROM: "+user+"-> "+msg.rstrip('\n')+" - [ "+str(len(tmp))+" total ]" - return color_panel(ret_string,RED) - except(IOError): - pass - else: - return '' if __name__ == "__main__": - print(vpn(),guthaben(),battery(),sep='') + print(ip(),vpn(),guthaben(),battery(),sep='') diff --git a/herbstluftwm/hl_status_deamon.py b/herbstluftwm/hl_status_deamon.py index 5790392..d09cd24 100755 --- a/herbstluftwm/hl_status_deamon.py +++ b/herbstluftwm/hl_status_deamon.py @@ -4,12 +4,15 @@ import sys import time import sys import subprocess -from hl_panel_content import color_panel +from hl_panel_content import color_panel, get_color from hl_utils import error, is_cip, shexec, color_remove, hlpath, is_laptop +import re RED = 0xff0000 GREEN = 0x32CD32 YELLOW = 0xffff00 +BAT_COLOR_OFFSET = 10 + #Druckerguthaben def pr_acct_status(): @@ -43,7 +46,7 @@ def vpn_status(): def battery(): try: - bat = hl_utils.shexec("acpi -b") + bat = shexec("acpi -b") if bat == '': return color_panel("BATTERY FAILURE",RED) bat = re.compile(r'Battery [0-9]+: ').sub('',bat) @@ -69,21 +72,28 @@ def battery(): def battery_status(): if is_laptop: - with open(hlpatch("battery.log")) as g: + with open(hlpath("battery.log"),'w') as g: g.write(battery()) +def ip_status(): + with open(hlpath("ip.log"),'w') as g: + p="Public IP: " + try: + tmp=color_panel(p+shexec("wget --timeout=3 -O- --quiet https://atlantishq.de/ipcheck"),GREEN) + except: + tmp=color_panel("Offline",RED) + g.write(tmp) + if __name__ == '__main__': #print('"'+sys.argv[-1]+'"') - if sys.argv[-1]=='--refresh': - vpn_status() - pr_acct_status() - battery() - sys.exit() while(True): vpn_status() pr_acct_status() battery_status() + ip_status() + if sys.argv[-1]=='--refresh': + break time.sleep(30) diff --git a/herbstluftwm/hl_utils.py b/herbstluftwm/hl_utils.py index f134834..12ab9bc 100755 --- a/herbstluftwm/hl_utils.py +++ b/herbstluftwm/hl_utils.py @@ -13,7 +13,7 @@ def color_remove(s): return re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]').sub('',s) def shexec(s): - return subprocess.check_output(shlex.split(s),shell=True).decode() + return subprocess.check_output(shlex.split(s),shell=False).decode() def is_cip(): u = os.uname()