Browse Source

Moved to dunst based statusbar

tags/v0.6.0
Micah Halter 7 months ago
parent
commit
d9ea9a7261
25 changed files with 999 additions and 111 deletions
  1. +2
    -0
      CHANGELOG.md
  2. +2
    -3
      Makefile
  3. +2
    -2
      dunst/.config/dunst/dunstrc
  4. +1
    -1
      etc/sudoers.d/micahprivs
  5. +41
    -56
      i3/.config/i3/config
  6. +1
    -10
      i3blocks/.config/i3blocks/config
  7. +18
    -17
      neovim/.config/nvim/autoload/plug.vim
  8. +9
    -4
      neovim/.config/nvim/init.vim
  9. BIN
      preview.png
  10. +3
    -3
      qutebrowser/.config/qutebrowser/config.py
  11. +1
    -1
      ranger/.config/ranger/rc.conf
  12. +0
    -2
      scripts/.config/Scripts/configs.shortcuts
  13. +8
    -0
      scripts/.config/Scripts/criticalbattery
  14. +1
    -1
      scripts/.config/Scripts/dmenucolor
  15. +45
    -0
      scripts/.config/Scripts/dunstbar
  16. +2
    -2
      scripts/.config/Scripts/dunstcolor
  17. +1
    -1
      scripts/.config/Scripts/statusbar/clock
  18. +1
    -1
      scripts/.config/Scripts/statusbar/date
  19. +1
    -1
      scripts/.config/Scripts/statusbar/ethernet
  20. +13
    -0
      scripts/.config/Scripts/statusbar/fullbar
  21. +3
    -0
      scripts/.config/Scripts/statusbar/i3
  22. +5
    -0
      scripts/.config/Scripts/statusbar/network
  23. +1
    -1
      scripts/.config/Scripts/statusbar/wifi
  24. +838
    -0
      scripts/.config/Scripts/vpnc-script
  25. +0
    -5
      zsh/.zprofile

+ 2
- 0
CHANGELOG.md View File

@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

- Added `dunst` based statusbar
- Added useful python aliases for virtualenv management
- Added tmux system-clipboard support
- Added pandoc template detection
@@ -39,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed

- Removed `i3blocks` dependency
- Revamped httpstart alias
- Removed unneeded `ttf-symbola` font
- Switched to Hack font, and removed Terminus and Inconsolata


+ 2
- 3
Makefile View File

@@ -69,7 +69,6 @@ arch: pacman
gparted \
gscan2pdf \
i3-gaps \
i3blocks \
imagemagick \
intel-ucode \
jdk8-openjdk \
@@ -105,7 +104,7 @@ arch: pacman
python-pip \
qrencode \
r \
ranger \
ranger-git \
rsync \
speedtest-cli \
stow \
@@ -177,6 +176,7 @@ aur: yay
openvpn-update-systemd-resolved \
plantuml \
python-i3ipc \
python-ueberzug-git \
qutebrowser-git \
rtv \
sc-im \
@@ -209,7 +209,6 @@ configs: update stow-pre
gnupg \
gtk \
i3 \
i3blocks \
khal \
khard \
mpv \


+ 2
- 2
dunst/.config/dunst/dunstrc View File

@@ -179,10 +179,10 @@
### Misc/Advanced ###

# dmenu path.
dmenu = /usr/bin/dmenu -p dunst:
dmenu = /home/micah/.config/Scripts/dmenucolor

# Browser for opening urls in context menu.
browser = /usr/bin/firefox -new-tab
browser = /home/micah/.config/Scripts/linkhandler

# Always run rule-defined scripts, even if the notification is suppressed
always_run_script = true


+ 1
- 1
etc/sudoers.d/micahprivs View File

@@ -1 +1 @@
micah ALL= NOPASSWD:/bin/mount,/bin/umount,/bin/mkdir,/usr/bin/openvpn
micah ALL= NOPASSWD:/bin/mount,/bin/umount,/bin/mkdir,/usr/bin/openvpn,/usr/bin/light

+ 41
- 56
i3/.config/i3/config View File

@@ -163,22 +163,6 @@ exec --no-startup-id $BROWSER
# terminal
exec --no-startup-id i3-msg 'workspace $workspace2; exec $TERMINAL; workspace $workspace1'

bar {
font pango:mono 10
status_command i3blocks
position top
mode dock
modifier None
colors {
background $inactive-bg-color
statusline $bg-color
focused_workspace $inactive-bg-color $inactive-bg-color $text-color
active_workspace $inactive-bg-color $inactive-bg-color $inactive-text-color
inactive_workspace $inactive-bg-color $inactive-bg-color $inactive-text-color
urgent_workspace $urgent-bg-color $urgent-bg-color $text-color
}
}


######################
# LETTER KEYBINDINGS #
@@ -239,8 +223,8 @@ bindsym $mod+Shift+a exec --no-startup-id i3-cliprog ncpamixer "ncpamixe
#bindsym $mod+Control+a
#bindsym $mod+Shift+Control+a

bindsym $mod+s split toggle; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+s exec --no-startup-id i3-workspaceswap; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+s split toggle
bindsym $mod+Shift+s exec --no-startup-id i3-workspaceswap
#bindsym $mod+Control+s
#bindsym $mod+Shift+Control+s

@@ -259,25 +243,25 @@ bindsym $mod+Shift+g exec --no-startup-id dmenubluetooth -d
#bindsym $mod+Control+g
bindsym $mod+Shift+Control+g exec --no-startup-id killall gpymusic & killall cava & echo '' > $HOME/.nowplaying

bindsym $mod+h focus left; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+h move left; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+h focus left
bindsym $mod+Shift+h move left
bindsym $mod+Control+h exec --no-startup-id i3-resize left
bindsym $mod+Shift+Control+h move workspace to output left; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+Control+h move workspace to output left

bindsym $mod+j focus down; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+j move down; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+j focus down
bindsym $mod+Shift+j move down
bindsym $mod+Control+j exec --no-startup-id i3-resize down
bindsym $mod+Shift+Control+j move workspace to output down; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+Control+j move workspace to output down

bindsym $mod+k focus up; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+k move up; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+k focus up
bindsym $mod+Shift+k move up
bindsym $mod+Control+k exec --no-startup-id i3-resize up
bindsym $mod+Shift+Control+k move workspace to output up; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+Control+k move workspace to output up

bindsym $mod+l focus right; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+l move right; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+l focus right
bindsym $mod+Shift+l move right
bindsym $mod+Control+l exec --no-startup-id i3-resize right
bindsym $mod+Shift+Control+l move workspace to output right; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+Control+l move workspace to output right

bindsym $mod+z exec --no-startup-id dmenumount
bindsym $mod+Shift+z exec --no-startup-id dmenuumount
@@ -312,51 +296,51 @@ bindsym $mod+Shift+n exec --no-startup-id $TERMINAL -e 'i3-runner "newsb
bindsym $mod+m exec --no-startup-id i3-cliprog email "neomutt"
bindsym $mod+Shift+m exec --no-startup-id $TERMINAL --name=gpymusic -e 'i3-runner "gpymusic"'
#bindsym $mod+Control+m
bindsym $mod+Shift+Control+m exec --no-startup-id amixer -D pulse sset Master toggle; exec --no-startup-id bash -c "$I3BLOCKS_VOLUME"
bindsym $mod+Shift+Control+m exec --no-startup-id amixer -D pulse sset Master toggle; exec --no-startup-id dunstbar -s volume -t 1000


