aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2021-01-11 21:52:49 +0530
committerAkshay Nair <phenax5@gmail.com>2021-01-11 21:52:49 +0530
commit0a4dc975e0a02bda8bebbf14dd9cc516b2819fcc (patch)
tree26e087bc89c9a6b2d567dd59acf885393470d35f
parent9c6ca8f41864fc1e0bf367dd4324e38d22aece98 (diff)
downloadnixos-config-0a4dc975e0a02bda8bebbf14dd9cc516b2819fcc.tar.gz
nixos-config-0a4dc975e0a02bda8bebbf14dd9cc516b2819fcc.zip
Updates scripts
Diffstat (limited to '')
-rwxr-xr-xscripts/bin/with_zsh2
-rwxr-xr-xscripts/brightness.sh55
-rwxr-xr-xscripts/commands/:codi2
-rwxr-xr-xscripts/commands/:notes2
-rwxr-xr-xscripts/commands/:tasks2
-rwxr-xr-xscripts/commands/:today2
-rwxr-xr-xscripts/menuitems.sh6
-rwxr-xr-xscripts/screenshot.sh4
-rwxr-xr-xscripts/sessions/project.sh15
9 files changed, 63 insertions, 27 deletions
diff --git a/scripts/bin/with_zsh b/scripts/bin/with_zsh
index 0da2d95..5dbdc7d 100755
--- a/scripts/bin/with_zsh
+++ b/scripts/bin/with_zsh
@@ -1,4 +1,4 @@
#!/bin/sh
-zsh -c "source ~/.zshrc && $@";
+zsh -c "source ~/nixos/config/zsh/zshrc && $@";
diff --git a/scripts/brightness.sh b/scripts/brightness.sh
index 71432d6..b3051a1 100755
--- a/scripts/brightness.sh
+++ b/scripts/brightness.sh
@@ -1,22 +1,49 @@
-#!/bin/bash
+#!/usr/bin/env bash
-read_brightness() { xbacklight -get; }
+max() { [[ "$1" -gt "$2" ]] && echo "$1" || echo "$2"; }
+min() { [[ "$1" -lt "$2" ]] && echo "$1" || echo "$2"; }
+between() { max "$2" $(min "$1" "$3"); }
-get_brightness() { printf "%.0f%s" "$(read_brightness)" "%"; }
+adapter_bctl() {
+ set_() { brightnessctl set "$@"; }
+ get() { brightnessctl get; }
+ max_b() { brightnessctl m; }
+ update() {
+ local curr=`brightnessctl get`;
+ local min=100;
+ local max=`max_b`;
+ set_ $(between $(echo "$curr $1" | bc) $min $max);
+ }
-set_brightness() { xbacklight -set $1; }
+ local delta="1000";
+ case "$1" in
+ get) echo "100 * `get` / `max_b`" | bc ;;
+ set) set_ $(echo "$2 * `max_b` / 100" | bc) ;;
+ inc) update "+ $delta" ;;
+ dec) update "- $delta" ;;
+ *) echo "invalid command" ;;
+ esac;
+}
-increment() { xbacklight -inc $1; }
-decrement() { xbacklight -dec $1; }
+adapter_xbacklight() {
+ read_brightness() { xbacklight -get; }
-case $1 in
- get) get_brightness ;;
- set) set_brightness $2 ;;
- inc) increment $2 ;;
- dec) decrement $2 ;;
- *) echo "For tools to work, you need to know how to use them" ;;
-esac
+ get_brightness() { printf "%.0f%s" "$(read_brightness)" "%"; }
-#~/scripts/statusbar/statusbar.sh update brightness;
+ set_brightness() { xbacklight -set $1; }
+
+ increment() { xbacklight -inc $1; }
+ decrement() { xbacklight -dec $1; }
+
+ case $1 in
+ get) get_brightness ;;
+ set) set_brightness $2 ;;
+ inc) increment $2 ;;
+ dec) decrement $2 ;;
+ *) echo "For tools to work, you need to know how to use them" ;;
+ esac
+}
+
+adapter_bctl "$@";
update-dwmblock brightness;
diff --git a/scripts/commands/:codi b/scripts/commands/:codi
index 09fb11b..cb4ec8d 100755
--- a/scripts/commands/:codi
+++ b/scripts/commands/:codi
@@ -3,7 +3,7 @@
filetype=${1:-javascript}
tmpfile=$(mktemp /tmp/interpreter.XXXXXXX)
-sensible-terminal -e sh -c "~/.bin/with_zsh 'codi $filetype $tmpfile'";
+sensible-terminal -e sh -c "~/scripts/bin/with_zsh 'codi $filetype $tmpfile'";
rm $tmpfile;
diff --git a/scripts/commands/:notes b/scripts/commands/:notes
index cf5a8cc..2406947 100755
--- a/scripts/commands/:notes
+++ b/scripts/commands/:notes
@@ -1,3 +1,3 @@
#!/usr/bin/env sh
-sensible-terminal -e sensible-editor ~/.config/vimwiki/index.md;
+sensible-terminal -e sensible-editor ~/nixos/extras/notes/index.md;
diff --git a/scripts/commands/:tasks b/scripts/commands/:tasks
index d020ddf..93b59ec 100755
--- a/scripts/commands/:tasks
+++ b/scripts/commands/:tasks
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
-sensible-terminal -e sensible-editor ~/.config/vimwiki/Work.md;
+sensible-terminal -e sensible-editor ~/nixos/extras/notes/Work.md;
diff --git a/scripts/commands/:today b/scripts/commands/:today
index ec7b295..4f695e5 100755
--- a/scripts/commands/:today
+++ b/scripts/commands/:today
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
-sensible-terminal -e sensible-editor ~/.config/vimwiki/Today.md;
+sensible-terminal -e sensible-editor ~/nixos/extras/notes/Today.md;
diff --git a/scripts/menuitems.sh b/scripts/menuitems.sh
index 92e24d4..4cdb086 100755
--- a/scripts/menuitems.sh
+++ b/scripts/menuitems.sh
@@ -38,12 +38,12 @@ icon() {
}
date_module() {
- echo "$(icon date) $(date +"%A, %e %b - %I:%M %p")";
+ echo "$(icon date) $(date +"%A, %e %b - %I:%M %p")";
}
battery_module() {
local capacity=$(cat "/sys/class/power_supply/BAT0/capacity");
- echo "$(icon battery) $capacity%";
+ echo "$(icon battery) $capacity%";
}
music_module() {
@@ -52,7 +52,7 @@ music_module() {
}
brightness_module() {
- echo "$(icon brightness) $(printf "%.0f%s" "$(xbacklight -get)" "%")"
+ echo "$(icon brightness) $(printf "%.0f%s" "$(xbacklight -get)" "%")"
}
volume_module() {
diff --git a/scripts/screenshot.sh b/scripts/screenshot.sh
index 59770dd..4ae4e4f 100755
--- a/scripts/screenshot.sh
+++ b/scripts/screenshot.sh
@@ -6,8 +6,8 @@ notify() { notify-send "$@"; }
scrsht() {
local type=$1;
- local window=$([ -z "$2" ] && echo "" || echo "-window $2");
- magick import $window "$SCREENSHOTS/$type-$(date '+%Y_%m_%d_%H_%M_%S').jpg";
+ local window=$([ -z "$2" ] && echo "" || echo $([[ "$2" == root ]] && "-screen" || "-window $2"));
+ import $window "$SCREENSHOTS/$type-$(date '+%Y_%m_%d_%H_%M_%S').jpg";
notify "Screenshot ($type) captured";
}
diff --git a/scripts/sessions/project.sh b/scripts/sessions/project.sh
index ffe9cc9..f642a9e 100755
--- a/scripts/sessions/project.sh
+++ b/scripts/sessions/project.sh
@@ -2,10 +2,19 @@
dir="$1";
-sensible-terminal -d "$dir" -e sensible-editor . &
+editor="sensible-editor";
+
+if [[ -f "$dir/default.nix" ]]; then
+ editor="nix-shell --run '$editor'";
+fi;
+
+term() { sensible-terminal -d "$dir" "$@"; }
+editor() { term -e sh -c "echo 'Loading...'; $editor"; }
+
+editor &
sleep 0.1;
-sensible-terminal -d "$dir" &
-sensible-terminal -d "$dir" &
+term &
+term &
disown;