]> git.sev.monster Git - dotfiles.git/commitdiff
add required/useful scripts, install.sh support
authords6 <git@ds6.pw>
Tue, 16 Jan 2018 05:23:29 +0000 (23:23 -0600)
committersev <git@sev.monster>
Fri, 5 Apr 2024 20:44:51 +0000 (15:44 -0500)
13 files changed:
base/.xinitrc
bin/dmenu [new file with mode: 0755]
bin/dmenu_runsmart [new file with mode: 0755]
bin/dpass [new file with mode: 0755]
bin/i3subscribe [new file with mode: 0755]
bin/redoff [new file with mode: 0755]
bin/redon [new file with mode: 0755]
bin/rotate [new file with mode: 0755]
bin/tint2-i3mode [new file with mode: 0755]
bin/tint2-i3status [new file with mode: 0755]
bin/tint2-wifi [new file with mode: 0755]
bin/xmixer [new file with mode: 0755]
install.sh

index 3b41f3dec73344cb2de6f150b0e7f4b26909613d..bf14d4ff0022a95a49e8bf82bd9aabf0f99b182d 100755 (executable)
@@ -64,6 +64,7 @@ fi
 
 # try to wait for session to start
 (sleep 0.1 && tint2) &
+#x220t
 (sleep 0.1 && [ -x "$HOME/bin/acpi_ac" ] && \
        "$HOME/bin/acpi_ac" "0x0`sysctl -n hw.acpi.acline`") &
 (sleep 1.5 && [ -x /usr/local/bin/conky ] && conky -c "$HOME/.conkyrc.d/dock") &