######################
# NUMBER KEYBINDINGS #
######################

bindsym $mod+1 workspace $workspace1; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+1 move container to workspace $workspace1; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+1 workspace $workspace1
bindsym $mod+Shift+1 move container to workspace $workspace1
#bindsym $mod+Shift+Control+1

bindsym $mod+2 workspace $workspace2; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+2 move container to workspace $workspace2; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+2 workspace $workspace2
bindsym $mod+Shift+2 move container to workspace $workspace2
#bindsym $mod+Shift+Control+2

bindsym $mod+3 workspace $workspace3; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+3 move container to workspace $workspace3; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+3 workspace $workspace3
bindsym $mod+Shift+3 move container to workspace $workspace3
#bindsym $mod+Shift+Control+3

bindsym $mod+4 workspace $workspace4; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+4 move container to workspace $workspace4; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+4 workspace $workspace4
bindsym $mod+Shift+4 move container to workspace $workspace4
#bindsym $mod+Shift+Control+4

bindsym $mod+5 workspace $workspace5; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+5 move container to workspace $workspace5; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+5 workspace $workspace5
bindsym $mod+Shift+5 move container to workspace $workspace5
#bindsym $mod+Shift+Control+5

bindsym $mod+6 workspace $workspace6; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+6 move container to workspace $workspace6; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+6 workspace $workspace6
bindsym $mod+Shift+6 move container to workspace $workspace6
#bindsym $mod+Shift+Control+6

bindsym $mod+7 workspace $workspace7; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+7 move container to workspace $workspace7; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+7 workspace $workspace7
bindsym $mod+Shift+7 move container to workspace $workspace7
#bindsym $mod+Shift+Control+7

bindsym $mod+8 workspace $workspace8; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+8 move container to workspace $workspace8; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+8 workspace $workspace8
bindsym $mod+Shift+8 move container to workspace $workspace8
#bindsym $mod+Shift+Control+8

bindsym $mod+9 workspace $workspace9; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+9 move container to workspace $workspace9; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+9 workspace $workspace9
bindsym $mod+Shift+9 move container to workspace $workspace9
#bindsym $mod+Shift+Control+9

bindsym $mod+0 workspace $workspace10; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+Shift+0 move container to workspace $workspace10; exec --no-startup-id bash -c "$I3BLOCKS_LAYOUT"
bindsym $mod+0 workspace $workspace10
bindsym $mod+Shift+0 move container to workspace $workspace10
#bindsym $mod+Shift+Control+0
bindsym $mod+Control+0 gaps inner current set $defaultgaps

@@ -440,7 +424,7 @@ bindsym $mod+Shift+F3 exec --no-startup-id displayctrl -r HDMI-2 -p HDMI-3
bindsym $mod+F4 exec --no-startup-id displayctrl LVDS-1
#bindsym $mod+Shift+F4

bindsym $mod+F5 exec --no-startup-id i3-powersaver
bindsym $mod+F5 exec --no-startup-id i3-powersaver; exec --no-startup-id dunstbar -t 1000
#bindsym $mod+Shift+F5

#bindsym $mod+F6
@@ -452,7 +436,8 @@ bindsym $mod+F5 exec --no-startup-id i3-powersaver
#bindsym $mod+F8
#bindsym $mod+Shift+F8

#bindsym $mod+F9
bindsym F9 exec --no-startup-id dunstbar
bindsym $mod+F9 exec --no-startup-id dunstify -C 800
#bindsym $mod+Shift+F9

#bindsym $mod+F10
@@ -496,9 +481,9 @@ bindsym $mod+Shift+Control+Next exec --no-startup-id dmenushutdown
# MEDIA KEYBINDINGS #
#####################

bindsym XF86AudioLowerVolume exec --no-startup-id amixer -D pulse sset Master 5%-; exec --no-startup-id bash -c "$I3BLOCKS_VOLUME"
bindsym XF86AudioRaiseVolume exec --no-startup-id amixer -D pulse sset Master 5%+; exec --no-startup-id bash -c "$I3BLOCKS_VOLUME"
bindsym XF86AudioMute exec --no-startup-id amixer -D pulse sset Master toggle; exec --no-startup-id bash -c "$I3BLOCKS_VOLUME"
bindsym XF86AudioLowerVolume exec --no-startup-id amixer -D pulse sset Master 5%-; exec --no-startup-id dunstbar -s volume -t 1000
bindsym XF86AudioRaiseVolume exec --no-startup-id amixer -D pulse sset Master 5%+; exec --no-startup-id dunstbar -s volume -t 1000
bindsym XF86AudioMute exec --no-startup-id amixer -D pulse sset Master toggle; exec --no-startup-id dunstbar -s volume -t 1000
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute $(pacmd list-sources|awk '/\* index:/{ print $3 }') toggle

bindsym XF86AudioPause exec --no-startup-id echo "cycle pause" > $HOME/.config/mpv/control


+ 1
- 10
i3blocks/.config/i3blocks/config View File

@@ -4,7 +4,6 @@ separator_block_width=15
markup=pango

[mail]
label=
interval=once
signal=13

@@ -12,13 +11,7 @@ signal=13
interval=1
signal=11

[vpn]
interval=1

[wifi]
interval=1

[ethernet]
[network]
interval=1

[powersaver]
@@ -29,11 +22,9 @@ signal=12
interval=1

[date]
label=
interval=1

[clock]
label=
interval=1

[layout]


+ 18
- 17
neovim/.config/nvim/autoload/plug.vim View File

@@ -334,11 +334,11 @@ function! s:progress_opt(base)
\ s:git_version_requirement(1, 7, 1) ? '--progress' : ''
endfunction

if s:is_win
function! s:rtp(spec)
return s:path(a:spec.dir . get(a:spec, 'rtp', ''))
endfunction
function! s:rtp(spec)
return s:path(a:spec.dir . get(a:spec, 'rtp', ''))
endfunction

if s:is_win
function! s:path(path)
return s:trim(substitute(a:path, '/', '\', 'g'))
endfunction
@@ -353,14 +353,16 @@ if s:is_win

" Copied from fzf
function! s:wrap_cmds(cmds)
let use_chcp = executable('sed')
return map([
\ '@echo off',
\ 'setlocal enabledelayedexpansion',
\ 'for /f "tokens=*" %%a in (''chcp'') do for %%b in (%%a) do set origchcp=%%b',
\ 'chcp 65001 > nul'
\ ]
\ 'setlocal enabledelayedexpansion']
\ + (use_chcp ? [
\ 'for /f "usebackq" %%a in (`chcp ^| sed "s/[^0-9]//gp"`) do set origchcp=%%a',
\ 'chcp 65001 > nul'] : [])
\ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds])
\ + ['chcp !origchcp! > nul', 'endlocal'],
\ + (use_chcp ? ['chcp !origchcp! > nul'] : [])
\ + ['endlocal'],
\ 'v:val."\r"')
endfunction

@@ -374,10 +376,6 @@ if s:is_win
return [batchfile, cmd]
endfunction
else
function! s:rtp(spec)
return s:dirpath(a:spec.dir . get(a:spec, 'rtp', ''))
endfunction

function! s:path(path)
return s:trim(a:path)
endfunction
@@ -824,6 +822,7 @@ function! s:chsh(swap)
endfunction

