added wrapper around yadm, changed to /usr/bin/env fish

This commit is contained in:
Phuntsok Drak-pa 2019-10-23 14:51:34 +02:00
parent 317eca7eb1
commit e05888f731
10 changed files with 120 additions and 60 deletions

View File

@ -50,7 +50,6 @@ bindsym $alt+F4 kill
# program launcher
bindsym $mod+Shift+d exec --no-startup-id j4-dmenu-desktop
bindsym $mod+d exec --no-startup-id $rofiexec
bindsym $mod+w exec --no-startup-id rofi-wifi-menu
# change focus
bindsym $mod+$left focus left
@ -126,9 +125,9 @@ workspace 10 output eDP-1
{% endif -%}
# reload the configuration file
bindsym $mod+Shift+c reload
bindsym $mod+Shift+c exec yadm alt && i3-msg reload
# restart i3 inplace
bindsym $mod+Shift+r restart
bindsym $mod+Shift+r exec yadm alt && i3-msg restart
# exit i3
bindsym $mod+Shift+e exec $exiti3
@ -185,7 +184,7 @@ bindsym $mod+$alt+c exec speedcrunch
bindsym $mod+F3 exec arandr
bindsym $mod+Shift+l exec dmenu-lpass
bindsym $mod+Shift+p exec ~/.config/polybar/launch.sh
bindsym $mod+Shift+p exec polybar-launch
# Brightness keyboard shortcuts
bindsym XF86MonBrightnessUp exec "light -A 5"
@ -215,6 +214,7 @@ bindsym $mod+Shift+h exec $term htop
bindsym $mod+Ctrl+m exec rofi-mount
bindsym $mod+Ctrl+u exec rofi-dumount
bindsym $mod+$alt+e exec rofi-emoji
bindsym $mod+w exec wacom-setup
# Music shortcuts
bindsym $alt+XF86AudioRaiseVolume exec mpc next
@ -267,7 +267,7 @@ exec --no-startup-id compton -F --opengl --config ~/.config/compton
exec --no-startup-id /usr/lib/mate-polkit/polkit-mate-authentication-agent-1
{% endif -%}
exec_always --no-startup-id enable_touch
exec_always --no-startup-id ~/.config/polybar/launch.sh
exec_always --no-startup-id polybar-launch
exec --no-startup-id xss-lock -- i3lock -fol
exec --no-startup-id xfce4-power-manager
exec --no-startup-id clight

View File