diff --git a/bin/dmenu b/bin/dmenu
new file mode 100755 (executable)
index 0000000..81f61e4
--- /dev/null
+++ b/bin/dmenu
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec /usr/local/bin/dmenu -fn 'Dina-10' -nb \#110800 -nf \#93a1a1 -sb \#aa5500 -sf \#eee8d5 "$@"
diff --git a/bin/dmenu_runsmart b/bin/dmenu_runsmart
new file mode 100755 (executable)
index 0000000..71cb8ad
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+cmd=$(dmenu_path | ~/bin/dmenu "$@")
+if [ -n "$cmd" ]; then
+       # zsh SH_WORD_SPLIT is unset by default, `=' flag is required to expand
+       echo "alias sudo='sudo -Ak'
+cmd='$(echo "$cmd" | sed "s/'/'\\\\''/g")'" '
+if [ -n "$ZSH_VERSION" ]; then
+       out="$(${=cmd} 2>&1)"
+else
+       out="$($cmd 2>&1)"
+fi
+code=$?
+out="$(echo "$out" | tail -n 3)"
+notify-send -t 10000 -u $([ $code != 0 ] && echo normal || echo low) -a ' "'$(basename $0)'" ' "${cmd}$([ $code != 0 ] && echo \: $code)" "$out"' | SUDO_ASKPASS=~/bin/dpass ${SHELL:-"/bin/sh"}
+fi
diff --git a/bin/dpass b/bin/dpass
new file mode 100755 (executable)
index 0000000..a7dddb8
--- /dev/null
+++ b/bin/dpass
@@ -0,0 +1,6 @@
+#!/bin/sh
+p="$1"
+if [ -z "$p" ]; then
+       p="[$(ps -o comm= -p $(ps -o ppid= -p $$))]";
+fi
+~/bin/dmenu -p "$p" -fn Dina-10 -nb \#110800 -nf \#110800 -sb \#264bd2 -sf \#fdf6e3 <&-
diff --git a/bin/i3subscribe b/bin/i3subscribe
new file mode 100755 (executable)
index 0000000..166cd3f
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+
+BEGIN { $| = 1 } # flush \n
+
+use strict;
+use warnings;
+use Data::Dumper;
+use AnyEvent::I3;
+use v5.10;
+
+my $i3 = i3();
+$i3->connect->recv or die "Error connecting to i3";
+
+sub subscribe {
+    my $ev = $_[0];
+    my $dump = $_[1];
+    if($i3->subscribe({
+        $ev => sub {
+            my ($msg) = @_;
+            say "$ev:$msg->{'change'}";
+            if($dump) {
+                print Dumper($msg);
+            }
+        }
+    })->recv->{success}) {
+        say "Successfully subscribed to $ev-event";
+    }
+}
+
+my $nextArg = shift;
+if(!$nextArg) {
+    say "Subscribe to i3-events";
+    say "Usage:   $0 workspace|output|mode|window|barconfig_update|binding [dump]";
+    say "Example: $0 workspace dump window binding dump";
+    exit 1;
+}
+while($nextArg) {
+    my $arg = $nextArg;
+    $nextArg = shift;
+    my $dump = 0;
+    if($nextArg and $nextArg eq "dump") {
+        $dump = 1;
+        $nextArg = shift;
+    }
+    subscribe("$arg", $dump);
+}
+AE::cv->recv;
+
+# vim: et:ts=4:sts=4
diff --git a/bin/redoff b/bin/redoff
new file mode 100755 (executable)
index 0000000..25c0f37
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+killall redshift > /dev/null 2>&1
+redshift -m randr -x
diff --git a/bin/redon b/bin/redon
new file mode 100755 (executable)
index 0000000..055e2c7
--- /dev/null
+++ b/bin/redon
@@ -0,0 +1,3 @@
+#!/bin/sh
+killall redshift > /dev/null 2>&1
+redshift -l manual:lat=38.95171:lon=-92.33407 -m randr -t 6600:4000 -r &
diff --git a/bin/rotate b/bin/rotate
new file mode 100755 (executable)
index 0000000..2e6e4aa
--- /dev/null
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+default_output=LVDS1
+
+usage() {
+       echo "Usage:
+       rotate (left|right|invert) [output]
+       rotate set (normal|right|inverted|left) [output]
+Examples:
+       rotate left LVDS1
+       rotate set right HDMI2
+
+Only the first letter of each command is checked (case-insensitive), so they
+can be abbreviated or even cut to one letter each in lower or upper case.
+
+For example, the following commands do the same thing:
+       rotate set left
+       rotate SET LeFt
+       rotate s l
+       rotate salad lasagna"
+}
+
+rot_to_num() {
+       case $1 in
+               # normal right invert left
+               # convert to numbers to allow math to rotate
+               [nN]*) rot0=0;;
+               [rR]*) rot0=1;;
+               [iI]*) rot0=2;;
+               [lL]*) rot0=3;;
+               *)     usage; exit 2;;
+       esac
+}
+num_to_rot() {
+       case $1 in
+               # maps to rot_to_num output
+               0) rot1=normal
+                  rot2=none;;
+               1) rot1=right
+                  rot2=cw;;
+               2) rot1=inverted
+                  rot2=half;;
+               3) rot1=left
+                  rot2=ccw;;
+       esac
+}
+
+case $1 in
+       [sS]*)
+               # set: rotate set (normal|right|inverted|left) [output]
+               output=${3:-$default_output}
+               rot_to_num $2
+               ;;
+       *)
+               # rotate (left|right|invert) [output]
+               output=${2:-$default_output}
+               rot_to_num `xrandr --query --verbose | grep $output | awk '{print $5}'`
+               case $1 in
+                       [lL]*) rot0=$(($rot0 - 1));;
+                       [rR]*) rot0=$(($rot0 + 1));;
+                       [iI]*) rot0=$(($rot0 + 2));;
+                       *)    usage; exit 1;;
+               esac
+               ;;
+esac
+
+# add 4 modulo 4 to prevent negatives and overflows
+num_to_rot $((($rot0 + 4) % 4))
+
+xrandr --output $output --rotation $rot1
+# x220t
+if [ -x /usr/local/bin/xsetwacom ]; then
+       xsetwacom --set stylus Rotate $rot2
+       xsetwacom --set eraser Rotate $rot2
+       xsetwacom --set touch  Rotate $rot2
+fi
+
+# reload bg
+~/.fehbg
diff --git a/bin/tint2-i3mode b/bin/tint2-i3mode
new file mode 100755 (executable)
index 0000000..2fc24e0
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+first=true
+i3subscribe mode | while read -r x; do
+       if $first; then
+               first=false
+               continue
+       fi
+       x=${x#mode:}
+       case $x in
+               default) echo;;
+               *) echo $x;;
+       esac
+done
diff --git a/bin/tint2-i3status b/bin/tint2-i3status
new file mode 100755 (executable)
index 0000000..3d53d4d
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+i3status -c ${XDG_CONFIG_HOME:-~/.config}/i3status/tint2-$1 | sed -ue 's/fc=\(#[a-f0-9]\{3,6\}\)/span color="\1"/gi;s_/fc_/span_g'
diff --git a/bin/tint2-wifi b/bin/tint2-wifi
new file mode 100755 (executable)
index 0000000..b59f04a
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+base=~/.icons/Paper/24x24/panel/network
+excellent=$base-wireless-signal-excellent.svg
+     good=$base-wireless-signal-good.svg
+       ok=$base-wireless-signal-ok.svg
+      low=$base-wireless-signal-low.svg
+     none=$base-wireless-signal-none.svg
+  offline=$base-wireless-offline.svg
+while true; do
+       sleep 3
+       x=$(ifconfig wlan0 list sta)
+       if [ $? != 0 ]; then
+               echo $offline
+               continue
+       fi
+       x=$(echo "$x" | awk 'NR == 1 {next} {printf "%.0f", $5}')
+       if [ $x -ge 20 ]; then
+               echo $excellent
+       elif [ $x -ge 15 ]; then
+               echo $good
+       elif [ $x -ge 10 ]; then
+               echo $ok
+       elif [ $x -ge 5 ]; then
+               echo $low
+       else
+               echo $none
+       fi
+done
diff --git a/bin/xmixer b/bin/xmixer
new file mode 100755 (executable)
index 0000000..ec4207b
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+(sleep 0.1; xdotool search --class --sync XMixer \
+  windowmove $(xdotool getmouselocation|awk 'BEGIN{FS=" |:"}{print $2" "$4}'))&
+xmixer
index e7a959be15befaa0cf0f7cbada6d9cdab6c1cc70..713e7026a0f5d83106393c57bf85531dc2a8d853 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-#fix permissions from git (should probably move this to git hook)
+#fix permissions from git (TODO: should probably move this to git hook)
 chmod go= base/.zshenv base/.Xresources
 
 if [ 0 -eq 1 ]; then
@@ -12,12 +12,17 @@ if [ 0 -eq 1 ]; then
 fi
 
 l() {
+       # TODO: use install?
        [ -L "$1" -o \! -e "$1" ] && ln -sFhvw "$x" "$1"
 }
 
 find "$PWD/base" -depth 1 | while read -r x; do
        l "$HOME/`basename "$x"`"
 done
+mkdir "$HOME/bin"
+find "$PWD/bin" -depth 1 | while read -r x; do
+       l "$HOME/bin/`basename "$x"`"
+done
 find "$PWD/xdg" -depth 1 | while read -r x; do
        l "${XDG_CONFIG_HOME:-$HOME/.config}/`basename "$x"`"
 done
This page took 0.051442 seconds and 4 git commands to generate.