function! s:bang(cmd, ...)
let batchfile = ''
try
let [sh, shellcmdflag, shrd] = s:chsh(a:0)
" FIXME: Escaping is incomplete. We could use shellescape with eval,
@@ -837,7 +836,7 @@ function! s:bang(cmd, ...)
finally
unlet g:_plug_bang
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
if s:is_win
if s:is_win && filereadable(batchfile)
call delete(batchfile)
endif
endtry
@@ -1034,7 +1033,7 @@ function! s:update_impl(pull, force, args) abort
let s:clone_opt = get(g:, 'plug_shallow', 1) ?
\ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : ''

if has('win32unix')
if has('win32unix') || has('wsl')
let s:clone_opt .= ' -c core.eol=lf -c core.autocrlf=input'
endif

@@ -2049,6 +2048,7 @@ function! s:with_cd(cmd, dir, ...)
endfunction

function! s:system(cmd, ...)
let batchfile = ''
try
let [sh, shellcmdflag, shrd] = s:chsh(1)
let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
@@ -2058,7 +2058,7 @@ function! s:system(cmd, ...)
return system(cmd)
finally
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
if s:is_win
if s:is_win && filereadable(batchfile)
call delete(batchfile)
endif
endtry
@@ -2381,6 +2381,7 @@ function! s:preview_commit()
wincmd P
endif
setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable
let batchfile = ''
try
let [sh, shellcmdflag, shrd] = s:chsh(1)
let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
@@ -2390,7 +2391,7 @@ function! s:preview_commit()
execute 'silent %!' cmd
finally
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
if s:is_win
if s:is_win && filereadable(batchfile)
call delete(batchfile)
endif
endtry


+ 9
- 4
neovim/.config/nvim/init.vim View File

@@ -34,7 +34,7 @@ Plug 'https://github.com/vim-pandoc/vim-pandoc'
Plug 'https://github.com/vim-pandoc/vim-pandoc-syntax'
Plug 'https://github.com/vim-pandoc/vim-rmarkdown'
Plug 'https://github.com/vim-scripts/ReplaceWithRegister'
Plug 'https://github.com/wmvanvliet/jupyter-vim'
" Plug 'https://github.com/wmvanvliet/jupyter-vim'
call plug#end()

""""""""""""""""""""""""""""
@@ -64,7 +64,7 @@ set nowritebackup
set noswapfile
" linebreak at 500 characters
set linebreak
set textwidth=500
set textwidth=80
set wrap
" go to last position on open
augroup startup
@@ -101,7 +101,7 @@ let g:mapleader = " "
""""""""""""""""""""""""""""
set ruler
set number
set relativenumber
" set relativenumber
set showbreak=..
set fillchars+=vert:│
set hidden
@@ -113,7 +113,7 @@ set foldnestmax=10
set nofoldenable
set foldlevel=2
set foldcolumn=2
set conceallevel=2
set conceallevel=0
set wildignore=*.o,*~,*.pyc,*/.gi/*,*/.hg/*,*/.cvn/*,*/.DS_Store
" backspace functionality
set whichwrap+=<,>,h,l
@@ -179,6 +179,9 @@ let g:vimtex_compiler_progname='nvr'
" table-mode
let g:table_mode_corner='|'

" pandoc-syntax
let g:pandoc#syntax#conceal#use = 0

" lightline
let g:lightline = {
\ 'colorscheme': 'wal',
@@ -482,6 +485,8 @@ augroup markup
autocmd BufNewFile,BufRead *.md,*.rmd setlocal textwidth=80
" turn on spell check
autocmd BufNewFile,BufRead *.md,*.rmd setlocal spell spelllang=en_us
" enable justify package
autocmd BufNewFile,BufRead *.md,*.rmd packadd justify
augroup END

" => Java


BIN
preview.png View File

Before After
Width: 1600  |  Height: 900  |  Size: 434 KiB Width: 1920  |  Height: 1080  |  Size: 1.3 MiB

+ 3
- 3
qutebrowser/.config/qutebrowser/config.py View File

@@ -7,7 +7,7 @@ import os

colors = []

with open(os.getenv('XDG_CONFIG_HOME', '~/.config')+'/wpg/formats/colors') as f:
with open(os.getenv('HOME', '~')+'/.cache/wal/colors') as f:
colors = f.read().splitlines()

config.load_autoconfig()
@@ -147,8 +147,8 @@ c.editor.command = ['urxvt', '-e', 'runner', 'nvim {}']
c.qt.args = ['ppapi-widevine-path=/usr/lib/qt/plugins/ppapi/libwidevinecdmadapter.so', 'disable-seccomp-filter-sandbox']

# set default pages
c.url.default_page = "https://start.duckduckgo.com"
c.url.start_pages = c.url.default_page
c.url.default_page = "file:///home/micah/Documents/start-page/index.html"
c.url.start_pages = "file:///home/micah/Documents/start-page/index.html"

# set search engines
c.url.searchengines["aw"] = "https://wiki.archlinux.org/?search={}"


+ 1
- 1
ranger/.config/ranger/rc.conf View File

@@ -13,7 +13,7 @@ set vcs_backend_git enabled
set vcs_backend_hg disabled
set vcs_backend_bzr disabled
set preview_images true
set preview_images_method w3m
set preview_images_method ueberzug
set unicode_ellipsis false
set show_hidden_bookmarks true
set colorscheme default


+ 0
- 2
scripts/.config/Scripts/configs.shortcuts View File

@@ -1,11 +1,9 @@
cfa ~/.zsh_aliases
cfb ~/.bashrc
cfd ~/.config/i3blocks/config
cfcf ~/.config/Scripts/configs.shortcuts
cfcv ~/Documents/mehalter.com/content.yml
cff ~/.config/Scripts/folders.shortcuts
cfi ~/.config/i3/config
cfm ~/.config/mutt/muttrc
cfq ~/.config/qutebrowser/config.py
cfr ~/.config/ranger/rc.conf
cft ~/.tmux.conf


+ 8
- 0
scripts/.config/Scripts/criticalbattery View File

@@ -0,0 +1,8 @@
#!/bin/bash

capacity=$(cat /sys/class/power_supply/BAT0/capacity)
status=$(cat /sys/class/power_supply/BAT0/status)

if [ "$capacity" -le 15 ] && [ "$status" != "Charging" ]; then
dunstify -r 900 -t 5000 "BATTERY LOW" " $capacity%"
fi

+ 1
- 1
scripts/.config/Scripts/dmenucolor View File

@@ -1,6 +1,6 @@
#!/bin/bash

source ~/.config/wpg/formats/colors.sh
source ~/.cache/wal/colors.sh

command=dmenu



+ 45
- 0
scripts/.config/Scripts/dunstbar View File

@@ -0,0 +1,45 @@
#!/bin/bash

scripts="$HOME/.config/Scripts/statusbar"
time=3000

script="$scripts/fullbar"
body=""


showusage() {
echo "Usage:"
echo " dunstbar [options]"
echo ""
echo "Options:"
echo " -s <script> Script to be used (default: fullbar)"
echo " -t <time> Duration to display notification in ms (default: 3000)"
echo " -i Include i3 workspaces"
echo " -h Show this screen."
}


while getopts "t:s:ih" option; do
case ${option} in
t )
time="$OPTARG"
;;
s )
[ -f "$scripts/$OPTARG" ] && script="$scripts/$OPTARG"
;;
i )
body="$($scripts/i3)"
;;
h )
showusage
exit 0
;;
\? )
echo "Invalid Option: -$OPTARG" 1>&2
showusage
exit 1
;;
esac
done

dunstify -t $time -r 800 "$($script)" "$body"

+ 2
- 2
scripts/.config/Scripts/dunstcolor View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash

. "$HOME/.config/wpg/formats/colors.sh"
. "$HOME/.cache/wal/colors.sh"

dunst \
-lb "${background:-#FFFFFF}" \
@@ -14,4 +14,4 @@ dunst \
-lto 2 \
-nto 2 \
-cto 5 \
-geometry "300x5-10+34"
-geometry "0x5-10+34"

+ 1
- 1
scripts/.config/Scripts/statusbar/clock View File

@@ -1,3 +1,3 @@
#!/bin/bash

date '+%H:%M:%S'
echo " $(date '+%H:%M:%S')"

+ 1
- 1
scripts/.config/Scripts/statusbar/date View File

@@ -1,3 +1,3 @@
#!/bin/bash

date '+%b %d, %Y'
echo " $(date '+%b %d, %Y')"

+ 1
- 1
scripts/.config/Scripts/statusbar/ethernet View File

@@ -1,6 +1,6 @@
#!/bin/bash

device='enp0*'
device="ens*"
ip="$(ip -4 addr show|grep "$device"|grep -oP '(?<=inet )\d*(\.\d*){3}')"
if [ "$ip" != "" ]; then
echo " $ip"


+ 13
- 0
scripts/.config/Scripts/statusbar/fullbar View File

@@ -0,0 +1,13 @@
#!/bin/bash

scripts="$HOME/.config/Scripts/statusbar"

echo "$({ $scripts/mail;
$scripts/volume;
$scripts/network;
$scripts/powersaver;
$scripts/battery;
$scripts/date;
$scripts/clock;
$scripts/layout;
} | tr '\n' ' ')"

+ 3
- 0
scripts/.config/Scripts/statusbar/i3 View File

@@ -0,0 +1,3 @@
#!/bin/bash

echo "$(i3-msg -t get_workspaces|jq 'group_by(.rect.x, .rect.y)|map(map(if .focused then "<b>"+.name+"</b>" else "<small>"+.name+"</small>" end))|.[]|.[]' | tr '\n' ' '|sed 's/"//g')"

+ 5
- 0
scripts/.config/Scripts/statusbar/network View File

@@ -0,0 +1,5 @@
#!/bin/bash

scripts="$HOME/.config/Scripts/statusbar"

echo "$({ $scripts/vpn; $scripts/wifi; $scripts/ethernet; } | tr '\n' ' ')"

+ 1
- 1
scripts/.config/Scripts/statusbar/wifi View File

@@ -1,6 +1,6 @@
#!/bin/bash

device=wlp3s0
device=wlp59s0
ssid="$(iw dev $device info|grep -oP '(?<=ssid ).*')"
if [ "$ssid" != "" ]; then
echo "說 $ssid"


+ 838
- 0
scripts/.config/Scripts/vpnc-script View File

@@ -0,0 +1,838 @@
#!/bin/sh
#
# Originally part of vpnc source code:
# © 2005-2012 Maurice Massar, Jörg Mayer, Antonio Borneo et al.
# © 2009-2012 David Woodhouse <dwmw2@infradead.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
################
#
# List of parameters passed through environment
#* reason -- why this script was called, one of: pre-init connect disconnect reconnect
#* VPNGATEWAY -- vpn gateway address (always present)
#* TUNDEV -- tunnel device (always present)
#* INTERNAL_IP4_ADDRESS -- address (always present)
#* INTERNAL_IP4_MTU -- mtu (often unset)
#* INTERNAL_IP4_NETMASK -- netmask (often unset)
#* INTERNAL_IP4_NETMASKLEN -- netmask length (often unset)
#* INTERNAL_IP4_NETADDR -- address of network (only present if netmask is set)
#* INTERNAL_IP4_DNS -- list of dns servers
#* INTERNAL_IP4_NBNS -- list of wins servers
#* INTERNAL_IP6_ADDRESS -- IPv6 address
#* INTERNAL_IP6_NETMASK -- IPv6 netmask
#* INTERNAL_IP6_DNS -- IPv6 list of dns servers
#* CISCO_DEF_DOMAIN -- default domain name
#* CISCO_BANNER -- banner from server
#* CISCO_SPLIT_INC -- number of networks in split-network-list
#* CISCO_SPLIT_INC_%d_ADDR -- network address
#* CISCO_SPLIT_INC_%d_MASK -- subnet mask (for example: 255.255.255.0)
#* CISCO_SPLIT_INC_%d_MASKLEN -- subnet masklen (for example: 24)
#* CISCO_SPLIT_INC_%d_PROTOCOL -- protocol (often just 0)
#* CISCO_SPLIT_INC_%d_SPORT -- source port (often just 0)
#* CISCO_SPLIT_INC_%d_DPORT -- destination port (often just 0)
#* CISCO_IPV6_SPLIT_INC -- number of networks in IPv6 split-network-list
#* CISCO_IPV6_SPLIT_INC_%d_ADDR -- IPv6 network address
#* CISCO_IPV6_SPLIT_INC_$%d_MASKLEN -- IPv6 subnet masklen

# FIXMEs:

# Section A: route handling

# 1) The 3 values CISCO_SPLIT_INC_%d_PROTOCOL/SPORT/DPORT are currently being ignored
# In order to use them, we'll probably need os specific solutions
# * Linux: iptables -t mangle -I PREROUTING <conditions> -j ROUTE --oif $TUNDEV
# This would be an *alternative* to changing the routes (and thus 2) and 3)
# shouldn't be relevant at all)
# 2) There are two different functions to set routes: generic routes and the
# default route. Why isn't the defaultroute handled via the generic route case?
# 3) In the split tunnel case, all routes but the default route might get replaced
# without getting restored later. We should explicitely check and save them just
# like the defaultroute
# 4) Replies to a dhcp-server should never be sent into the tunnel

# Section B: Split DNS handling

# 1) Maybe dnsmasq can do something like that
# 2) Parse dns packets going out via tunnel and redirect them to original dns-server

#env | sort
#set -x

# =========== script (variable) setup ====================================

PATH=/sbin:/usr/sbin:$PATH

OS="`uname -s`"

HOOKS_DIR=/etc/vpnc
DEFAULT_ROUTE_FILE=/var/run/vpnc/defaultroute
RESOLV_CONF_BACKUP=/var/run/vpnc/resolv.conf-backup
SCRIPTNAME=`basename $0`

# some systems, eg. Darwin & FreeBSD, prune /var/run on boot
if [ ! -d "/var/run/vpnc" ]; then
mkdir -p /var/run/vpnc
[ -x /sbin/restorecon ] && /sbin/restorecon /var/run/vpnc
fi

# stupid SunOS: no blubber in /usr/local/bin ... (on stdout)
IPROUTE="`which ip 2> /dev/null | grep '^/'`"

if ifconfig --help 2>&1 | grep BusyBox > /dev/null; then
ifconfig_syntax_inet=""
else
ifconfig_syntax_inet="inet"
fi

if [ "$OS" = "Linux" ]; then
ifconfig_syntax_ptp="pointopoint"
route_syntax_gw="gw"
route_syntax_del="del"
route_syntax_netmask="netmask"
else
ifconfig_syntax_ptp=""
route_syntax_gw=""
route_syntax_del="delete"
route_syntax_netmask="-netmask"
fi
if [ "$OS" = "SunOS" ]; then
route_syntax_interface="-interface"
ifconfig_syntax_ptpv6="$INTERNAL_IP6_ADDRESS"
else
route_syntax_interface=""
ifconfig_syntax_ptpv6=""
fi

if [ -r /etc/openwrt_release ] && [ -n "$OPENWRT_INTERFACE" ]; then
. /etc/functions.sh
include /lib/network
MODIFYRESOLVCONF=modify_resolvconf_openwrt
RESTORERESOLVCONF=restore_resolvconf_openwrt
elif [ -x /sbin/resolvconf ]; then # Optional tool on Debian, Ubuntu, Gentoo and FreeBSD
MODIFYRESOLVCONF=modify_resolvconf_manager
RESTORERESOLVCONF=restore_resolvconf_manager
elif [ -x /sbin/netconfig ]; then # tool on Suse after 11.1
MODIFYRESOLVCONF=modify_resolvconf_suse_netconfig
RESTORERESOLVCONF=restore_resolvconf_suse_netconfig
elif [ -x /sbin/modify_resolvconf ]; then # Mandatory tool on Suse earlier than 11.1
MODIFYRESOLVCONF=modify_resolvconf_suse
RESTORERESOLVCONF=restore_resolvconf_suse
elif [ -x /usr/sbin/unbound-control ] && /usr/sbin/unbound-control status > /dev/null 2>&1; then
MODIFYRESOLVCONF=modify_resolvconf_unbound
RESTORERESOLVCONF=restore_resolvconf_unbound
else # Generic for any OS
MODIFYRESOLVCONF=modify_resolvconf_generic
RESTORERESOLVCONF=restore_resolvconf_generic
fi


# =========== script hooks =================================================

run_hooks() {
HOOK="$1"

if [ -d ${HOOKS_DIR}/${HOOK}.d ]; then
for script in ${HOOKS_DIR}/${HOOK}.d/* ; do
[ -f $script ] && . $script
done
fi
}

# =========== tunnel interface handling ====================================

do_ifconfig() {
if [ -n "$INTERNAL_IP4_MTU" ]; then
MTU=$INTERNAL_IP4_MTU
elif [ -n "$IPROUTE" ]; then
MTUDEV=`$IPROUTE route get "$VPNGATEWAY" | sed -ne 's/^.*dev \([a-z0-9]*\).*$/\1/p'`
MTU=`$IPROUTE link show "$MTUDEV" | sed -ne 's/^.*mtu \([[:digit:]]\+\).*$/\1/p'`
if [ -n "$MTU" ]; then
MTU=`expr $MTU - 88`
fi
fi

if [ -z "$MTU" ]; then
MTU=1412
fi

# Point to point interface require a netmask of 255.255.255.255 on some systems
if [ -n "$IPROUTE" ]; then
$IPROUTE link set dev "$TUNDEV" up mtu "$MTU"
$IPROUTE addr add "$INTERNAL_IP4_ADDRESS/32" peer "$INTERNAL_IP4_ADDRESS" dev "$TUNDEV"
else
ifconfig "$TUNDEV" ${ifconfig_syntax_inet} "$INTERNAL_IP4_ADDRESS" $ifconfig_syntax_ptp "$INTERNAL_IP4_ADDRESS" netmask 255.255.255.255 mtu ${MTU} up
fi

if [ -n "$INTERNAL_IP4_NETMASK" ]; then
set_network_route $INTERNAL_IP4_NETADDR $INTERNAL_IP4_NETMASK $INTERNAL_IP4_NETMASKLEN
fi

# If the netmask is provided, it contains the address _and_ netmask
if [ -n "$INTERNAL_IP6_ADDRESS" ] && [ -z "$INTERNAL_IP6_NETMASK" ]; then
INTERNAL_IP6_NETMASK="$INTERNAL_IP6_ADDRESS/128"
fi
if [ -n "$INTERNAL_IP6_NETMASK" ]; then
if [ -n "$IPROUTE" ]; then
$IPROUTE -6 addr add $INTERNAL_IP6_NETMASK dev $TUNDEV
else
# Unlike for Legacy IP, we don't specify the dest_address
# here on *BSD. OpenBSD for one will refuse to accept
# incoming packets to that address if we do.
# OpenVPN does the same (gives dest_address for Legacy IP
# but not for IPv6).
# Only Solaris needs it; hence $ifconfig_syntax_ptpv6
ifconfig "$TUNDEV" inet6 $INTERNAL_IP6_NETMASK $ifconfig_syntax_ptpv6 mtu $MTU up
fi
fi
}

destroy_tun_device() {
case "$OS" in
NetBSD|OpenBSD) # and probably others...
ifconfig "$TUNDEV" destroy
;;
FreeBSD)
ifconfig "$TUNDEV" destroy > /dev/null 2>&1 &
;;
esac
}

# =========== route handling ====================================

if [ -n "$IPROUTE" ]; then
fix_ip_get_output () {
sed -e 's/ /\n/g' | \
sed -ne '1p;/via/{N;p};/dev/{N;p};/src/{N;p};/mtu/{N;p}'
}

set_vpngateway_route() {
$IPROUTE route add `$IPROUTE route get "$VPNGATEWAY" | fix_ip_get_output`
$IPROUTE route flush cache
}

del_vpngateway_route() {
$IPROUTE route $route_syntax_del "$VPNGATEWAY"
$IPROUTE route flush cache
}

set_default_route() {
$IPROUTE route | grep '^default' | fix_ip_get_output > "$DEFAULT_ROUTE_FILE"
$IPROUTE route replace default dev "$TUNDEV"
$IPROUTE route flush cache
}

set_network_route() {
NETWORK="$1"
NETMASK="$2"
NETMASKLEN="$3"
$IPROUTE route replace "$NETWORK/$NETMASKLEN" dev "$TUNDEV"
$IPROUTE route flush cache
}

reset_default_route() {
if [ -s "$DEFAULT_ROUTE_FILE" ]; then
$IPROUTE route replace `cat "$DEFAULT_ROUTE_FILE"`
$IPROUTE route flush cache
rm -f -- "$DEFAULT_ROUTE_FILE"
fi
}

del_network_route() {
NETWORK="$1"
NETMASK="$2"
NETMASKLEN="$3"
$IPROUTE route $route_syntax_del "$NETWORK/$NETMASKLEN" dev "$TUNDEV"
$IPROUTE route flush cache
}

set_ipv6_default_route() {
# We don't save/restore IPv6 default route; just add a higher-priority one.
$IPROUTE -6 route add default dev "$TUNDEV" metric 1
$IPROUTE -6 route flush cache
}

set_ipv6_network_route() {
NETWORK="$1"
NETMASKLEN="$2"
$IPROUTE -6 route replace "$NETWORK/$NETMASKLEN" dev "$TUNDEV"
$IPROUTE route flush cache
}

reset_ipv6_default_route() {
$IPROUTE -6 route del default dev "$TUNDEV"
$IPROUTE route flush cache
}

del_ipv6_network_route() {
NETWORK="$1"
NETMASKLEN="$2"
$IPROUTE -6 route del "$NETWORK/$NETMASKLEN" dev "$TUNDEV"
$IPROUTE -6 route flush cache
}
else # use route command
get_default_gw() {
# isn't -n supposed to give --numeric output?
# apperently not...
# Get rid of lines containing IPv6 addresses (':')
netstat -r -n | awk '/:/ { next; } /^(default|0\.0\.0\.0)/ { print $2; }'
}

set_vpngateway_route() {
route add -host "$VPNGATEWAY" $route_syntax_gw "`get_default_gw`"
}

del_vpngateway_route() {
route $route_syntax_del -host "$VPNGATEWAY" $route_syntax_gw "`get_default_gw`"
}

set_default_route() {
DEFAULTGW="`get_default_gw`"
echo "$DEFAULTGW" > "$DEFAULT_ROUTE_FILE"
route $route_syntax_del default $route_syntax_gw "$DEFAULTGW"
route add default $route_syntax_gw "$INTERNAL_IP4_ADDRESS" $route_syntax_interface
}

set_network_route() {
NETWORK="$1"
NETMASK="$2"
NETMASKLEN="$3"
del_network_route "$NETWORK" "$NETMASK" "$NETMASKLEN"
route add -net "$NETWORK" $route_syntax_netmask "$NETMASK" $route_syntax_gw "$INTERNAL_IP4_ADDRESS" $route_syntax_interface
}

reset_default_route() {
if [ -s "$DEFAULT_ROUTE_FILE" ]; then
route $route_syntax_del default $route_syntax_gw "`get_default_gw`" $route_syntax_interface
route add default $route_syntax_gw `cat "$DEFAULT_ROUTE_FILE"`
rm -f -- "$DEFAULT_ROUTE_FILE"
fi
}

del_network_route() {
case "$OS" in
Linux|NetBSD|OpenBSD|Darwin|SunOS) # and probably others...
# routes are deleted automatically on device shutdown
return
;;
esac
NETWORK="$1"
NETMASK="$2"
NETMASKLEN="$3"
route $route_syntax_del -net "$NETWORK" $route_syntax_netmask "$NETMASK" $route_syntax_gw "$INTERNAL_IP4_ADDRESS"
}

set_ipv6_default_route() {
route add -inet6 default "$INTERNAL_IP6_ADDRESS" $route_syntax_interface
}

set_ipv6_network_route() {
NETWORK="$1"
NETMASK="$2"
route add -inet6 -net "$NETWORK/$NETMASK" "$INTERNAL_IP6_ADDRESS" $route_syntax_interface
:
}

reset_ipv6_default_route() {
route $route_syntax_del -inet6 default "$INTERNAL_IP6_ADDRESS"
:
}

del_ipv6_network_route() {
NETWORK="$1"
NETMASK="$2"
route $route_syntax_del -inet6 "$NETWORK/$NETMASK" "$INTERNAL_IP6_ADDRESS"
:
}

fi

# =========== resolv.conf handling ====================================

# =========== resolv.conf handling for any OS =========================

modify_resolvconf_generic() {
grep '^#@VPNC_GENERATED@' /etc/resolv.conf > /dev/null 2>&1 || cp -- /etc/resolv.conf "$RESOLV_CONF_BACKUP"
NEW_RESOLVCONF="#@VPNC_GENERATED@ -- this file is generated by vpnc
# and will be overwritten by vpnc
# as long as the above mark is intact"

# Remember the original value of CISCO_DEF_DOMAIN we need it later
CISCO_DEF_DOMAIN_ORIG="$CISCO_DEF_DOMAIN"
# Don't step on INTERNAL_IP4_DNS value, use a temporary variable
INTERNAL_IP4_DNS_TEMP="$INTERNAL_IP4_DNS"
exec 6< "$RESOLV_CONF_BACKUP"
while read LINE <&6 ; do
case "$LINE" in
nameserver*)
if [ -n "$INTERNAL_IP4_DNS_TEMP" ]; then
read ONE_NAMESERVER INTERNAL_IP4_DNS_TEMP <<-EOF
$INTERNAL_IP4_DNS_TEMP
EOF
LINE="nameserver $ONE_NAMESERVER"
else
LINE=""
fi
;;
search*)
if [ -n "$CISCO_DEF_DOMAIN" ]; then
LINE="$LINE $CISCO_DEF_DOMAIN"
CISCO_DEF_DOMAIN=""
fi
;;
domain*)
if [ -n "$CISCO_DEF_DOMAIN" ]; then
LINE="domain $CISCO_DEF_DOMAIN"
CISCO_DEF_DOMAIN=""
fi
;;
esac
NEW_RESOLVCONF="$NEW_RESOLVCONF
$LINE"
done
exec 6<&-

for i in $INTERNAL_IP4_DNS_TEMP ; do
NEW_RESOLVCONF="$NEW_RESOLVCONF
nameserver $i"
done
if [ -n "$CISCO_DEF_DOMAIN" ]; then
NEW_RESOLVCONF="$NEW_RESOLVCONF
search $CISCO_DEF_DOMAIN"
fi
echo "$NEW_RESOLVCONF" > /etc/resolv.conf

if [ "$OS" = "Darwin" ]; then
case "`uname -r`" in
# Skip for pre-10.4 systems
4.*|5.*|6.*|7.*)
;;
# 10.4 and later require use of scutil for DNS to work properly
*)
OVERRIDE_PRIMARY=""
if [ -n "$CISCO_SPLIT_INC" ]; then
if [ $CISCO_SPLIT_INC -lt 1 ]; then
# Must override for correct default route
# Cannot use multiple DNS matching in this case
OVERRIDE_PRIMARY='d.add OverridePrimary # 1'
fi
# Overriding the default gateway breaks split routing
OVERRIDE_GATEWAY=""
# Not overriding the default gateway breaks usage of
# INTERNAL_IP4_DNS. Prepend INTERNAL_IP4_DNS to list
# of used DNS servers
SERVICE=`echo "show State:/Network/Global/IPv4" | scutil | grep -oE '[a-fA-F0-9]{8}-([a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}'`
SERVICE_DNS=`echo "show State:/Network/Service/$SERVICE/DNS" | scutil | grep -oE '([0-9]{1,3}[\.]){3}[0-9]{1,3}' | xargs`
if [ X"$SERVICE_DNS" != X"$INTERNAL_IP4_DNS" ]; then
scutil >/dev/null 2>&1 <<-EOF
open
get State:/Network/Service/$SERVICE/DNS
d.add ServerAddresses * $INTERNAL_IP4_DNS $SERVICE_DNS
set State:/Network/Service/$SERVICE/DNS
close
EOF
fi
else
# No split routing. Override default gateway
OVERRIDE_GATEWAY="d.add Router $INTERNAL_IP4_ADDRESS"
fi
# Uncomment the following if/fi pair to use multiple
# DNS matching when available. When multiple DNS matching
# is present, anything reading the /etc/resolv.conf file
# directly will probably not work as intended.
#if [ -z "$CISCO_DEF_DOMAIN_ORIG" ]; then
# Cannot use multiple DNS matching without a domain
OVERRIDE_PRIMARY='d.add OverridePrimary # 1'
#fi
scutil >/dev/null 2>&1 <<-EOF
open
d.init
d.add ServerAddresses * $INTERNAL_IP4_DNS
set State:/Network/Service/$TUNDEV/DNS
d.init
$OVERRIDE_GATEWAY
d.add Addresses * $INTERNAL_IP4_ADDRESS
d.add SubnetMasks * 255.255.255.255
d.add InterfaceName $TUNDEV
$OVERRIDE_PRIMARY
set State:/Network/Service/$TUNDEV/IPv4
close
EOF
if [ -n "$CISCO_DEF_DOMAIN_ORIG" ]; then
scutil >/dev/null 2>&1 <<-EOF
open
get State:/Network/Service/$TUNDEV/DNS
d.add DomainName $CISCO_DEF_DOMAIN_ORIG
d.add SearchDomains * $CISCO_DEF_DOMAIN_ORIG
d.add SupplementalMatchDomains * $CISCO_DEF_DOMAIN_ORIG
set State:/Network/Service/$TUNDEV/DNS
close
EOF
fi
;;
esac
fi
}

restore_resolvconf_generic() {
if [ ! -f "$RESOLV_CONF_BACKUP" ]; then
return
fi
grep '^#@VPNC_GENERATED@' /etc/resolv.conf > /dev/null 2>&1 && cat "$RESOLV_CONF_BACKUP" > /etc/resolv.conf
rm -f -- "$RESOLV_CONF_BACKUP"

if [ "$OS" = "Darwin" ]; then
case "`uname -r`" in
# Skip for pre-10.4 systems
4.*|5.*|6.*|7.*)
;;
# 10.4 and later require use of scutil for DNS to work properly
*)
scutil >/dev/null 2>&1 <<-EOF
open
remove State:/Network/Service/$TUNDEV/IPv4
remove State:/Network/Service/$TUNDEV/DNS
close
EOF
# Split routing required prepending of INTERNAL_IP4_DNS
# to list of used DNS servers
if [ -n "$CISCO_SPLIT_INC" ]; then
SERVICE=`echo "show State:/Network/Global/IPv4" | scutil | grep -oE '[a-fA-F0-9]{8}-([a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}'`
SERVICE_DNS=`echo "show State:/Network/Service/$SERVICE/DNS" | scutil | grep -oE '([0-9]{1,3}[\.]){3}[0-9]{1,3}' | xargs`
if [ X"$SERVICE_DNS" != X"$INTERNAL_IP4_DNS" ]; then
scutil >/dev/null 2>&1 <<-EOF
open
get State:/Network/Service/$SERVICE/DNS
d.add ServerAddresses * ${SERVICE_DNS##$INTERNAL_IP4_DNS}
set State:/Network/Service/$SERVICE/DNS
close
EOF
fi
fi
;;
esac
fi
}
# === resolv.conf handling via /sbin/netconfig (Suse 11.1) =====================

# Suse provides a script that modifies resolv.conf. Use it because it will
# restart/reload all other services that care about it (e.g. lwresd). [unclear if this is still true, but probably --mlk]

modify_resolvconf_suse_netconfig()
{
/sbin/netconfig modify -s vpnc -i "$TUNDEV" <<-EOF
INTERFACE='$TUNDEV'
DNSSERVERS='$INTERNAL_IP4_DNS'
DNSDOMAIN='$CISCO_DEF_DOMAIN'
EOF
}
# Restore resolv.conf to old contents on Suse
restore_resolvconf_suse_netconfig()
{
/sbin/netconfig remove -s vpnc -i "$TUNDEV"
}

# === resolv.conf handling via /sbin/modify_resolvconf (Suse) =====================

# Suse provides a script that modifies resolv.conf. Use it because it will
# restart/reload all other services that care about it (e.g. lwresd).

modify_resolvconf_suse()
{
FULL_SCRIPTNAME=`readlink -f $0`
RESOLV_OPTS=''
test -n "$INTERNAL_IP4_DNS" && RESOLV_OPTS="-n \"$INTERNAL_IP4_DNS\""
test -n "$CISCO_DEF_DOMAIN" && RESOLV_OPTS="$RESOLV_OPTS -d $CISCO_DEF_DOMAIN"
test -n "$RESOLV_OPTS" && eval /sbin/modify_resolvconf modify -s vpnc -p $SCRIPTNAME -f $FULL_SCRIPTNAME -e $TUNDEV $RESOLV_OPTS -t \"This file was created by $SCRIPTNAME\"
}

# Restore resolv.conf to old contents on Suse
restore_resolvconf_suse()
{
FULL_SCRIPTNAME=`readlink -f $0`
/sbin/modify_resolvconf restore -s vpnc -p $SCRIPTNAME -f $FULL_SCRIPTNAME -e $TUNDEV
}

# === resolv.conf handling via UCI (OpenWRT) =========

modify_resolvconf_openwrt() {
add_dns $OPENWRT_INTERFACE $INTERNAL_IP4_DNS
}

restore_resolvconf_openwrt() {
remove_dns $OPENWRT_INTERFACE
}
# === resolv.conf handling via /sbin/resolvconf (Debian, Ubuntu, Gentoo)) =========

modify_resolvconf_manager() {
NEW_RESOLVCONF=""
for i in $INTERNAL_IP4_DNS; do
NEW_RESOLVCONF="$NEW_RESOLVCONF
nameserver $i"
done
if [ -n "$CISCO_DEF_DOMAIN" ]; then
NEW_RESOLVCONF="$NEW_RESOLVCONF
domain $CISCO_DEF_DOMAIN"
fi
echo "$NEW_RESOLVCONF" | /sbin/resolvconf -a $TUNDEV
}

restore_resolvconf_manager() {
/sbin/resolvconf -d $TUNDEV
}

# === resolv.conf handling via unbound =========

modify_resolvconf_unbound() {
if [ -n "$CISCO_DEF_DOMAIN" ]; then
/usr/sbin/unbound-control forward_add +i ${CISCO_DEF_DOMAIN} ${INTERNAL_IP4_DNS}
/usr/sbin/unbound-control flush_requestlist
/usr/sbin/unbound-control flush_zone ${CISCO_DEF_DOMAIN}
fi
}

restore_resolvconf_unbound() {
if [ -n "$CISCO_DEF_DOMAIN" ]; then
/usr/sbin/unbound-control forward_remove +i ${CISCO_DEF_DOMAIN}
/usr/sbin/unbound-control flush_zone ${CISCO_DEF_DOMAIN}
/usr/sbin/unbound-control flush_requestlist
fi
}

# ========= Toplevel state handling =======================================

kernel_is_2_6_or_above() {
case `uname -r` in
1.*|2.[012345]*)
return 1
;;
*)
return 0
;;
esac
}

do_pre_init() {
if [ "$OS" = "Linux" ]; then
if (exec 6<> /dev/net/tun) > /dev/null 2>&1 ; then
:
else # can't open /dev/net/tun
test -e /proc/sys/kernel/modprobe && `cat /proc/sys/kernel/modprobe` tun 2>/dev/null
# fix for broken devfs in kernel 2.6.x
if [ "`readlink /dev/net/tun`" = misc/net/tun \
-a ! -e /dev/net/misc/net/tun -a -e /dev/misc/net/tun ] ; then
ln -sf /dev/misc/net/tun /dev/net/tun
fi
# make sure tun device exists
if [ ! -e /dev/net/tun ]; then
mkdir -p /dev/net
mknod -m 0640 /dev/net/tun c 10 200
[ -x /sbin/restorecon ] && /sbin/restorecon /dev/net/tun
fi
# workaround for a possible latency caused by udev, sleep max. 10s
if kernel_is_2_6_or_above ; then
for x in `seq 100` ; do
(exec 6<> /dev/net/tun) > /dev/null 2>&1 && break;
sleep 0.1
done
fi
fi
elif [ "$OS" = "FreeBSD" ]; then
if ! kldstat -q -m if_tun > /dev/null; then
kldload if_tun
fi

if ! ifconfig $TUNDEV > /dev/null; then
ifconfig $TUNDEV create
fi
elif [ "$OS" = "GNU/kFreeBSD" ]; then
if [ ! -e /dev/tun ]; then
kldload if_tun
fi
elif [ "$OS" = "NetBSD" ]; then
:
elif [ "$OS" = "OpenBSD" ]; then
if ! ifconfig $TUNDEV > /dev/null; then
ifconfig $TUNDEV create
fi
:
elif [ "$OS" = "SunOS" ]; then
:
elif [ "$OS" = "Darwin" ]; then
:
fi
}

do_connect() {
if [ -n "$CISCO_BANNER" ]; then
echo "Connect Banner:"
echo "$CISCO_BANNER" | while read LINE ; do echo "|" "$LINE" ; done
echo
fi

set_vpngateway_route
do_ifconfig
if [ -n "$CISCO_SPLIT_INC" ]; then
i=0
while [ $i -lt $CISCO_SPLIT_INC ] ; do
eval NETWORK="\${CISCO_SPLIT_INC_${i}_ADDR}"
eval NETMASK="\${CISCO_SPLIT_INC_${i}_MASK}"
eval NETMASKLEN="\${CISCO_SPLIT_INC_${i}_MASKLEN}"
if [ "$NETWORK" != "0.0.0.0" ]; then
set_network_route "$NETWORK" "$NETMASK" "$NETMASKLEN"
else
set_default_route
fi
i=`expr $i + 1`
done
for i in $INTERNAL_IP4_DNS ; do
echo "$i" | grep : >/dev/null || \
set_network_route "$i" "255.255.255.255" "32"
done
elif [ -n "$INTERNAL_IP4_ADDRESS" ]; then
set_default_route
fi
if [ -n "$CISCO_IPV6_SPLIT_INC" ]; then
i=0
while [ $i -lt $CISCO_IPV6_SPLIT_INC ] ; do
eval NETWORK="\${CISCO_IPV6_SPLIT_INC_${i}_ADDR}"
eval NETMASKLEN="\${CISCO_IPV6_SPLIT_INC_${i}_MASKLEN}"
if [ $NETMASKLEN -lt 128 ]; then
set_ipv6_network_route "$NETWORK" "$NETMASKLEN"
else
set_ipv6_default_route
fi
i=`expr $i + 1`
done
for i in $INTERNAL_IP4_DNS ; do
if echo "$i" | grep : >/dev/null; then
set_ipv6_network_route "$i" "128"
fi
done
elif [ -n "$INTERNAL_IP6_NETMASK" -o -n "$INTERNAL_IP6_ADDRESS" ]; then
set_ipv6_default_route
fi

if [ -n "$INTERNAL_IP4_DNS" ]; then
$MODIFYRESOLVCONF
fi
}

do_disconnect() {
if [ -n "$CISCO_SPLIT_INC" ]; then
i=0
while [ $i -lt $CISCO_SPLIT_INC ] ; do
eval NETWORK="\${CISCO_SPLIT_INC_${i}_ADDR}"
eval NETMASK="\${CISCO_SPLIT_INC_${i}_MASK}"
eval NETMASKLEN="\${CISCO_SPLIT_INC_${i}_MASKLEN}"
if [ "$NETWORK" != "0.0.0.0" ]; then
# FIXME: This doesn't restore previously overwritten
# routes.
del_network_route "$NETWORK" "$NETMASK" "$NETMASKLEN"
else
reset_default_route
fi
i=`expr $i + 1`
done
for i in $INTERNAL_IP4_DNS ; do
del_network_route "$i" "255.255.255.255" "32"
done
else
reset_default_route
fi
if [ -n "$CISCO_IPV6_SPLIT_INC" ]; then
i=0
while [ $i -lt $CISCO_IPV6_SPLIT_INC ] ; do
eval NETWORK="\${CISCO_IPV6_SPLIT_INC_${i}_ADDR}"
eval NETMASKLEN="\${CISCO_IPV6_SPLIT_INC_${i}_MASKLEN}"
if [ $NETMASKLEN -eq 0 ]; then
reset_ipv6_default_route
else
del_ipv6_network_route "$NETWORK" "$NETMASKLEN"
fi
i=`expr $i + 1`
done
for i in $INTERNAL_IP6_DNS ; do
del_ipv6_network_route "$i" "128"
done
elif [ -n "$INTERNAL_IP6_NETMASK" -o -n "$INTERNAL_IP6_ADDRESS" ]; then
reset_ipv6_default_route
fi

del_vpngateway_route

if [ -n "$INTERNAL_IP4_DNS" ]; then
$RESTORERESOLVCONF
fi


if [ -n "$IPROUTE" ]; then
if [ -n "$INTERNAL_IP4_ADDRESS" ]; then
$IPROUTE addr del "$INTERNAL_IP4_ADDRESS/255.255.255.255" peer "$INTERNAL_IP4_ADDRESS" dev "$TUNDEV"
fi
# If the netmask is provided, it contains the address _and_ netmask
if [ -n "$INTERNAL_IP6_ADDRESS" ] && [ -z "$INTERNAL_IP6_NETMASK" ]; then
INTERNAL_IP6_NETMASK="$INTERNAL_IP6_ADDRESS/128"
fi
if [ -n "$INTERNAL_IP6_NETMASK" ]; then
$IPROUTE -6 addr del $INTERNAL_IP6_NETMASK dev $TUNDEV
fi
else
if [ -n "$INTERNAL_IP4_ADDRESS" ]; then
ifconfig "$TUNDEV" 0.0.0.0
fi
if [ -n "$INTERNAL_IP6_ADDRESS" ] && [ -z "$INTERNAL_IP6_NETMASK" ]; then
INTERNAL_IP6_NETMASK="$INTERNAL_IP6_ADDRESS/128"
fi
if [ -n "$INTERNAL_IP6_NETMASK" ]; then
ifconfig "$TUNDEV" inet6 del $INTERNAL_IP6_NETMASK
fi
fi

destroy_tun_device
}

#### Main

if [ -z "$reason" ]; then
echo "this script must be called from vpnc" 1>&2
exit 1
fi

case "$reason" in
pre-init)
run_hooks pre-init
do_pre_init
;;
connect)
run_hooks connect
do_connect
run_hooks post-connect
;;
disconnect)
run_hooks disconnect
do_disconnect
run_hooks post-disconnect
;;
reconnect)
run_hooks reconnect
;;
*)
echo "unknown reason '$reason'. Maybe vpnc-script is out of date" 1>&2
exit 1
;;
esac

exit 0

+ 0
- 5
zsh/.zprofile View File

@@ -8,11 +8,6 @@ export BROWSER="$HOME/.config/Scripts/linkhandler"
export TRUEBROWSER="qutebrowser"
export ALTBROWSER="firefox"

export I3BLOCKS_LAYOUT="pkill -SIGRTMIN+10 i3blocks"
export I3BLOCKS_VOLUME="pkill -SIGRTMIN+11 i3blocks"
export I3BLOCKS_POWERSAVER="pkill -SIGRTMIN+12 i3blocks"
export I3BLOCKS_MAIL="pkill -SIGRTMIN+13 i3blocks"

PATH="$PATH:$HOME/.config/Scripts/:$HOME/.gem/ruby/2.5.0/bin:$HOME/go/bin:$HOME/.local/bin"

export DEFAULT_USER="micah"


Loading…
Cancel
Save