@ -46,7 +46,8 @@
- [[#askpass][Askpass]]
- [[#dmenu][Dmenu]]
- [[#emoji-picker][Emoji picker]]
- [[#rofimount][Rofimount]]
- [[#polybar-launch][Polybar-launch]]
- [[#rofi-mount][Rofi-mount]]
- [[#get-the-mountable-elements][Get the mountable elements]]
- [[#get-the-drive-to-mount][Get the drive to mount]]
- [[#mount-a-usb-drive-hard-drive-or-partition][Mount a USB drive, hard drive or partition]]
@ -54,7 +55,7 @@
- [[#mount-a-cd-drive][Mount a CD drive]]
- [[#ask-what-type-of-drive-we-want-to-mount][Ask what type of drive we want to mount]]
- [[#launch-the-mounting-functions][Launch the mounting functions]]
- [[#rofiumount][Rofiumount]]
- [[#rofi-umount][Rofi-umount]]
- [[#get-the-unmountable-drives][Get the unmountable drives]]
- [[#unmount-disk-partitions][Unmount disk partitions]]
- [[#unmount-android-device][Unmount Android device]]
@ -67,6 +68,7 @@
- [[#select-our-screen][Select our screen]]
- [[#adjust-the-tablet][Adjust the tablet]]
- [[#lauch-the-functions][Lauch the functions]]
- [[#yadm][Yadm]]
* Presentation
:PROPERTIES:
@ -94,7 +96,7 @@
and with [[https://wiki.archlinux.org/index.php/Rofi][rofi]] support instead of [[https://wiki.archlinux.org/index.php/Dmenu][dmenu]]. As you can see, this is a oneliner if
we ignore the initial shebang. This executable is pointed at by the
#+BEGIN_SRC fish :exports code
#!/usr/bin/fish
#!/usr/bin/env fish
rofi -dmenu -font 'DejaVu Sans 10' -password -no-fixed-num-lines \
-p (printf $argv[1] | sed s/://)
#+END_SRC
@ -108,8 +110,8 @@
emulation of dmenu, since I prefer rofis appearance. It basically calls
rofis dmenu emulation with the arguments initially passed to dmenu.
#+BEGIN_SRC fish
#!/usr/bin/fish
/usr/bin/rofi -dmenu $argv
#!/usr/bin/env fish
rofi -dmenu $argv
#+END_SRC
* Emoji picker
@ -121,7 +123,7 @@
[[file:~/.config/emoji.txt][~/.config/emoji.txt]] to provide a small, local search for emojis. Once the
emoji is selected, it is copied to the clipboard using =xclipboard=.
#+BEGIN_SRC fish
#!/usr/bin/fish
#!/usr/bin/env fish
grep -v "#" ~/.config/emoji.txt | rofi -dmenu -i | awk '{print $1}' | tr -d '\n' | xclip -selection clipboard
#+END_SRC
@ -135,7 +137,49 @@
It is inspired from [[https://www.youtube.com/watch?v=UCEXY46t3OA][this video]] from [[https://lukesmith.xyz/][Luke Smith]], rewritten in Fish.
* Rofimount
* Polybar-launch
:PROPERTIES:
:CUSTOM_ID: h-68587918-879b-42db-b304-901d01233f95
:HEADER-ARGS: :tangle polybar-launch :exports code
:END:
This scripts allows the user to kill polybar and relaunch it, or to simply
launch it if polybar isnt launched yet. This script is a bash script, so
lets declare its shebang.
#+BEGIN_SRC bash
#!/usr/bin/env bash
#+END_SRC
First thing to do is kill all polybar processes.
#+BEGIN_SRC bash
killall -q polybar
#+END_SRC
Now we have to wait untill all polybar processes have been shut down.
#+BEGIN_SRC bash
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
#+END_SRC
Now that our system isnt running polybar anymore, well launch it again on
all of our screens. By the way, I have two bars, so Ill have to lauch them
both.
#+BEGIN_SRC bash
if type "xrandr"; then
for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
MONITOR=$m polybar --reload top &
MONITOR=$m polybar --reload bottom &
done
else
polybar --reload top &
polybar --reload bottom &
fi
#+END_SRC
And were done! Lets just launch a notification polybar has been relaunched.
#+BEGIN_SRC bash
notify-send "Polybar restarted!" -a "polybar-launch"
#+END_SRC
* Rofi-mount
:PROPERTIES:
:HEADER-ARGS: :tangle rofi-mount :exports code
:CUSTOM_ID: h-32ee4a66-e7fb-4abf-a168-fa259efdb1f4
@ -146,7 +190,7 @@
original script. For the record, this is a fish script. Lets declare our
shebang.
#+BEGIN_SRC fish
#!/usr/bin/fish
#!/usr/bin/env fish
#+END_SRC
** Get the mountable elements
@ -527,7 +571,7 @@
And with that, this is the end of our script!
* Rofiumount
* Rofi-umount
:PROPERTIES:
:CUSTOM_ID: h-68a1f671-5dc6-4120-81c8-c94fffa7d7a3
:HEADER-ARGS: :tangle rofi-umount :exports code
@ -535,7 +579,7 @@
=rofiumount= is the counterpart of =rofimount= for unmounting our mounted
partitions. It is a fish script, so lets declare it as that with its shebang.
#+BEGIN_SRC fish
#!/usr/bin/fish
#!/usr/bin/env fish
#+END_SRC
** Get the unmountable drives
@ -773,7 +817,7 @@
This is a one-liner that allows you to watch Star Wars episode 4 in ASCII art
in your terminal. Here is the code:
#+BEGIN_SRC fish
#!/usr/bin/fish
#!/usr/bin/env fish
telnet towel.blinkenlights.nl
#+END_SRC
@ -785,7 +829,7 @@
I made a small and quick utility to set up my Wacom tablet so it is only bound
to one screen. This is a fish script, so lets insert the sheband.
#+BEGIN_SRC fish
#!/usr/bin/fish
#!/usr/bin/env fish
#+END_SRC
** Set our variables
@ -944,3 +988,17 @@
set_screen
adjust_device
#+END_SRC
* Yadm
:PROPERTIES:
:CUSTOM_ID: h-9535957b-7559-4244-a5e0-d056c4770fea
:HEADER-ARGS: :tangle yadm :exports code
:END:
For some reason, =yadm= wont stop making polybar crash. So, I created this
script that will wrap yadm with a call to yadm, and then a call to
=polybar-launch= declared in [[#polybar-launch][Polybar-launch]]. This is a oneliner, as you can
see below:
#+BEGIN_SRC fish
#!/usr/bin/env fish
/usr/bin/yadm $argv; polybar-launch 2>/dev/null >/dev/null
#+END_SRC

View File

@ -1,3 +1,3 @@
#!/usr/bin/fish
#!/usr/bin/env fish
rofi -dmenu -font 'DejaVu Sans 10' -password -no-fixed-num-lines \
-p (printf $argv[1] | sed s/://)

View File

@ -1,2 +1,2 @@
#!/usr/bin/fish
/usr/bin/rofi -dmenu $argv
#!/usr/bin/env fish
rofi -dmenu $argv

View File

@ -1,4 +1,4 @@
#!/usr/bin/fish
#!/usr/bin/env fish
grep -v "#" ~/.config/emoji.txt | rofi -dmenu -i | awk '{print $1}' | tr -d '\n' | xclip -selection clipboard
set emoji (xclip -o -selection clipboard | tr -d '\n')

View File

@ -1,4 +1,4 @@
#!/usr/bin/fish
#!/usr/bin/env fish
begin

View File

@ -1,4 +1,4 @@
#!/usr/bin/fish
#!/usr/bin/env fish
set -g drives (lsblk -nrpo "name,type,size,mountpoint" | \
awk '$2=="part"&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')

View File

@ -1,2 +1,2 @@
#!/usr/bin/fish
#!/usr/bin/env fish
telnet towel.blinkenlights.nl

View File

@ -1,63 +1,63 @@
#!/usr/bin/fish
#!/usr/bin/env fish
function set_device
set -g DEVICE "Wacom USB Bamboo PAD Pen stylus"
set -g DEVICETOUCH "Wacom USB Bamboo PAD Finger touch"
set -g DEVICE "Wacom USB Bamboo PAD Pen stylus"
set -g DEVICETOUCH "Wacom USB Bamboo PAD Finger touch"
set -g WACOMPROPTOUCHSPEED "Device Accel Velocity Scaling"
set -g WACOMPROPSCROLLPSEED "ScrollDistance"
set -g WACOMPROPTOUCHSPEED "Device Accel Velocity Scaling"
set -g WACOMPROPSCROLLPSEED "ScrollDistance"
xsetwacom set "$DEVICE" ResetArea
xsetwacom set "$DEVICE" ResetArea
set -l AREATOT (xsetwacom get "$DEVICE" Area)
set -g AREAX (echo $AREATOT | awk '{print $3}')
set -g AREAY (echo $AREATOT | awk '{print $4}')
set -l AREATOT (xsetwacom get "$DEVICE" Area)
set -g AREAX (echo $AREATOT | awk '{print $3}')
set -g AREAY (echo $AREATOT | awk '{print $4}')
end
function set_screen
set CONNECTED_DISPLAYS (xrandr -q --current | \
sed -n 's/^\([^ ]\+\) connected .*/\1/p') desktop
set CONNECTED_DISPLAYS (xrandr -q --current | \
sed -n 's/^\([^ ]\+\) connected .*/\1/p') desktop
set -g SCREEN (for d in $CONNECTED_DISPLAYS
echo $d
end | rofi -dmenu -i -p "Select your dispaly" | tr -d '\n')
set -g SCREEN (for d in $CONNECTED_DISPLAYS
echo $d
end | rofi -dmenu -i -p "Select your dispaly" | tr -d '\n')
set -l LINE (xrandr -q --current | if [ "$SCREEN" = "desktop" ]
sed -n 's/^Screen 0:.*, current \([0-9]\+\) x \([0-9]\+\),.*/\1 \2/p'
else
sed -n "s/^$SCREEN"' connected \(primary \)\{0,1\}\([0-9]\+\)x\([0-9]\+\)+.*/\2 \3/p'
end)
set -l LINE (xrandr -q --current | if [ "$SCREEN" = "desktop" ]
sed -n 's/^Screen 0:.*, current \([0-9]\+\) x \([0-9]\+\),.*/\1 \2/p'
else
sed -n "s/^$SCREEN"' connected \(primary \)\{0,1\}\([0-9]\+\)x\([0-9]\+\)+.*/\2 \3/p'
end)
echo $LINE | read -g WIDTH HEIGHT
echo $LINE | read -g WIDTH HEIGHT
if test -z $WIDTH || test -z $HEIGHT
exit 1
end
if test -z $WIDTH || test -z $HEIGHT
exit 1
end
end
function adjust_device
set RATIOAREAY (math ceil \($AREAX \* $HEIGHT \/ $WIDTH\))
set RATIOAREAX (math ceil \($AREAY \* $WIDTH \/ $HEIGHT\))
set RATIOAREAY (math ceil \($AREAX \* $HEIGHT \/ $WIDTH\))
set RATIOAREAX (math ceil \($AREAY \* $WIDTH \/ $HEIGHT\))
if test $AREAY -gt $RATIOAREAY
set -g NEWAREAX $AREAX
set -g NEWAREAY $RATIOAREAY
else
set -g NEWAREAX $RATIOAREAX
set -g NEWAREAY $AREAY
end
if test $AREAY -gt $RATIOAREAY
set -g NEWAREAX $AREAX
set -g NEWAREAY $RATIOAREAY
else
set -g NEWAREAX $RATIOAREAX
set -g NEWAREAY $AREAY
end
xsetwacom set "$DEVICE" Area 0 0 $NEWAREAX $NEWAREAY
xsetwacom set "$DEVICE" MapToOutput "$SCREEN"
xsetwacom set "$DEVICE" Area 0 0 $NEWAREAX $NEWAREAY
xsetwacom set "$DEVICE" MapToOutput "$SCREEN"
xinput set-float-prop $DEVICETOUCH $WACOMPROPTOUCHSPEED 0.5
xinput set-float-prop $DEVICETOUCH $WACOMPROPTOUCHSPEED 0.5
xsetwacom set $DEVICETOUCH $WACOMPROPSCROLLPSEED "90"
xsetwacom set $DEVICETOUCH $WACOMPROPSCROLLPSEED "90"
end

2
.local/bin/yadm Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env fish
/usr/bin/yadm $argv; polybar-launch 2>/dev/null >/dev/null