From 8a34b1f760a415e330a65657198455401f331c21 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Sun, 9 Oct 2016 18:05:33 +0200 Subject: [PATCH 01/11] htoprc / sceenrc --- config/htop/htoprc | 26 ++++++++++++++++++++++++++ screenrc | 9 +++++++++ 2 files changed, 35 insertions(+) create mode 100644 config/htop/htoprc create mode 100644 screenrc diff --git a/config/htop/htoprc b/config/htop/htoprc new file mode 100644 index 0000000..882a239 --- /dev/null +++ b/config/htop/htoprc @@ -0,0 +1,26 @@ +# Beware! This file is rewritten by htop when settings are changed in the interface. +# The parser is also very primitive, and not human-friendly. +fields=0 48 17 18 38 39 40 2 46 47 49 1 +sort_key=46 +sort_direction=1 +hide_threads=0 +hide_kernel_threads=0 +hide_userland_threads=0 +shadow_other_users=0 +show_thread_names=0 +show_program_path=1 +highlight_base_name=0 +highlight_megabytes=0 +highlight_threads=1 +tree_view=0 +header_margin=0 +detailed_cpu_time=0 +cpu_count_from_zero=0 +update_process_names=0 +account_guest_in_cpu_meter=0 +color_scheme=0 +delay=15 +left_meters=AllCPUs Memory Swap +left_meter_modes=1 1 1 +right_meters=Tasks LoadAverage Uptime +right_meter_modes=2 2 2 diff --git a/screenrc b/screenrc new file mode 100644 index 0000000..e92bde1 --- /dev/null +++ b/screenrc @@ -0,0 +1,9 @@ +term xterm-256color +hardstatus off +hardstatus alwayslastline +hardstatus alwayslastline '%{= G}[ %{G}%H %{g}][%= %{= w}%?%-Lw%?%{= R}%n*%f %t%?%{= R}(%u)%?%{= w}%+Lw%?%= %{= g}][ %{y}Load: %l %{g}][%{B}%Y-%m-%d %{W}%c:%s %{g}]' +startup_message off +termcapinfo xterm* ti@:te@ +vbell off +altscreen on +windowlist string "%4n %h%=%f" From ec985118f7726f83c4516dbff6ccd549b0eec591 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Fri, 28 Oct 2016 07:50:59 +0200 Subject: [PATCH 02/11] Bye arrow keys! --- config/i3/config | 74 ++++++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/config/i3/config b/config/i3/config index 5e94b25..6ad3bed 100644 --- a/config/i3/config +++ b/config/i3/config @@ -81,11 +81,11 @@ bindsym $mod+j focus down bindsym $mod+k focus up bindsym $mod+l focus right -# alternatively, you can use the cursor keys: -bindsym $mod+Left focus left -bindsym $mod+Down focus down -bindsym $mod+Up focus up -bindsym $mod+Right focus right +## alternatively, you can use the cursor keys: +#bindsym $mod+Left focus left +#bindsym $mod+Down focus down +#bindsym $mod+Up focus up +#bindsym $mod+Right focus right # move focused window bindsym $mod+Shift+h move left @@ -93,11 +93,11 @@ bindsym $mod+Shift+j move down bindsym $mod+Shift+k move up bindsym $mod+Shift+l move right -# alternatively, you can use the cursor keys: -bindsym $mod+Shift+Left move left -bindsym $mod+Shift+Down move down -bindsym $mod+Shift+Up move up -bindsym $mod+Shift+Right move right +## alternatively, you can use the cursor keys: +#bindsym $mod+Shift+Left move left +#bindsym $mod+Shift+Down move down +#bindsym $mod+Shift+Up move up +#bindsym $mod+Shift+Right move right # workspace back and forth (with/without active container) workspace_auto_back_and_forth yes @@ -167,16 +167,28 @@ bindsym $mod+9 workspace $WS9 bindsym $mod+0 workspace $WS10 #navigate workspaces next / previous -bindsym $mod+Ctrl+Left workspace prev_on_output -bindsym $mod+Ctrl+Right workspace next_on_output -bindsym $mod+Ctrl+Down workspace prev -bindsym $mod+Ctrl+Up workspace next +bindsym $mod+Ctrl+h workspace prev_on_output +bindsym $mod+Ctrl+l workspace next_on_output +bindsym $mod+Ctrl+j workspace prev +bindsym $mod+Ctrl+k workspace next + +##navigate workspaces next / previous (arrow keys) +#bindsym $mod+Ctrl+Left workspace prev_on_output +#bindsym $mod+Ctrl+Right workspace next_on_output +#bindsym $mod+Ctrl+Down workspace prev +#bindsym $mod+Ctrl+Up workspace next # Move to workspace next / previous with focused container -bindsym $mod+Ctrl+Shift+Left move container to workspace prev_on_output; workspace prev_on_output -bindsym $mod+Ctrl+Shift+Right move container to workspace next_on_output; workspace next_on_output -bindsym $mod+Ctrl+Shift+Down move container to workspace prev; workspace prev -bindsym $mod+Ctrl+Shift+Up move container to workspace next; workspace next +bindsym $mod+Ctrl+Shift+h move container to workspace prev_on_output; workspace prev_on_output +bindsym $mod+Ctrl+Shift+l move container to workspace next_on_output; workspace next_on_output +bindsym $mod+Ctrl+Shift+j move container to workspace prev; workspace prev +bindsym $mod+Ctrl+Shift+k move container to workspace next; workspace next + +## Move to workspace next / previous with focused container (arrow keys) +#bindsym $mod+Ctrl+Shift+Left move container to workspace prev_on_output; workspace prev_on_output +#bindsym $mod+Ctrl+Shift+Right move container to workspace next_on_output; workspace next_on_output +#bindsym $mod+Ctrl+Shift+Down move container to workspace prev; workspace prev +#bindsym $mod+Ctrl+Shift+Up move container to workspace next; workspace next # move focused container to workspace bindsym $mod+ctrl+1 move container to workspace $ws1 @@ -202,11 +214,17 @@ bindsym $mod+shift+8 move container to workspace $ws8; workspace $ws8 bindsym $mod+shift+9 move container to workspace $ws9; workspace $ws9 bindsym $mod+shift+0 move container to workspace $ws10; workspace $ws10 -# move workspaces to screen -bindsym $mod+ctrl+shift+r move workspace to output right -bindsym $mod+ctrl+shift+l move workspace to output left -bindsym $mod+Ctrl+Shift+u move workspace to output above -bindsym $mod+Ctrl+Shift+d move workspace to output below +## move workspaces to screen +#bindsym $mod+ctrl+shift+r move workspace to output right +#bindsym $mod+ctrl+shift+l move workspace to output left +#bindsym $mod+Ctrl+Shift+u move workspace to output above +#bindsym $mod+Ctrl+Shift+d move workspace to output below + +# move workspaces to screen (arrow keys) +bindsym $mod+ctrl+shift+Right move workspace to output right +bindsym $mod+ctrl+shift+Left move workspace to output left +bindsym $mod+Ctrl+Shift+Up move workspace to output above +bindsym $mod+Ctrl+Shift+Down move workspace to output below # Open applications on specific workspaces assign [class="Thunderbird"] $WS7 @@ -268,11 +286,11 @@ mode "Resize" { bindsym i resize shrink height 10 px or 10 ppt bindsym l resize grow width 10 px or 10 ppt - # same bindings, but for the arrow keys - bindsym Left resize shrink width 10 px or 10 ppt - bindsym Down resize grow height 10 px or 10 ppt - bindsym Up resize shrink height 10 px or 10 ppt - bindsym Right resize grow width 10 px or 10 ppt + ## same bindings, but for the arrow keys + #bindsym Left resize shrink width 10 px or 10 ppt + #bindsym Down resize grow height 10 px or 10 ppt + #bindsym Up resize shrink height 10 px or 10 ppt + #bindsym Right resize grow width 10 px or 10 ppt # back to normal: Enter or Escape bindsym Return mode "default" From d4780d447e96a8ea38ea69949708c4aa944dfd53 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Fri, 28 Oct 2016 10:28:16 +0200 Subject: [PATCH 03/11] Moar keybindings --- config/dunst/dunstrc | 10 +++++----- config/i3/config | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config/dunst/dunstrc b/config/dunst/dunstrc index 1f9b98c..eead4c9 100644 --- a/config/dunst/dunstrc +++ b/config/dunst/dunstrc @@ -96,7 +96,7 @@ # # If this option is set to mouse or keyboard, the monitor option # will be ignored. - follow = mouse + follow = none # Should a notification popped up from history be sticky or timeout # as if it would normally do. @@ -162,19 +162,19 @@ # Xev might be helpful to find names for keys. # Close notification. - close = mod1+space + close = mod4+n # Close all notifications. # close_all = ctrl+shift+space - close_all = ctrl+mod1+space + close_all = ctrl+mod4+n # Redisplay last message(s). # On the US keyboard layout "grave" is normally above TAB and left # of "1". - history = ctrl+mod4+h + history = shift+mod4+n # Context menu. - context = ctrl+alt+c + context = mod1+mod4+n [urgency_low] # IMPORTANT: colors have to be defined in quotation marks. diff --git a/config/i3/config b/config/i3/config index 6ad3bed..31d89a2 100644 --- a/config/i3/config +++ b/config/i3/config @@ -29,8 +29,8 @@ font pango:Sans 8 floating_modifier $mod # kill focused window -#bindsym $mod+F4 kill -bindsym Mod1+F4 kill +bindsym $mod+z kill +#bindsym Mod1+F4 kill bindsym button2 kill # start dmenu (a program launcher) From 8beaf72eaf15ea34660e46a7dac06bfde1a565ad Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Wed, 2 Nov 2016 11:54:27 +0100 Subject: [PATCH 04/11] Naming convention changed --- bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashrc b/bashrc index 07d6b6c..c4bbb9b 100644 --- a/bashrc +++ b/bashrc @@ -19,7 +19,7 @@ fi export USER=$(whoami) export HOSTNAME=$(cat /etc/hostname) -HOST=${HOSTNAME//geoffrey-/} +HOST=${HOSTNAME%%.*} PS1="\[\e]2;\u@${HOST} \w\a\]\[\e[0;37m\][\[\e[0;${col}m\]\u\[\e[0;37m\]@\[\e[0;34m\]${HOST} \[\e[0;36m\]\W\[\e[0;37m\]]\$\[\e[1;97m\] " PS2="> " PS3="+ " From fbcd9ec19ad7d955cf6db9750130eaa9fbf821e7 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Wed, 2 Nov 2016 13:48:33 +0100 Subject: [PATCH 05/11] Proxytunnel can't work outside port 443 anyway... --- scripts/tunnel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tunnel b/scripts/tunnel index dd90532..ad92ff9 100755 --- a/scripts/tunnel +++ b/scripts/tunnel @@ -19,7 +19,7 @@ try: user = None if len(s) == 2: user, proxy = s - args = ['proxytunnel', '-p', proxy, '-d', host + ':' + port] + args = ['proxytunnel', '-p', proxy, '-d', host + ':' + '443'] if user: args += ['-P', user] call(args) From d421235c1785874b88a49e4f7986e5738b50700f Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Thu, 17 Nov 2016 05:48:44 +0100 Subject: [PATCH 06/11] Enough of this --- bashrc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bashrc b/bashrc index c4bbb9b..2a9cbde 100644 --- a/bashrc +++ b/bashrc @@ -20,11 +20,10 @@ fi export USER=$(whoami) export HOSTNAME=$(cat /etc/hostname) HOST=${HOSTNAME%%.*} -PS1="\[\e]2;\u@${HOST} \w\a\]\[\e[0;37m\][\[\e[0;${col}m\]\u\[\e[0;37m\]@\[\e[0;34m\]${HOST} \[\e[0;36m\]\W\[\e[0;37m\]]\$\[\e[1;97m\] " +PS1="\[\e]2;\u@${HOST} \w\a\]\[\e[0;37m\][\[\e[0;${col}m\]\u\[\e[0;37m\]@\[\e[0;34m\]${HOST} \[\e[0;36m\]\W\[\e[0;37m\]]\$\[\e[0m\] " PS2="> " PS3="+ " PS4="+ " -trap 'echo -ne "\e[0m"' DEBUG # Vars From e1d7223175750920141dae5257f4119173a99455 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Sat, 19 Nov 2016 23:51:30 +0100 Subject: [PATCH 07/11] Bye bye locinst, hello debloc! Well, for what I wanted to do, locinst really was badly designed and overkill... I'm really happy with how debloc turned out! --- scripts/debloc.sh | 224 +++++++++++++++++++++++++++++++++++++++++++++ scripts/index.sh | 2 +- scripts/locinst.py | 152 ------------------------------ scripts/locinst.sh | 203 ---------------------------------------- 4 files changed, 225 insertions(+), 356 deletions(-) create mode 100755 scripts/debloc.sh delete mode 100755 scripts/locinst.py delete mode 100755 scripts/locinst.sh diff --git a/scripts/debloc.sh b/scripts/debloc.sh new file mode 100755 index 0000000..b359f8e --- /dev/null +++ b/scripts/debloc.sh @@ -0,0 +1,224 @@ +#!/usr/bin/env bash + +DEBLOC_DB=$HOME/.config/debloc +DEBLOC_ROOT=$HOME/.debloc + +# TODO Configurable +DEBIAN_MIRROR=http://debian.polytech-lille.fr/debian +DEBIAN_MIRROR=http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu + +mkdir -p $DEBLOC_DB &> /dev/null +mkdir -p $DEBLOC_ROOT &> /dev/null + +export PATH="$DEBLOC_ROOT/usr/bin:$DEBLOC_ROOT/usr/games/:$PATH" +export LD_LIBRARY_PATH="$DEBLOC_ROOT/lib:$LD_LIBRARY_PATH" +export PYTHONPATH="$DEBLOC_ROOT/usr/lib/python3:$PYTHONPATH" +export QT_QPA_PLATFORM_PLUGIN_PATH="$DEBLOC_ROOT/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms" + +# Tell if a package exists +function _debloc-exists { # package + LANG=C apt-cache show $1 &> /dev/null + if [ $? == 0 ]; then + return 1 + else + return 0 + fi +} + +# Return the real package associated with a virtual package +# If not a virtual package, return the input +function _debloc-filterVirtual { # package + pkg=$1 + LANG=C apt-cache policy $1 | grep "Candidate" | grep "(none)" > /dev/null + if [ $? == 0 ]; then + # TODO This is not really accurate + LANG=C apt-cache showpkg $pkg | tail -1 | cut -d ' ' -f 1 + else + echo $pkg + fi + return 0 +} + +# Tell if a package is installed via debloc +function _debloc-locallyInstalled { # package + if [ -e $DEBLOC_DB/$1 ]; then + return 1 + else + return 0 + fi +} + +# Tell if a package is installed system-wide +function _debloc-globallyInstalled { # package + LANG=C apt-cache policy $1 | grep "Installed" | grep "(none)" > /dev/null + return $? +} + +# Get informations about a package +function _debloc-packageShow { # package + LANG=C apt-cache show $1 | while read line; do + if [ "$line" == '' ]; then + break + fi + echo "$line" + done + return 0 +} + +# Get the path of a package +function _debloc-packagePath { # package + _debloc-packageShow $1 | grep "^Filename:" | head -1 | cut -d ':' -f 2 | sed -e 's/^[[:space:]]*//' + return 0 +} + +# Get the md5sum of a package +function _debloc-packageMd5sum { # package + _debloc-packageShow $1 | grep "^MD5sum:" | cut -d ':' -f 2 | sed -e 's/^[[:space:]]*//' + return 0 +} + +# Update symbolics links in $DEBLOC_ROOT/lib +function _debloc-ldconfig { + mkdir -p $DEBLOC_ROOT/lib &> /dev/null + rm -f $DEBLOC_ROOT/lib/* &> /dev/null + if [ -e $DEBLOC_ROOT/usr/lib ]; then + find $DEBLOC_ROOT/usr/lib -type f -name "*.so*" | while read lib; do + ln --symbolic --force "$lib" "$DEBLOC_ROOT/lib/$(basename $lib)" + done + find $DEBLOC_ROOT/usr/lib -type l -name "*.so*" | while read link; do + yes | cp --force --no-dereference --preserve=links "$link" "$DEBLOC_ROOT/lib/" &> /dev/null + done + fi + +} + +# Install debian archive +function _debloc-installDeb { # path + TMP_DIR=$(mktemp -d) &> /dev/null + $(cd $TMP_DIR; ar x "$1") + TAR_FILE=$(find $TMP_DIR -type f -name "data.tar.*" | head -1) + if [ -e "$TAR_FILE" ]; then + # Output for DB saving + tar tf $TAR_FILE + tar xf $TAR_FILE -C $DEBLOC_ROOT + + # _debloc-ldconfig + mkdir -p $DEBLOC_ROOT/lib &> /dev/null + tar tf $TAR_FILE | grep '^./usr/lib/' | grep '\.so' | while read file; do + lib=$(readlink -f $DEBLOC_ROOT/$file) + if [ -f $lib ]; then + ln --symbolic --force "$lib" "$DEBLOC_ROOT/lib/$(basename $file)" + fi + if [ -h $lib ]; then + yes | cp --force --no-dereference --preserve=links "$(basename $link)" "$DEBLOC_ROOT/lib/" &> /dev/null + fi + done + fi + + rm -rf $TMP_DIR &> /dev/null + return 0 + +} + +# Install package +function _debloc-install { # package + pkg=$1 + + echo "→ Downloading" + url=${DEBIAN_MIRROR}/$(_debloc-packagePath $pkg) + DEB_FILE=$(mktemp) &> /dev/null + wget "$url" --quiet -O $DEB_FILE + if [ $? != 0 ]; then + echo "→ Failed!" + return 4 + fi + + echo "→ Verifying sums" + theo=$(_debloc-packageMd5sum $pkg) + real=$(md5sum $DEB_FILE | cut -d ' ' -f 1) + if [ "$theo" != "$real" ]; then + rm -f $DEB_FILE &> /dev/null + echo "→ Failed!" + return 5 + fi + + echo "→ Installing" + _debloc-installDeb $DEB_FILE > $DEBLOC_DB/$pkg + + echo "→ Done!" + rm -f $DEB_FILE &> /dev/null + return 0 +} + +# Get the dependencies of a package +function _debloc-packageDeps { # package + LANG=C apt-cache show $1 | grep '^Depends:' | sed 's/Depends: //' | sed 's/, /\n/g' | cut -d ' ' -f 1 + return 0 +} + +# Install package with dependencies +function _debloc-installDeps { # package + pkg=$1 + echo "Installing $pkg" + _debloc-packageDeps $pkg | while read dep; do + dep=$(_debloc-filterVirtual $dep) + _debloc-locallyInstalled $dep + if [ $? == 1 ]; then + echo "- Dependency $dep is already installed with Debloc" + continue + fi + _debloc-globallyInstalled $dep + if [ $? == 1 ]; then + echo "- Dependency $dep is already installed on the system" + continue + fi + _debloc-installDeps $dep | while read line; do echo "- $line"; done + done + _debloc-install $pkg + return 0 +} + +# Install package with dependencies (user version with verifications) +function debloc-install { # package + for pkg in $*; do + pkg=$(_debloc-filterVirtual $pkg) + _debloc-exists $pkg + if [ $? == 0 ]; then + echo "Unknown package $pkg" + continue + fi + _debloc-locallyInstalled $pkg + if [ $? == 1 ]; then + echo "Package $pkg is already installed with Debloc" + continue + fi + _debloc-globallyInstalled $pkg + if [ $? == 1 ]; then + echo "Package $pkg is already installed on the system" + continue + fi + _debloc-installDeps $pkg + done + return 0 + +} + +# Install debian archive (user version with verifications) +function debloc-deb { # path + for path in $*; do + if [ ! -f "$path" ]; then + echo "$path is not a file" + return 6 + fi + echo "Installing $(basename $path)" + _debloc-installDeb "$(readlink -f $path)" > $DEBLOC_DB/$(basename $path) + done + return 0 + +} + +# Remove every package installed with Debloc +function debloc-flush { + rm -rf $DEBLOC_ROOT/* &> /dev/null + rm -f $DEBLOC_DB/* &> /dev/null +} diff --git a/scripts/index.sh b/scripts/index.sh index 3d7f7e8..87b928b 100644 --- a/scripts/index.sh +++ b/scripts/index.sh @@ -1,3 +1,3 @@ source ~/.scripts/proxy.sh -source ~/.scripts/locinst.sh +source ~/.scripts/debloc.sh alias beep=~/.scripts/beep.sh diff --git a/scripts/locinst.py b/scripts/locinst.py deleted file mode 100755 index d0b75ea..0000000 --- a/scripts/locinst.py +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/env python3 - -import json -import urllib.request -import subprocess -import os -import sys -import re - -LOCINST_DIR=os.environ['HOME']+'/.locinst' -LOCINST_DB=os.environ['HOME']+'/.config/locinst' -LOCINST_TMP='/tmp/locinst' - -DEBIAN_MIRROR = 'http://debian.polytech-lille.fr/debian/' - -def globallyInstalled(name): - try: - a = subprocess.check_output(['apt-cache', 'policy', name]).decode('utf8').strip().lower() - return 'installé\xa0: (aucun)' not in [b.strip() for b in a.split('\n')] - except FileNotFoundError: - return False - -def locallyInstalled(name): - return False - -def debian_install(name): - def findPackage(name): - raw = urllib.request.urlopen('http://sources.debian.net/api/search/' + name + '/') - data = json.loads(raw.read().decode('utf8')) - results = data['results'] - if results['exact']: - return True - else: - print("Package " + name + " does not exist" + (", however you might want to try one of the following: " + ", ".join([pkg['name'] for pkg in results['other']]) if results['other'] else "") + ".") - return False - - def findVersion(name): - raw = urllib.request.urlopen('http://sources.debian.net/api/src/' + name + '/') - data = json.loads(raw.read().decode('utf8')) - - def findByCodename(codename): - goodVersions = [version['version'] for version in data['versions'] if codename in version['suites']] - return goodVersions[0] if len(goodVersions) else False - - try: - codename = subprocess.check_output(['lsb_release', '--codename', '--short']).decode('utf8').strip().lower() - choice = findByCodename(codename) - if choice: - return choice - except FileNotFoundError: - pass - - return findByCodename('jessie') - - def parseInfos(control): - paragraph = {} - key = '' - - for line in control.strip().split('\n'): - if re.match('\s', line[0]): - try: - paragraph[key] += '\n' + line.strip() - except KeyError: - pass - elif re.match('^[\w-]+\:', line): - key = line.split(':')[0].lower() - paragraph[key] = line[len(key)+1:].strip() - - return paragraph - - def getArch(): - arch = subprocess.check_output(['uname', '--machine']).decode('utf8').strip().lower() - if arch == 'x86_64': - arch = 'amd64' - return arch - - - def download(name, version): - arch = getArch() - filename = name + '_' + version + '_' + arch - - print("Downloading " + filename + "...") - url = DEBIAN_MIRROR + 'pool/main/' + (name[0] if name[0:3] != 'lib' else name[0:4]) + '/' + name + '/' + filename + '.deb' - debfile = LOCINST_TMP + '/' + filename + '.deb' - urllib.request.urlretrieve(url, debfile) - - extractdir = LOCINST_TMP + '/' + filename - try: - os.mkdir(extractdir) - except FileExistsError: - pass - subprocess.check_call(['ar', 'x', debfile], cwd=extractdir) - subprocess.check_call(['rm', '-rf', debfile], stdout=subprocess.DEVNULL) - - controltar = [a for a in os.listdir(extractdir) if a.split('.')[:2] == ['control', 'tar']][0] - subprocess.check_call(['tar', 'xf', extractdir + '/' + controltar], cwd=extractdir) - with open(extractdir + '/control') as controlfile: - control = controlfile.read() - - finaldir = LOCINST_TMP + '/' + name - try: - os.mkdir(finaldir) - except FileExistsError: - pass - datatar = [a for a in os.listdir(extractdir) if a.split('.')[:2] == ['data', 'tar']][0] - subprocess.check_call(['tar', 'xf', extractdir + '/' + datatar], cwd=finaldir) - - subprocess.check_call(['rm', '-rf', extractdir]) - return { - 'final': finaldir, - 'control': control - } - - - if not findPackage(name): - return 4 - - if globallyInstalled(name): - return 5 - - print("Installing " + name + "...") - version = findVersion(name) - - if not version: - return 6 - - d = download(name, version) - finaldir, control = d['final'], d['control'] - - infos = parseInfos(control) - - if 'depends' in infos: - for dep in infos['depends'].split(', '): - dep = dep.strip().split(' ')[0] - if not globallyInstalled(dep): - # print("Installing " + dep + " as a dependency") - # debian_install(dep) - - # TODO For compatibility until locinst.sh is rewritten - try: - subprocess.check_call([os.environ['HOME'] + '/.scripts/locinst.sh', 'debian', dep]) - except subprocess.CalledProcessError: - pass - - if 'recommends' in infos: - for rec in infos['recommends'].split(','): - print(name + " suggests you to install: " + rec.strip()) - - return 0 - -# TODO For compatibility until locinst.sh is rewritten -exit(debian_install(sys.argv[1])) diff --git a/scripts/locinst.sh b/scripts/locinst.sh deleted file mode 100755 index e9196b5..0000000 --- a/scripts/locinst.sh +++ /dev/null @@ -1,203 +0,0 @@ -#!/bin/bash -# Local package installer - -# Config -export LOCINST_DIR="$HOME/.locinst/" -#export LOCINST_DB="$XDG_CONFIG_HOME/locinst/" -export LOCINST_DB="$HOME/.config/locinst/" - -# Constants -LOCINST_TMP=/tmp/locinst - -# Path set -export PATH="$LOCINST_DIR/bin:$LOCINST_DIR/usr/bin:$LOCINST_DIR/usr/games/:$PATH" -export LD_LIBRARY_PATH="$LOCINST_DIR/lib:$LOCINST_DIR/usr/lib:$LD_LIBRARY_PATH" - -# Dir set -if [ ! -d "$LOCINST_DIR" ]; then - mkdir -p "$LOCINST_DIR" - # TODO Add symbolic links and stuff -fi -if [ ! -d "$LOCINST_TMP" ]; then - mkdir -p "$LOCINST_TMP" -fi -if [ ! -d "$LOCINST_DB" ]; then - mkdir -p "$LOCINST_DB" -fi - -# Misc functions -function step { # str - echo "--> $1" -} - -function error { # str - echo "ERR $1" -} - - -# Providers -# Args package_destination, package[, extra_info] -# 0: No error, must have put the uncompressed package in $package_destination -# 1: Generic error -# 4: Package not found on repo -# 5: Package already installed on system - -function locinst_arch { - - function getPageLink { # package, arch, repo - echo "https://www.archlinux.org/packages/$3/$2/$1/" - } - - function getDlLink { # package, arch, repo - echo "$(getPageLink $1 $2 $3)download/" - } - - function findPackage { # package - - function testLink { # link - wget -q --max-redirect 0 "$1" -O /dev/null - return $? - } - - function testPackage { # package, arch, repo - link="$(getPageLink $1 $2 $3)" - testLink "$link" - return $? - } - - for repo in community core extra - do - for arch in any $(uname -m) - do - testPackage $1 $arch $repo - if [ $? -eq 0 ]; then - echo "$arch:$repo" - return 0 - fi - done - done - return 1 - } - - dest="$1" - package=$2 - - step "Finding $package" - data=$(findPackage $package) - if [ $? -ne 0 ]; then - return 4 - fi - arch=$(cut -d ":" -f 1 <<< "$data") - repo=$(cut -d ":" -f 2 <<< "$data") - - step "Downloading $repo/$package-$arch" - link=$(getDlLink $package $arch $repo) - destcmp="$LOCINST_TMP/$package.tar.xz" - wget $link -O $destcmp - - step "Extracting package" - tar xf "$destcmp" -C "$dest" - - # TODO Parse .PKGINFO for dependency - # TODO Check if already on system - - rm -f $dest/.MTREE $dest/.PKGINFO - rm "$destcmp" - return 0 -} - -function locinst_pypi { - dest=$1 - shift - tar=$LOCINST_TMP/$1.tar.gz - char=`echo $1 | cut -c1-1` - wget "https://pypi.python.org/packages/source/$char/$1/$1-$2.tar.gz" -O $tar --no-check-certificate - preinst=$LOCINST_TMP/$1-$2/ - tar xf $tar -C $LOCINST_TMP - mkdir -p $dest/lib/python - export PYTHONPATH="$dest/lib/python:$PYTHONPATH" - (cd $preinst; python3 setup.py install --home=$dest) - rm -rf $tar $preinst -} - - - -# Master function - -function locinst { # action package [other_info]* - function remove { # package - package=$1 - index=$LOCINST_DB/$package - # TODO Filter common things, also delete folders - (cd $LOCINST_DIR; cat $index | while read file; do rm -f "$file"; done) - rm -f $index - } - - action=$1 - package=$2 - shift; shift - - dest=$LOCINST_TMP/$package - if [ ! -d "$dest" ]; then - mkdir -p "$dest" - fi - - case $action in - "remove") - step "Removing $package" - remove $package - return $? - ;; - "arch") - locinst_arch $dest $package $* - code=$? - ;; - "pypi") - locinst_pypi $dest $package $* - code=$? - ;; - "debian") - $HOME/.scripts/locinst.py $package $* - code=$? - ;; - *) - #error "I don't know what to do. And don't beg for help with the commands." - return 1 - ;; - esac - - # From now on something was installed - case $code in - 0) - index=$LOCINST_DB/$package - if [ -e $index ]; then - step "Removing old instance of $package" - remove $package - fi - step "Installing $package" - (cd $dest; find . -mindepth 2 >> $index) - cp -r $dest/* $LOCINST_DIR/ - rm -rf $dest - return 0 - ;; - 4) - error "Package not found!" - ;; - 5) - error "Package already installed on system!" - ;; - 6) - error "Could not satisfy version requirements!" - ;; - *) - error "Ugh... Something bad happened" - esac - - # From now on an error has happened - return $code - -} - -if [ -n $1 ]; then - locinst $@ -fi From 3eed219b61b896d27e88b2768628351315eab7d8 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Sun, 20 Nov 2016 13:34:20 +0100 Subject: [PATCH 08/11] Niiuh things --- config/i3/config | 6 +++--- scripts/debloc.sh | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/config/i3/config b/config/i3/config index 31d89a2..bf37494 100644 --- a/config/i3/config +++ b/config/i3/config @@ -281,9 +281,9 @@ mode "Resize" { # Pressing right will grow the window’s width. # Pressing up will shrink the window’s height. # Pressing down will grow the window’s height. - bindsym j resize shrink width 10 px or 10 ppt - bindsym k resize grow height 10 px or 10 ppt - bindsym i resize shrink height 10 px or 10 ppt + bindsym h resize shrink width 10 px or 10 ppt + bindsym j resize grow height 10 px or 10 ppt + bindsym k resize shrink height 10 px or 10 ppt bindsym l resize grow width 10 px or 10 ppt ## same bindings, but for the arrow keys diff --git a/scripts/debloc.sh b/scripts/debloc.sh index b359f8e..ff75db8 100755 --- a/scripts/debloc.sh +++ b/scripts/debloc.sh @@ -5,7 +5,6 @@ DEBLOC_ROOT=$HOME/.debloc # TODO Configurable DEBIAN_MIRROR=http://debian.polytech-lille.fr/debian -DEBIAN_MIRROR=http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu mkdir -p $DEBLOC_DB &> /dev/null mkdir -p $DEBLOC_ROOT &> /dev/null From 7543597b6ba7c59e181aa4fc550576e1f013b01e Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Sun, 20 Nov 2016 14:32:31 +0100 Subject: [PATCH 09/11] Debloc: Support multi-arch Incredibly easy since this wasn't poorly designed :) --- scripts/debloc.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/debloc.sh b/scripts/debloc.sh index ff75db8..c371836 100755 --- a/scripts/debloc.sh +++ b/scripts/debloc.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -DEBLOC_DB=$HOME/.config/debloc -DEBLOC_ROOT=$HOME/.debloc +ARCH=$(dpkg --print-architecture) +DEBLOC_DB=$HOME/.config/debloc/$ARCH +DEBLOC_ROOT=$HOME/.debloc/$ARCH # TODO Configurable DEBIAN_MIRROR=http://debian.polytech-lille.fr/debian From c8e0d9bfe29c728718de5e2c3770b8bbeece508b Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Sun, 20 Nov 2016 14:33:54 +0100 Subject: [PATCH 10/11] My programs. MIIINE! --- scripts/debloc-custom.sh | 30 ++++++++++++++++++++++++++++++ scripts/index.sh | 1 + 2 files changed, 31 insertions(+) create mode 100755 scripts/debloc-custom.sh mode change 100644 => 100755 scripts/index.sh diff --git a/scripts/debloc-custom.sh b/scripts/debloc-custom.sh new file mode 100755 index 0000000..58073a6 --- /dev/null +++ b/scripts/debloc-custom.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +# Installs all programs on the system + +function debloc-custom-cli { + # Utils + debloc-install moreutils screen ncdu htop sl proxytunnel pass + + # Text editor + debloc-install vim exuberant-ctags + + # Dev + debloc-install build-essential cmake clang +} + +function debloc-custom { + debloc-custom-cli + + # Desktop manager + debloc-install i3 dmenu dunst unclutter xautolock feh numlockx scrot + + # qutebrowser + debloc-install python3-lxml python-tox python3-pyqt5 python3-pyqt5.qtwebkit python3-sip python3-jinja2 python3-pygments python3-yaml + TMP_DIR=$(mktemp -d) + $(cd $TMP_DIR; wget --quiet https://qutebrowser.org/python3-pypeg2_2.15.2-1_all.deb) + $(cd $TMP_DIR; wget --quiet https://github.com/The-Compiler/qutebrowser/releases/download/v0.8.4/qutebrowser_0.8.4-1_all.deb) + debloc-deb $TMP_DIR/*.deb + rm -rf $TMP_DIR +} + diff --git a/scripts/index.sh b/scripts/index.sh old mode 100644 new mode 100755 index 87b928b..d06c95a --- a/scripts/index.sh +++ b/scripts/index.sh @@ -1,3 +1,4 @@ source ~/.scripts/proxy.sh source ~/.scripts/debloc.sh +source ~/.scripts/debloc-custom.sh alias beep=~/.scripts/beep.sh From 34ae3383688b0156ee31f21a8f50e5c2b369c369 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Sun, 20 Nov 2016 14:38:40 +0100 Subject: [PATCH 11/11] Well, git uses it own path, great I'm sure there will be TONS of those --- scripts/debloc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/debloc.sh b/scripts/debloc.sh index c371836..05bcbf2 100755 --- a/scripts/debloc.sh +++ b/scripts/debloc.sh @@ -10,7 +10,7 @@ DEBIAN_MIRROR=http://debian.polytech-lille.fr/debian mkdir -p $DEBLOC_DB &> /dev/null mkdir -p $DEBLOC_ROOT &> /dev/null -export PATH="$DEBLOC_ROOT/usr/bin:$DEBLOC_ROOT/usr/games/:$PATH" +export PATH="$DEBLOC_ROOT/usr/bin:$DEBLOC_ROOT/usr/games/:$DEBLOC_ROOT/usr/lib/git-core:$PATH" export LD_LIBRARY_PATH="$DEBLOC_ROOT/lib:$LD_LIBRARY_PATH" export PYTHONPATH="$DEBLOC_ROOT/usr/lib/python3:$PYTHONPATH" export QT_QPA_PLATFORM_PLUGIN_PATH="$DEBLOC_ROOT/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms"