scripts

scripts to make my pc work
Index Commits Files Refs
commit bccc6c771cb434f3d861329aa1db2dc659217837
parent 3cbd9827fe2f993de261a20b078a66e461bff3b5
Author: klewer-martin <martin.cachari@gmail.com>
Date:   Sat, 26 Jun 2021 01:14:27 -0300

Updated scripts folder

Diffstat:
Abrightness.c | 27+++++++++++++++++++++++++++
Acount.c | 11+++++++++++
Acount.py | 7+++++++
Acount.sh | 4++++
Adbdb.sh | 18++++++++++++++++++
Aimagestodownload.txt | 3+++
Aimg.jpg | 0
Aip.sh | 14++++++++++++++
Mlockscreen | 4+++-
Anasa_img_downloader | 5+++++
Mopenbook | 4++--
Aopendir | 11+++++++++++
Msetlockscreenbg | 9++-------
Mstatusbar/sb-clock | 2+-
Mstatusbar/sb-memory | 2+-
Mstatusbar/sb-price | 6+++---
Mtakescreenshot | 2+-
17 files changed, 113 insertions(+), 16 deletions(-)
diff --git a/brightness.c b/brightness.c
@@ -0,0 +1,27 @@
+#include <stdlib.h>
+#include <stdio.h>
+#define BUFSIZE 10
+
+int main(int argc, char **argv)
+{
+    FILE *fp;
+    char scurr[BUFSIZE];
+    long new, curr, incr, min = 0;
+
+    /* An argument with an integer increment must be supplied */
+    if (argc != 2 || !(incr = strtol(argv[1], NULL, 10))) return 1;
+
+    /* Retrieve the current brightness and increment it in the brightness file */
+    if ((fp = fopen("/sys/class/backlight/intel_backlight/brightness", "r+")) 
+        && fgets(scurr, BUFSIZE, fp)) {
+        curr = strtol(scurr, NULL, 10);
+        rewind(fp);
+        new = curr + incr;
+        if (new < min) new = min;
+        fprintf(fp, "%ld\n", new);
+        fclose(fp);
+    } else return 2;
+
+    return 0;
+}
+
diff --git a/count.c b/count.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+int main (void)
+{
+    unsigned long x;
+
+    for(x = 0; x < 1000000; x++)
+        printf("%ld\n", x);
+
+    return 0;
+}
diff --git a/count.py b/count.py
@@ -0,0 +1,7 @@
+#!/usr/bin/python
+
+x = 0
+
+while x < 1000000:
+    print(x)
+    x = x + 1
diff --git a/count.sh b/count.sh
@@ -0,0 +1,4 @@
+#/usr/bin/sh
+
+x=0
+while [ "$x" -lt 500000 ]; do echo $x; x=$((x+1));done
diff --git a/dbdb.sh b/dbdb.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+# dmenu-based directory browser
+# to run from terminal:
+#    source /path/to/dbdb.sh
+# or bind it to shortcut:
+#   echo bind \'\"\\C-o\":\"source /path/to/dbdb.sh\\n\"\' >> ~/.bashrc
+
+chosen="placeholder"
+
+while [ ! -z "$chosen" ]; do
+    DIRs=$( ls -a1p | grep -P '^\w[^\$/]+/$' | awk -vRS="\n" -vORS="\t" '1')
+    DOTDs=$( ls -a1p | grep -P '^\.[^\$/]+/$' | awk -vRS="\n" -vORS="\t" '1')
+    FILEs=$( ls -a1p | grep -P '^\w[^\$/]+$' | awk -vRS="\n" -vORS=" \t" '1')
+    DOTFs=$( ls -a1p | grep -P '^\.[^\$/]+$' | awk -vRS="\n" -vORS=" \t" '1')
+    clear && printf "\e[1;7;33m $(pwd) \e[0m\n$FILEs\n\e[0;38;5;238m$DOTFs\e[0m\n"
+    chosen=`( ( echo -e "$DIRs$DOTDs" | awk -vRS="\t" -vORS="\n" '1' ) | dmenu -i -l 10)`
+    cd "$chosen"
+done
diff --git a/imagestodownload.txt b/imagestodownload.txt
@@ -0,0 +1,3 @@
+https://www.nasa.gov/sites/default/files/thumbnails/image/iss065e002848.jpg
+https://www.nasa.gov/sites/default/files/thumbnails/image/iss065e005888.jpg
+https://www.nasa.gov/sites/default/files/thumbnails/image/iss065e005888.jpg
diff --git a/img.jpg b/img.jpg
Binary files differ.
diff --git a/ip.sh b/ip.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Prints your local ip address, if you are connected both via wireless & ethernet then the ethernet ip is printed
+
+# by github.com/klewer-martin
+
+estatus="$(cat /sys/class/net/e*/operstate)"
+
+if [ "$estatus" = "down" ]; 
+    then ip=$(ip -o a | awk '/: w.*.inet .*/ { print $4 }' | sed 's/\// /' | awk '{ print $1 }');
+    else ip=$(ip -o a | awk '/: e.*.inet .*/ { print $4 }' | sed 's/\// /' | awk '{ print $1 }');
+fi;
+
+echo $ip
diff --git a/lockscreen b/lockscreen
@@ -2,4 +2,6 @@
 
 #i3lock --color=000000
 
-betterlockscreen -l dim
+i3lock -c 00000000 -n --wrongtext="" --veriftext="" --veriftext="" --noinputtext="" -i $HOME/.cache/i3lock/current/dimblur.png --ringcolor=8B008B --keyhlcolor=ff00ff --verifcolor=0000FF --indicator
+
+# betterlockscreen -l dim
diff --git a/nasa_img_downloader b/nasa_img_downloader
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+[ -z "$1" ] && exit 1
+
+while read line; do url="$line"; imgname=$(echo "$url" | cut -d "/" -f 12); curl -# $url > $imgname; echo "\nDownloading: $imgname"; done < $1
diff --git a/openbook b/openbook
@@ -11,9 +11,9 @@ dmenucmds="-i -l 10 -h 14 -z 750 -bw 2 -c $@"
 
 bookname=$(ls $dir | dmenu $dmenucmds)
 
-[ "$bookname" = "" ] && exit
+[ -z "$bookname" ] && exit
 
 [ $(file "$dir/$bookname" | cut -d ":" -f 2) = "directory" ] &&
     dir=$dir/$bookname && bookname=$(ls "$dir" | dmenu $dmenucmds)
 
-[ "$bookname" != "" ] && $pdfviewer "$dir/$bookname"
+[ -n "$bookname" ] && $pdfviewer "$dir/$bookname"
diff --git a/opendir b/opendir
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Prints a list of books in dmenu and opens the chosen one with pdfviewer
+# The arguments receive are redirected to dmenu
+
+# by github.com/klewer-martin
+
+dmenucmds="-i -l 10 -h 14 -z 750 -bw 2 -c $@"
+dirname=$(fd -a | dmenu $dmenucmds)
+
+alacritty --working-directory "$dirname"
diff --git a/setlockscreenbg b/setlockscreenbg
@@ -1,8 +1,3 @@
-#!/bin/bash
+#!/bin/sh
 
-BACKGROUND_PATH=$(cat $HOME/.config/nitrogen/bg-saved.cfg \
-                    | grep file | cut -c6-)
-
-echo $BACKGROUND_PATH
-
-betterlockscreen -u $BACKGROUND_PATH
+betterlockscreen -u $(grep file $HOME/.config/nitrogen/bg-saved.cfg | cut -c6-)
diff --git a/statusbar/sb-clock b/statusbar/sb-clock
@@ -27,4 +27,4 @@ esac
 #esac
 
 #date "+ %a %b %d %Y $icon: %I:%M%p"
-date "+📅 %a %d/%m/%Y | $icon %R "
+date "+📅 %a %d/%m/%Y | $icon %R"
diff --git a/statusbar/sb-memory b/statusbar/sb-memory
@@ -9,4 +9,4 @@
 #    6) "$TERMINAL" -e "$EDITOR" "$0" ;;
 #esac
 
-free --mebi | sed -n '2{p;q}' | awk '{printf (" 🧠 %2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}'
+free --mebi | sed -n '2{p;q}' | awk '{printf (" 🧠 %2.2fG\n", ( $3 / 1024), ($2 / 1024))}'
diff --git a/statusbar/sb-price b/statusbar/sb-price
@@ -9,7 +9,7 @@
 interval="@14d"    # History contained in chart preceded by '@' (7d = 7 days)
 dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices"
 pricefile="$dir/$1"
-chartfile="$dir/$1-chart"
+# chartfile="$dir/$1-chart"
 
 # curl -s "rate.sx/1$1" > "$pricefile"
 
@@ -25,7 +25,7 @@ updateprice() { ping -q -c 1 example.org >/dev/null 2>&1 &&
 #[ "$(stat -c %x "$pricefile" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
 #    updateprice "$1"
 
-updateprice "$1"
+updateprice "$1" &
 
 # case $BLOCK_BUTTON in
 #     1) setsid "$TERMINAL" -e less -Srf "$chartfile" ;;
@@ -42,4 +42,4 @@ updateprice "$1"
 #     6) "$TERMINAL" -e "$EDITOR" "$0" ;;
 # esac
 
-printf "$3$%0.3f" "$(cat "$pricefile")"
+printf "$3$%0.2f" "$(cat "$pricefile")"
diff --git a/takescreenshot b/takescreenshot
@@ -2,4 +2,4 @@
 
 # Takes a screenshot of the screen and saves it on the folder below
 
-scrot -e 'mv $f ~/pictures/screenshots/'
+scrot -z -e 'mv $f ~/pictures/screenshots/'