Compare commits
106 Commits
newi3
...
be733bbcba
| Author | SHA1 | Date | |
|---|---|---|---|
| be733bbcba | |||
| 5b02e1ea77 | |||
| 86e49d6b74 | |||
| 2f6fb5e0d1 | |||
| 086a75b054 | |||
| 8f52441c54 | |||
| 964c1f3f85 | |||
| 22617db376 | |||
| bc0ff2b3ea | |||
| 959c9228c5 | |||
| 8aad68fd7c | |||
| 0af0672f3e | |||
| 564500c5b2 | |||
| 9f4c76a0a3 | |||
| 689289c410 | |||
| ea1dee10d0 | |||
| ef68cae1c0 | |||
| e698ad9319 | |||
| b86e7df6f7 | |||
| 7cf33dc7a3 | |||
| 0f8362fb68 | |||
| 1b0c9b6e6a | |||
| c70ddcf2a2 | |||
| c379d8e714 | |||
| e8e1dc77fe | |||
| 4c1daf109d | |||
| 79cae3e93b | |||
| a9f4901e25 | |||
| 55a06db3fe | |||
| 84afe0a158 | |||
| 7e2832532f | |||
| 6e9996f0de | |||
| 1e5594721c | |||
| 40fc4b6e0c | |||
| c85812479d | |||
| f0fc5d1d88 | |||
| ca6b02e14b | |||
| 3abb253457 | |||
| 740729834a | |||
| b37976611b | |||
| 6f6dd21aaf | |||
| 6b5912091c | |||
| bd00a604bd | |||
| 380cb65dff | |||
| ef6bd41684 | |||
| 6889b32037 | |||
| fb4fe04c12 | |||
| 7087d7c876 | |||
| 593fc07c77 | |||
| 295f5b95a2 | |||
| 809d0eb37e | |||
| 4e0bd16800 | |||
| 129748fd8c | |||
| 73c948b25c | |||
| f41b947fc5 | |||
| 5aee564810 | |||
| 7b43075070 | |||
| adef40b760 | |||
| 49b3e061e0 | |||
| 94129da2ed | |||
| d5422a0695 | |||
| e6dc178e4d | |||
| b21211fc2b | |||
| b09891fd04 | |||
| 4d8e0d1f97 | |||
| f0fa3d9c06 | |||
| 179f9d96b2 | |||
| 39add5548b | |||
| 1dacfd4c3f | |||
| 07f006c37d | |||
| 0f7d4db0a3 | |||
|
|
827870bc01 | ||
|
|
c63af798fe | ||
|
|
a57aa206aa | ||
|
|
3ad338dbe4 | ||
|
|
c4e760d5e7 | ||
|
|
5195ae47bc | ||
| 5d1b35f18a | |||
|
|
0609c7cdc9 | ||
|
|
2b0de46869 | ||
|
|
5a882d1fae | ||
| 0359fac5bd | |||
| 05ece594ad | |||
| c6f48faff0 | |||
| 1367be34be | |||
| b8bf0c0f61 | |||
|
|
fb73f5342d | ||
|
|
106f9fe47f | ||
|
|
9097a98884 | ||
|
|
9f5078611c | ||
|
|
a86415f264 | ||
|
|
2f31eef54b | ||
| 14c346d8b1 | |||
| f31e3dd7dc | |||
| 8442b2b154 | |||
|
|
98cfe87cad | ||
|
|
73b7a7561a | ||
| e8420af927 | |||
| 88daa7e088 | |||
|
|
cc817e998f | ||
| c0d719ab78 | |||
| f3d47aaa31 | |||
| 6e86609086 | |||
| 481b19c5ce | |||
| 31c86dda7d | |||
| 84381b084a |
147
.bash_prompt.kuba
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
format_modified_detailed() {
|
||||||
|
local txtrst='\e[m'
|
||||||
|
local txtred='\e[0;31m'
|
||||||
|
local txtgrn='\e[0;32m'
|
||||||
|
local txtyel='\e[0;33m'
|
||||||
|
|
||||||
|
# Modified, staged and untracked
|
||||||
|
# A added (new file) M modified, D deleted, R renamed, T typechange
|
||||||
|
stat="$(git status --porcelain 2>/dev/null)"
|
||||||
|
n_sta=""
|
||||||
|
n_mod=""
|
||||||
|
for i in A M D R T; do
|
||||||
|
c=$(echo "$stat" | grep "^[$i]" | wc -l)
|
||||||
|
[ "$c" != "0" ] && n_sta="$n_sta$i$c"
|
||||||
|
c=$(echo "$stat" | grep "^ [$i]" | wc -l)
|
||||||
|
[ "$c" != "0" ] && n_mod="$n_mod$i$c"
|
||||||
|
done
|
||||||
|
n_unt=$(echo "$stat" | grep "??" | wc -l)
|
||||||
|
|
||||||
|
out=""
|
||||||
|
[ ! -z "$n_sta" ] && out+="\[$txtgrn\]+$n_sta\[$txtrst\]"
|
||||||
|
[ ! -z "$n_mod" ] && out+="\[$txtred\]*$n_mod\[$txtrst\]"
|
||||||
|
[ ! -z "$n_unt" ] && out+="\[$txtyel\]^$n_unt\[$txtrst\]"
|
||||||
|
echo "$out"
|
||||||
|
}
|
||||||
|
|
||||||
|
format_modified() {
|
||||||
|
local txtrst='\e[m'
|
||||||
|
local txtred='\e[0;31m'
|
||||||
|
local txtgrn='\e[0;32m'
|
||||||
|
local txtyel='\e[0;33m'
|
||||||
|
|
||||||
|
# Modified, staged and untracked
|
||||||
|
# A added (new file) M modified, D deleted, R renamed, T typechange
|
||||||
|
stat="$(git status --porcelain 2>/dev/null)"
|
||||||
|
n_sta=$(echo "$stat" | grep "^[AMDRT]" | wc -l)
|
||||||
|
n_mod=$(echo "$stat" | grep "^ [AMDRT]" | wc -l)
|
||||||
|
n_unt=$(echo "$stat" | grep "??" | wc -l)
|
||||||
|
|
||||||
|
out=""
|
||||||
|
[ "$n_sta" != 0 ] && out+="\[$txtgrn\]+$n_sta\[$txtrst\]"
|
||||||
|
[ "$n_mod" != 0 ] && out+="\[$txtred\]*$n_mod\[$txtrst\]"
|
||||||
|
[ "$n_unt" != 0 ] && out+="\[$txtyel\]^$n_unt\[$txtrst\]"
|
||||||
|
echo "$out"
|
||||||
|
}
|
||||||
|
|
||||||
|
set_prompt_fancy()
|
||||||
|
{
|
||||||
|
local is_git="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
|
||||||
|
|
||||||
|
local last_cmd=$?
|
||||||
|
local txtrst='\e[m'
|
||||||
|
local txtbold='\e[1m'
|
||||||
|
local txtblk='\e[30m'
|
||||||
|
local txtred='\e[31m'
|
||||||
|
local txtgrn='\e[32m'
|
||||||
|
local txtyel='\e[33m'
|
||||||
|
local txtblu='\e[34m'
|
||||||
|
local txtpur='\e[35m'
|
||||||
|
local txtcyn='\e[36m'
|
||||||
|
local txtwht='\e[37m'
|
||||||
|
# unicode "✗"
|
||||||
|
local fancyx='\342\234\227'
|
||||||
|
# unicode "✓"
|
||||||
|
local checkmark='\342\234\223'
|
||||||
|
# Line 1: Full date + full time (24h)
|
||||||
|
# Line 2: current path
|
||||||
|
PS1="\[$txtbold\]\[$txtwht\]\n\D{%A %d %B %Y %H:%M:%S}\n\[$txtgrn\]\w\n"
|
||||||
|
# Line 3: Git repo + path in repo
|
||||||
|
if [ "$is_git" ]; then
|
||||||
|
local git_repo=$(basename `git rev-parse --show-toplevel` 2>/dev/null)
|
||||||
|
local git_rel_path=$(git rev-parse --show-prefix 2>/dev/null)
|
||||||
|
PS1+="$txtcyn$git_repo $txtpur$git_rel_path$txtrst\n"
|
||||||
|
fi
|
||||||
|
# User color: red for root, yel for others
|
||||||
|
if [[ $EUID == 0 ]]; then
|
||||||
|
PS1+="\[$txtred\]"
|
||||||
|
else
|
||||||
|
PS1+="\[$txtyel\]"
|
||||||
|
fi
|
||||||
|
# Line 3: user@host
|
||||||
|
PS1+="\u\[$txtwht\]@\h\n"
|
||||||
|
# Line 4: a red "✗" or a grn "✓" and the error number
|
||||||
|
if [[ $last_cmd == 0 ]]; then
|
||||||
|
PS1+="\[$txtgrn\]$checkmark \[$txtwht\](0)"
|
||||||
|
else
|
||||||
|
PS1+="\[$txtred\]$fancyx \[$txtwht\]($last_cmd)"
|
||||||
|
fi
|
||||||
|
# Line 4: grn git branch
|
||||||
|
PS1+="\[$txtgrn\]$(__git_ps1 '(%s')\[$txtwht\]"
|
||||||
|
PS1+="$(format_modified_detailed)\[$txtgrn\])\[$txtrst\] "
|
||||||
|
# Line 4: good old prompt, $ for user, # for root
|
||||||
|
PS1+=" \\$ "
|
||||||
|
}
|
||||||
|
|
||||||
|
set_prompt()
|
||||||
|
{
|
||||||
|
local is_git="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
|
||||||
|
|
||||||
|
local txtrst='\e[m'
|
||||||
|
local txtbold='\e[1m'
|
||||||
|
local txtblk='\e[30m'
|
||||||
|
local txtred='\e[31m'
|
||||||
|
local txtgrn='\e[32m'
|
||||||
|
local txtyel='\e[33m'
|
||||||
|
local txtblu='\e[34m'
|
||||||
|
local txtpur='\e[35m'
|
||||||
|
local txtcyn='\e[36m'
|
||||||
|
local txtwht='\e[37m'
|
||||||
|
|
||||||
|
# User color: red for root, yel for others
|
||||||
|
if [[ $EUID == 0 ]]; then
|
||||||
|
PS1+="\[$txtred\]"
|
||||||
|
else
|
||||||
|
PS1+="\[$txtyel\]"
|
||||||
|
fi
|
||||||
|
# user@host
|
||||||
|
PS1="\u\[$txtwht\]@\h"
|
||||||
|
# Git repo + path in repo
|
||||||
|
if [ "$is_git" ]; then
|
||||||
|
local git_repo=$(basename `git rev-parse --show-toplevel` 2>/dev/null)
|
||||||
|
local git_rel_path=$(git rev-parse --show-prefix 2>/dev/null)
|
||||||
|
PS1+="\[$txtcyn\][$git_repo] \[$txtpur\]$git_rel_path\[$txtrst\]"
|
||||||
|
# Green git branch
|
||||||
|
PS1+="\[$txtgrn\]$(__git_ps1 '(%s')\[$txtwht\]"
|
||||||
|
PS1+="$(format_modified)\[$txtgrn\])\[$txtrst\] "
|
||||||
|
else
|
||||||
|
# Current path
|
||||||
|
PS1+="\[$txtgrn\]\w "
|
||||||
|
fi
|
||||||
|
# Good old prompt, $ for user, # for root
|
||||||
|
PS1+="\[$txtrst\]\\$ "
|
||||||
|
}
|
||||||
|
|
||||||
|
f() {
|
||||||
|
case $PROMPT_COMMAND in
|
||||||
|
set_prompt )
|
||||||
|
export PROMPT_COMMAND='set_prompt_fancy'
|
||||||
|
;;
|
||||||
|
set_prompt_fancy )
|
||||||
|
export PROMPT_COMMAND='set_prompt'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
export PROMPT_COMMAND='set_prompt'
|
||||||
103
.bashrc.kuba
@@ -4,17 +4,102 @@
|
|||||||
|
|
||||||
# If not running interactively, don't do anything
|
# If not running interactively, don't do anything
|
||||||
[[ $- != *i* ]] && return
|
[[ $- != *i* ]] && return
|
||||||
alias ls='ls --color=auto'
|
|
||||||
PS1='[\u@\h \W]\$ '
|
# Convenient helper function
|
||||||
|
source_existing() {
|
||||||
|
[ -f "$1" ] && source "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
export LC_ALL=en_US.UTF-8
|
||||||
|
export LANG=en_US.UTF-8
|
||||||
|
|
||||||
|
export KRB5_CONFIG=".etcfiles/krb5.conf"
|
||||||
export EDITOR="vim"
|
export EDITOR="vim"
|
||||||
export CUPS_GSSSERVICENAME=HTTP
|
export OMPI_MCA_opal_cuda_support=0
|
||||||
export PATH=$PATH:/home/kuba/bin
|
|
||||||
export PATH="$HOME/git/esp-open-sdk/xtensa-lx106-elf/bin/:$PATH"
|
|
||||||
|
|
||||||
alias dotfiles="/usr/bin/git --git-dir=$HOME/.dotfiles.git --work-tree=$HOME"
|
alias dotfiles="/usr/bin/git --git-dir=$HOME/.dotfiles.git --work-tree=$HOME"
|
||||||
alias dvim="GIT_WORK_TREE='/home/kuba' GIT_DIR='/home/kuba/.dotfiles.git/' vim"
|
alias dvim="GIT_WORK_TREE='/home/kuba' GIT_DIR='/home/kuba/.dotfiles.git/' vim"
|
||||||
|
|
||||||
if xhost >& /dev/null ; then
|
alias ls='ls --color=auto'
|
||||||
# X is running
|
|
||||||
xhost +local:kuba > /dev/null
|
source_existing /usr/share/bash-completion/bash_completion
|
||||||
fi
|
# Make tab-completion work for dotfiles exactly as for git
|
||||||
|
# First we need to load the completion for git (this is done the first time
|
||||||
|
# one types `git <TAB>` in the console).
|
||||||
|
_completion_loader git
|
||||||
|
# Running `complete -p git` yields the following
|
||||||
|
# complete -o bashdefault -o default -o nospace -F __git_wrap__git_main git
|
||||||
|
# So we do
|
||||||
|
complete -o bashdefault -o default -o nospace -F __git_wrap__git_main dotfiles
|
||||||
|
|
||||||
|
# Define a OS X-like open command
|
||||||
|
open() { command xdg-open "$@" > /dev/null 2>&1 & }
|
||||||
|
|
||||||
|
# Inspect .npz files
|
||||||
|
npz_py_str="$(cat << EOM
|
||||||
|
from sys import argv
|
||||||
|
import numpy as np
|
||||||
|
try:
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
print('Imported matplotlib.pyplot as plt')
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Wrap:
|
||||||
|
def __init__(self, fname):
|
||||||
|
n = np.load(fname, allow_pickle=True)
|
||||||
|
files = n.files
|
||||||
|
globs = globals()
|
||||||
|
print('Contains files', files)
|
||||||
|
for f in files:
|
||||||
|
setattr(self, f, n[f])
|
||||||
|
globs[f] = n[f]
|
||||||
|
|
||||||
|
archive = Wrap(argv[1])
|
||||||
|
print('Global namespace populated with "archive" and all files')
|
||||||
|
EOM
|
||||||
|
)"
|
||||||
|
|
||||||
|
npz_preview() {
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
echo "Please specify file to open as argument"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
python -ic "$npz_py_str" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source git prompt
|
||||||
|
source_existing ~/scripts/git-prompt.sh
|
||||||
|
source_existing ~/.bash_prompt.kuba
|
||||||
|
|
||||||
|
# Activate python virtualenv
|
||||||
|
source_existing ~/.python-venv.kuba/bin/activate
|
||||||
|
|
||||||
|
# Source lmod module setup
|
||||||
|
source_existing /usr/share/lmod/lmod/init/profile
|
||||||
|
|
||||||
|
complete -o default -C "python ~/.python-venv.kuba/lib/python3.9/site-packages/myqueue/complete.py" mq
|
||||||
|
complete -o bashdefault -C snakemake-bash-completion snakemake
|
||||||
|
|
||||||
|
case $(hostname) in
|
||||||
|
vera* )
|
||||||
|
module use "$HOME/.modules.kuba/"
|
||||||
|
module load iccifort/2019.5.281
|
||||||
|
module load impi/2018.5.288
|
||||||
|
module load imkl/2019.5.281
|
||||||
|
module load Python/3.7.4
|
||||||
|
module load clusterappl
|
||||||
|
module load slurm-aliases
|
||||||
|
;;
|
||||||
|
tetralith* )
|
||||||
|
module use "$HOME/.modules.kuba/"
|
||||||
|
module load Python/3.6.3-anaconda-5.0.1-nsc1
|
||||||
|
module load clusterappl
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
if [ -e /usr/share/lmod/lmod/init/profile ]; then
|
||||||
|
module use "$HOME/.modules.kuba/"
|
||||||
|
module use "$HOME/git/auto-venv-setup/lmod-modules/"
|
||||||
|
fi
|
||||||
|
esac
|
||||||
|
|||||||
3
.config/nvim/init.vim
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
set runtimepath^=~/.vim runtimepath+=~/.vim/after
|
||||||
|
let &packpath=&runtimepath
|
||||||
|
source ~/.vimrc
|
||||||
12
.config/okularpartrc
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[$Version]
|
||||||
|
update_info=okular.upd:annotation-toolbar,okular.upd:builtin-annotations
|
||||||
|
|
||||||
|
[Identity]
|
||||||
|
IdentityAuthor=Jakub Fojt
|
||||||
|
|
||||||
|
[Main View]
|
||||||
|
SplitterSizes=145,719
|
||||||
|
|
||||||
|
[Reviews]
|
||||||
|
BuiltinAnnotationTools=<tool name="Yellow Highlighter" type="highlight" id="1"><engine type="TextSelector" color="#fff9f06b"><annotation type="Highlight" opacity="0.5" color="#fff9f06b"/></engine><shortcut>2</shortcut></tool>,<tool type="underline" id="2"><engine type="TextSelector" color="#ff0000"><annotation type="Underline" color="#ffff0000"/></engine></tool>,<tool type="squiggly" id="3"><engine type="TextSelector" color="#ff0000"><annotation type="Squiggly" color="#ffff0000"/></engine></tool>,<tool type="strikeout" id="4"><engine type="TextSelector" color="#ff0000"><annotation type="StrikeOut" color="#ffff0000"/></engine></tool>,<tool name="Totalpoäng" type="typewriter" id="5"><engine type="PickPoint" block="true"><annotation textColor="#1a5fb4" type="Typewriter" color="#00ffffff" width="0" font="Cantarell\\,26\\,-1\\,5\\,50\\,0\\,0\\,0\\,0\\,0"/></engine></tool>,<tool type="note-inline" id="6"><engine hoverIcon="tool-note-inline" type="PickPoint" block="true" color="#ffff00"><annotation textColor="#ff000000" type="FreeText" color="#ffffff00"/></engine></tool>,<tool name="Yellow popup note" type="note-linked" id="7"><engine hoverIcon="tool-note" type="PickPoint" color="#fff9f06b"><annotation icon="Comment" type="Text" color="#fff9f06b"/></engine><shortcut>8</shortcut></tool>,<tool type="ink" id="8"><engine type="SmoothLine" color="#00ff00"><annotation type="Ink" color="#ff00ff00" width="2"/></engine></tool>,<tool name="Arrow" type="straight-line" id="9"><engine type="PolyLine" color="#000000" points="2"><annotation type="Line" endStyle="3" color="#ff000000" width="2"/></engine></tool>,<tool type="straight-line" id="10"><engine type="PolyLine" color="#000000" points="2"><annotation type="Line" color="#ff000000" width="2"/></engine></tool>,<tool name="Yellow transparent fill" type="rectangle" id="11"><engine type="PickPoint" block="true" color="#fff9f06b"><annotation type="GeomSquare" opacity="0.5" color="#fff9f06b" innerColor="#f9f06b" width="5"/></engine><shortcut>5</shortcut></tool>,<tool name="Green transparent fill" type="ellipse" id="12"><engine type="PickPoint" block="true" color="#ff33d17a"><annotation type="GeomCircle" opacity="0.5" color="#ff33d17a" innerColor="#33d17a" width="5"/></engine><shortcut>6</shortcut></tool>,<tool type="polygon" id="13"><engine type="PolyLine" color="#007eee" points="-1"><annotation type="Line" color="#ff007eee" width="2"/></engine></tool>,<tool type="stamp" id="14"><engine hoverIcon="Sold" type="PickPoint" block="true" size="64"><annotation icon="Sold" type="Stamp"/></engine></tool>
|
||||||
|
QuickAnnotationTools=<tool id="1" name="Red highlighter" type="highlight"><engine type="TextSelector" color="#fff66151"><annotation opacity="0.5" type="Highlight" color="#fff66151"/></engine><shortcut>1</shortcut></tool>,<tool id="2" name="Yellow Highlighter" type="highlight"><engine type="TextSelector" color="#fff9f06b"><annotation opacity="0.5" type="Highlight" color="#fff9f06b"/></engine><shortcut>2</shortcut></tool>,<tool id="3" name="Green Highlighter" type="highlight"><engine type="TextSelector" color="#ff8ff0a4"><annotation opacity="0.5" type="Highlight" color="#ff8ff0a4"/></engine><shortcut>3</shortcut></tool>,<tool id="4" name="Red transparent fill" type="rectangle"><engine block="true" type="PickPoint" color="#fff66151"><annotation width="5" innerColor="#f66151" opacity="0.5" type="GeomSquare" color="#fff66151"/></engine><shortcut>4</shortcut></tool>,<tool id="5" name="Yellow transparent fill" type="rectangle"><engine block="true" type="PickPoint" color="#fff9f06b"><annotation width="5" innerColor="#f9f06b" opacity="0.5" type="GeomSquare" color="#fff9f06b"/></engine><shortcut>5</shortcut></tool>,<tool id="6" name="Green transparent fill" type="rectangle"><engine block="true" type="PickPoint" color="#ff8ff0a4"><annotation width="5" innerColor="#8ff0a4" opacity="0.5" type="GeomSquare" color="#ff8ff0a4"/></engine><shortcut>6</shortcut></tool>,<tool id="7" name="Red popup note" type="note-linked"><engine hoverIcon="tool-note" type="PickPoint" color="#fff66151"><annotation icon="Comment" type="Text" color="#fff66151"/></engine><shortcut>7</shortcut></tool>,<tool id="8" name="Yellow popup note" type="note-linked"><engine hoverIcon="tool-note" type="PickPoint" color="#fff9f06b"><annotation icon="Comment" type="Text" color="#fff9f06b"/></engine><shortcut>8</shortcut></tool>,<tool id="9" name="Green pop-up note" type="note-linked"><engine hoverIcon="tool-note" type="PickPoint" color="#ff8ff0a4"><annotation icon="Comment" type="Text" color="#ff8ff0a4"/></engine><shortcut>9</shortcut></tool>,<tool id="10" type="note-inline"><engine hoverIcon="tool-note-inline" block="true" type="PickPoint" color="#ffff00"><annotation textColor="#ff000000" type="FreeText" color="#ffffff00"/></engine></tool>,<tool id="11" name="Insert Text" type="typewriter"><engine block="true" type="PickPoint"><annotation width="0" textColor="#000000" type="Typewriter" color="#00ffffff"/></engine></tool>,<tool id="12" name="Totalpoäng" type="typewriter"><engine block="true" type="PickPoint"><annotation width="0" textColor="#1a5fb4" type="Typewriter" font="Cantarell\\,26\\,-1\\,5\\,50\\,0\\,0\\,0\\,0\\,0" color="#00ffffff"/></engine></tool>,<tool id="13" type="underline"><engine type="TextSelector" color="#ff0000"><annotation type="Underline" color="#ffff0000"/></engine></tool>
|
||||||
12
.config/systemd/user/phonesim-modem.service
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Power on phonesim modem
|
||||||
|
After=phonesim.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/bin/bash %h/scripts/start-phonesim-modem.sh
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=yes
|
||||||
|
StandardOutput=journal
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
11
.config/systemd/user/phonesim.service
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Phonesim service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/phonesim -p 12345 /usr/share/phonesim/default.xml
|
||||||
|
Type=simple
|
||||||
|
RemainAfterExit=true
|
||||||
|
StandardOutput=journal
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
@@ -1,20 +1,12 @@
|
|||||||
[global_config]
|
[global_config]
|
||||||
title_inactive_bg_color = "#4C566A"
|
|
||||||
title_inactive_fg_color = "#D8DEE9"
|
|
||||||
title_receive_bg_color = "#8FBCBB"
|
|
||||||
title_receive_fg_color = "#2E3440"
|
|
||||||
title_transmit_bg_color = "#88C0D0"
|
|
||||||
title_transmit_fg_color = "#2E3440"
|
title_transmit_fg_color = "#2E3440"
|
||||||
|
title_transmit_bg_color = "#88C0D0"
|
||||||
|
title_receive_fg_color = "#2E3440"
|
||||||
|
title_receive_bg_color = "#8FBCBB"
|
||||||
|
title_inactive_fg_color = "#D8DEE9"
|
||||||
|
title_inactive_bg_color = "#4C566A"
|
||||||
|
always_split_with_profile = True
|
||||||
[keybindings]
|
[keybindings]
|
||||||
[layouts]
|
|
||||||
[[default]]
|
|
||||||
[[[child1]]]
|
|
||||||
parent = window0
|
|
||||||
type = Terminal
|
|
||||||
[[[window0]]]
|
|
||||||
parent = ""
|
|
||||||
type = Window
|
|
||||||
[plugins]
|
|
||||||
[profiles]
|
[profiles]
|
||||||
[[default]]
|
[[default]]
|
||||||
background_color = "#12204d"
|
background_color = "#12204d"
|
||||||
@@ -28,7 +20,16 @@
|
|||||||
cursor_color = "#D8DEE9"
|
cursor_color = "#D8DEE9"
|
||||||
font = Hack 11
|
font = Hack 11
|
||||||
foreground_color = "#d8dee9"
|
foreground_color = "#d8dee9"
|
||||||
palette = "#3b4252:#bf616a:#a3be8c:#ebcb8b:#81a1c1:#b48ead:#88c0d0:#e5e9f0:#4c566a:#bf616a:#a3be8c:#ebcb8b:#81a1c1:#b48ead:#8fbcbb:#eceff4"
|
|
||||||
scrollbar_position = hidden
|
|
||||||
show_titlebar = False
|
show_titlebar = False
|
||||||
|
scrollbar_position = hidden
|
||||||
|
palette = "#3b4252:#bf616a:#a3be8c:#ebcb8b:#81a1c1:#b48ead:#88c0d0:#e5e9f0:#4c566a:#bf616a:#a3be8c:#ebcb8b:#81a1c1:#b48ead:#8fbcbb:#eceff4"
|
||||||
use_system_font = False
|
use_system_font = False
|
||||||
|
[layouts]
|
||||||
|
[[default]]
|
||||||
|
[[[child1]]]
|
||||||
|
parent = window0
|
||||||
|
type = Terminal
|
||||||
|
[[[window0]]]
|
||||||
|
parent = ""
|
||||||
|
type = Window
|
||||||
|
[plugins]
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
conky.config = {
|
|
||||||
use_spacer='none',
|
|
||||||
use_xft=true,
|
|
||||||
font='DejaVu Sans:size=9',
|
|
||||||
text_buffer_size=2048,
|
|
||||||
update_interval=600.0,
|
|
||||||
total_run_times=0,
|
|
||||||
|
|
||||||
own_window=true,
|
|
||||||
own_window_transparent=true,
|
|
||||||
own_window_type='normal',
|
|
||||||
own_window_hints='undecorated,skip_taskbar,skip_pager',
|
|
||||||
own_window_class='Conky-arch',
|
|
||||||
own_window_argb_visual=true,
|
|
||||||
own_window_argb_value=0,
|
|
||||||
|
|
||||||
draw_shades=false,
|
|
||||||
draw_outline=false,
|
|
||||||
draw_borders=false,
|
|
||||||
stippled_borders=0,
|
|
||||||
double_buffer=true,
|
|
||||||
|
|
||||||
default_color='white',
|
|
||||||
default_shade_color='black',
|
|
||||||
--Minimum size of text area
|
|
||||||
maximum_width=1200 ,
|
|
||||||
minimum_width=1200 ,
|
|
||||||
|
|
||||||
--alignment=top_right,
|
|
||||||
--gap_x=20,
|
|
||||||
--gap_y=20,
|
|
||||||
|
|
||||||
no_buffers=true,
|
|
||||||
net_avg_samples=2,
|
|
||||||
|
|
||||||
override_utf8_locale=true,
|
|
||||||
|
|
||||||
use_spacer=none,
|
|
||||||
|
|
||||||
short_units=on,
|
|
||||||
|
|
||||||
color1 = '0099ff', -- Arch News
|
|
||||||
color2 = '0000ff', --Titles
|
|
||||||
color3 = '3a3a3a', --Dates
|
|
||||||
color4 = 'dddddd', --Code tag
|
|
||||||
default_outline_color='black',--'00ccee',
|
|
||||||
lua_load = '~/.conky/arch/lua.lua'
|
|
||||||
};
|
|
||||||
conky.text = [[
|
|
||||||
${color1}${font DejaVu Sans:normal:size=24}${alignc}Arch-news
|
|
||||||
${lua_parse conky_print}
|
|
||||||
]];
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
${alignr}${font DejaVu Sans:size=8}Retrieved: 09/14/2018
|
|
||||||
${color2}${font DejaVu Sans:size=12}libutf8proc>=2.1.1-3 update requires manual intervention
|
|
||||||
${color}${font}The libutf8proc package prior to version 2.1.1-3 had an incorrect soname link. This has been fixed in 2.1.1-3, so the upgrade will need to overwrite the untracked soname link created by ldconfig. If
|
|
||||||
you get an error
|
|
||||||
|
|
||||||
${color4}${font DejaVu Sans:italic:size=9}libutf8proc: /usr/lib/libutf8proc.so.2 exists in filesystem${color}${font}
|
|
||||||
|
|
||||||
when updating, use
|
|
||||||
|
|
||||||
${color4}${font DejaVu Sans:italic:size=9}pacman -Suy --overwrite usr/lib/libutf8proc.so.2${color}${font}
|
|
||||||
|
|
||||||
to perform the upgrade.${color3}${font DejaVu Sans:size=8}${alignr} Uppdated: 07/14/2018
|
|
||||||
|
|
||||||
${color2}${font DejaVu Sans:size=12}js52 52.7.3-2 upgrade requires intervention
|
|
||||||
${color}${font}Due to the SONAME of ${color4}${font DejaVu Sans:italic:size=9}/usr/lib/libmozjs-52.so${color}${font} not matching its file name, ldconfig created an untracked file ${color4}${font DejaVu Sans:italic:size=9}/usr/lib/libmozjs-52.so.0${color}${font}. This is now fixed and both files are present in the package.
|
|
||||||
|
|
||||||
To pass the upgrade, remove ${color4}${font DejaVu Sans:italic:size=9}/usr/lib/libmozjs-52.so.0${color}${font} prior to upgrading.${color3}${font DejaVu Sans:size=8}${alignr} Uppdated: 05/04/2018
|
|
||||||
|
|
||||||
${color2}${font DejaVu Sans:size=12}glibc 2.27-2 and pam 1.3.0-2 may require manual intervention
|
|
||||||
${color}${font}The new version of glibc removes support for NIS and NIS+. The default ${color4}${font DejaVu Sans:italic:size=9}/etc/nsswitch.conf${color}${font} file provided by ${color4}${font DejaVu Sans:italic:size=9}filesystem${color}${font} package already reflects this change. Please make sure to merge pacnew file if it
|
|
||||||
exists prior to upgrade.
|
|
||||||
|
|
||||||
NIS functionality can still be enabled by installing ${color4}${font DejaVu Sans:italic:size=9}libnss_nis${color}${font} package. There is no replacement for NIS+ in the official repositories.
|
|
||||||
|
|
||||||
${color4}${font DejaVu Sans:italic:size=9}pam 1.3.0-2${color}${font} no longer ships pam_unix2 module and ${color4}${font DejaVu Sans:italic:size=9}pam_unix_*.so${color}${font} compatibility symlinks. Before upgrading, review PAM configuration files in the ${color4}${font DejaVu Sans:italic:size=9}/etc/pam.d${color}${font} directory and replace removed modules with ${color4}${font DejaVu Sans:italic:size=9}pam
|
|
||||||
_unix.so${color}${font}. Users of pam_unix2 should also reset their passwords after such change. Defaults provided by ${color4}${font DejaVu Sans:italic:size=9}pambase${color}${font} package do not need any modifications.${color3}${font DejaVu Sans:size=8}${alignr} Uppdated: 04/20/2018
|
|
||||||
|
|
||||||
${color2}${font DejaVu Sans:size=12}zita-resampler 1.6.0-1 -> 2 update requires manual intervention
|
|
||||||
${color}${font}The zita-resampler 1.6.0-1 package was missing a library symlink that has been readded in 1.6.0-2. If you installed 1.6.0-1, ldconfig would have created this symlink at install time, and it will
|
|
||||||
conflict with the one included in 1.6.0-2. In that case, remove /usr/lib/libzita-resampler.so.1 manually before updating.${color3}${font DejaVu Sans:size=8}${alignr} Uppdated: 02/22/2018
|
|
||||||
|
|
||||||
${color2}${font DejaVu Sans:size=12} The end of i686 support
|
|
||||||
${color}${font}Following 9 months of deprecation period${color}${font}, support for the i686 architecture effectively ends today. By the end of November, i686 packages will be removed from our mirrors and later from the packages
|
|
||||||
archive. The [multilib] repository is not affected.
|
|
||||||
|
|
||||||
For users unable to upgrade their hardware to x86_64, an alternative is a community maintained fork named Arch Linux 32${color}${font}. See their website for details on migrating existing installations.${color3}${font DejaVu Sans:size=8}${alignr} Uppdated: 11/08/2017
|
|
||||||
|
|
||||||
${color2}${font DejaVu Sans:size=12}Perl library path change
|
|
||||||
${color}${font}The perl package now uses a versioned path for compiled modules. This means that modules built for a non-matching perl version will not be loaded any more and must be rebuilt.
|
|
||||||
|
|
||||||
A pacman hook warns about affected modules during the upgrade by showing output like this:
|
|
||||||
|
|
||||||
You must rebuild all affected packages against the new perl package before you can use them again. The change also affects modules installed directly via CPAN. Rebuilding will also be necessary again
|
|
||||||
with future major perl updates like 5.28 and 5.30.
|
|
||||||
|
|
||||||
Please note that rebuilding was already required for major updates prior to this change, however now perl will no longer try to load the modules and then fail in strange ways.
|
|
||||||
|
|
||||||
If the build system of some software does not detect the change automatically, you can use ${color4}${font DejaVu Sans:italic:size=9}perl -V:vendorarch${color}${font} in your PKGBUILD to query perl for the correct path. There is also ${color4}${font DejaVu Sans:italic:size=9}sitearch${color}${font} for software
|
|
||||||
that is not packaged with pacman.${color3}${font DejaVu Sans:size=8}${alignr} Uppdated: 09/02/2017
|
|
||||||
|
|
||||||
${color2}${font DejaVu Sans:size=12}Deprecation of ABS tool and rsync endpoint
|
|
||||||
${color}${font}Due to high maintenance cost of scripts related to the Arch Build System, we have decided to deprecate the ${color4}${font DejaVu Sans:italic:size=9}abs${color}${font} tool and thus rsync as a way of obtaining PKGBUILDs.
|
|
||||||
|
|
||||||
The ${color4}${font DejaVu Sans:italic:size=9}asp${color}${font} tool, available in [extra], provides similar functionality to ${color4}${font DejaVu Sans:italic:size=9}abs${color}${font}. ${color4}${font DejaVu Sans:italic:size=9}asp export pkgname${color}${font} can be used as direct alternative; more information about its usage can be found in the documentation${color}${font}.
|
|
||||||
Additionally Subversion sparse checkouts, as described here${color}${font}, can be used to achieve a similar effect. For fetching all PKGBUILDs, the best way is cloning the svntogit${color}${font} mirrors.
|
|
||||||
|
|
||||||
While the ${color4}${font DejaVu Sans:italic:size=9}extra/abs${color}${font} package has been already dropped, the rsync endpoint (rsync://rsync.archlinux.org/abs) will be disabled by the end of the month.${color3}${font DejaVu Sans:size=8}${alignr} Uppdated: 05/15/2017
|
|
||||||
|
|
||||||
${color2}${font DejaVu Sans:size=12}ca-certificates-utils 20170307-1 upgrade requires manual intervention
|
|
||||||
${color}${font}The upgrade to <strong>ca-certificates-utils 20170307-1${color}${font} requires manual intervention because a symlink which used to be generated post-install has been moved into the package proper.
|
|
||||||
|
|
||||||
As deleting the symlink may leave you unable to download packages, perform this upgrade in three steps:${color3}${font DejaVu Sans:size=8}${alignr} Uppdated: 03/15/2017
|
|
||||||
|
|
||||||
${color2}${font DejaVu Sans:size=12}mesa with libglvnd support is now in testing
|
|
||||||
${color}${font}${color4}${font DejaVu Sans:italic:size=9}mesa${color}${font}-17.0.0-3 can now be installed side-by-side with ${color4}${font DejaVu Sans:italic:size=9}nvidia${color}${font}-378.13 driver without any libgl/libglx hacks, and with the help of Fedora and upstream xorg-server patches.
|
|
||||||
|
|
||||||
First step was to remove the libglx symlinks with xorg-server-1.19.1-3 and associated mesa/nvidia drivers through the removal of various libgl packages. It was a tough moment because it was breaking
|
|
||||||
optimus system, ${color4}${font DejaVu Sans:italic:size=9}xorg-server${color}${font} configuration needs manual updating.
|
|
||||||
|
|
||||||
The second step is now here, with an updated 10-nvidia-drm-outputclass.conf${color}${font} file that should help to have an "out-of-the-box" working ${color4}${font DejaVu Sans:italic:size=9}xorg-server${color}${font} experience with optimus system.
|
|
||||||
|
|
||||||
Please test this extensively and post your feedback in this forum thread${color}${font} or in our bugtracker${color}${font}.${color3}${font DejaVu Sans:size=8}${alignr} Uppdated: 02/27/2017
|
|
||||||
|
|
||||||
${color2}${font DejaVu Sans:size=12}Phasing out i686 support
|
|
||||||
${color}${font}Due to the decreasing popularity of i686 among the developers and the community, we have decided to phase out the support of this architecture.
|
|
||||||
|
|
||||||
The decision means that February ISO will be the last that allows to install 32 bit Arch Linux. The next 9 months are deprecation period, during which i686 will be still receiving upgraded packages.
|
|
||||||
Starting from November 2017, packaging and repository tools will no longer require that from maintainers, effectively making i686 unsupported.
|
|
||||||
|
|
||||||
However, as there is still some interest in keeping i686 alive, we would like to encourage the community to make it happen with our guidance. The arch-ports${color}${font} mailing list and #archlinux-ports IRC
|
|
||||||
channel on Freenode will be used for further coordination.
|
|
||||||
|
|
||||||
The [multilib] repository will not be affected by this change.${color3}${font DejaVu Sans:size=8}${alignr} Uppdated: 01/25/2017
|
|
||||||
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Written by Peter Garceau
|
|
||||||
# Based on the RDF Feed Display Script by Hellf[i]re v0.1
|
|
||||||
#
|
|
||||||
# This script is designed for the Arch Linux News Feed.
|
|
||||||
#
|
|
||||||
# This script depends on curl.
|
|
||||||
# pacman -Sy curl
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# .conkyrc: ${execi [time] /path/to/script/conky-rss.sh}
|
|
||||||
#
|
|
||||||
# Usage Example
|
|
||||||
# ${execi 300 /home/youruser/scripts/conky-rss.sh}
|
|
||||||
|
|
||||||
#Try to download feed
|
|
||||||
RES=$(curl -fs https://www.archlinux.org/feeds/news/)
|
|
||||||
SUCCESS=$?
|
|
||||||
if [ $SUCCESS == 0 ]
|
|
||||||
then
|
|
||||||
echo $RES > ~/.conky/arch/cache
|
|
||||||
fi
|
|
||||||
|
|
||||||
#RSS Setup
|
|
||||||
LINES=4 #Number of headlines
|
|
||||||
|
|
||||||
FEED=$(cat ~/.conky/arch/cache)
|
|
||||||
|
|
||||||
if [ "$FEED" ]
|
|
||||||
then
|
|
||||||
IFS=$'\n'
|
|
||||||
TITLES=($(echo $FEED |
|
|
||||||
sed -e 's/></>\n</g' |
|
|
||||||
sed -n '/<title>/p'))
|
|
||||||
|
|
||||||
ITEMS=($(echo $FEED |
|
|
||||||
sed -e 's/<item>/\n<item>/g'))
|
|
||||||
|
|
||||||
unset IFS
|
|
||||||
|
|
||||||
OUTPUT='1'
|
|
||||||
i=1
|
|
||||||
while [ $i -le $LINES ]
|
|
||||||
do
|
|
||||||
OUTPUT+='\n'
|
|
||||||
OUTPUT+=$(echo ${TITLES[$i]} | sed -n '/<title>/p' | \
|
|
||||||
sed -e 's/<title>//' | sed -e 's/<\/title>//')
|
|
||||||
OUTPUT+='\n'
|
|
||||||
OUTPUT+=$(echo ${ITEMS[$i]} | sed -e 's/.*<pubDate>\(.*\)<\/pubDate>.*/\1/' | \
|
|
||||||
awk '{print $1 " " $2 " " $3}')
|
|
||||||
OUTPUT+='\n'
|
|
||||||
OUTPUT+=$(echo ${ITEMS[$i]} | sed -e 's/.*<description>\(.*\)<\/description>.*/\1/' | \
|
|
||||||
sed -e 's/<\/p> <p>/\n/g' | sed -e 's/<\/p>//g' | \
|
|
||||||
sed -e 's/<p>//g')
|
|
||||||
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
echo -e $OUTPUT
|
|
||||||
echo -e $OUTPUT | sed -e 's/</</g' | sed -e 's/>/>/g' | \
|
|
||||||
sed -e 's/<ul>/\\n/g' | sed -e 's/<\/ul>/\\n/g' | sed -e 's/<li>/\\n• /g' | sed -e 's/<\/li>//g' | \
|
|
||||||
sed -e 's/<a href=[^>]*>/\\3/g' | sed -e 's/<\/a>/\\d/g' | \
|
|
||||||
sed -e 's/<strong>/\\b/g' | sed -e 's/<\/strong>/\\r/g' | \
|
|
||||||
sed -e 's/<pre>//g' | sed -e 's/<\/pre>//g' | \
|
|
||||||
sed -e 's/<code>/\\i/g' | sed -e 's/<\/code>/\\r/g' \
|
|
||||||
> ~/.conky/arch/feed
|
|
||||||
fi
|
|
||||||
#Do not update anything if curl fails
|
|
||||||
@@ -1,174 +0,0 @@
|
|||||||
line_width = 200
|
|
||||||
lipsum = [[
|
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eget dolor a dui interdum rhoncus. Aenean congue nunc quis sem ultrices, vel fringilla tellus dignissim. Vivamus vitae purus ligula. Quisque ante elit, ultrices id aliquam a, porttitor quis risus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nunc elementum nisl nec efficitur mattis. Donec viverra tempor enim nec dictum. Suspendisse quam neque, posuere eu magna sit amet, rhoncus finibus risus. Phasellus tristique ac lacus eu ultricies. Quisque varius purus at eros rutrum hendrerit. Donec efficitur justo eu scelerisque mollis. Fusce dictum aliquam convallis. Phasellus eget nunc lacus. Nunc urna dui, tempor pharetra consectetur non, elementum sed purus. Phasellus consectetur quis libero et semper.
|
|
||||||
|
|
||||||
Pellentesque condimentum sem quis diam commodo convallis. Morbi et ligula sagittis, venenatis tortor ut, molestie dui. Nam egestas, purus eu efficitur mollis, ex neque convallis felis, at egestas nisi dolor sed enim. Pellentesque a felis facilisis orci dapibus porttitor. Aenean et viverra nulla, interdum eleifend neque. Nunc sem justo, vulputate et arcu eget, dignissim lobortis dui. Vivamus laoreet feugiat elit.
|
|
||||||
|
|
||||||
Fusce euismod nibh vitae orci gravida pretium. Quisque feugiat lacinia tortor eget sagittis. Morbi in mauris sit amet dui vehicula egestas. Curabitur sit amet facilisis lectus. Donec id turpis eleifend, hendrerit turpis eu, tristique velit. Curabitur pulvinar facilisis tincidunt. In hac habitasse platea dictumst. Donec convallis erat id neque pretium, non gravida felis imperdiet. Vivamus hendrerit, nunc id rutrum tristique, arcu leo auctor sapien, id fringilla mauris erat sed justo. Etiam pharetra quis enim sit amet imperdiet. Vestibulum condimentum massa vel ullamcorper malesuada. Duis libero eros, facilisis in suscipit in, varius id ipsum.
|
|
||||||
|
|
||||||
Donec in orci ac leo dapibus maximus sed eget tortor. Sed blandit eros lectus, et venenatis erat aliquam sed. Vestibulum risus ex, laoreet at malesuada non, egestas ut lacus. Quisque sed malesuada leo. Ut id ligula accumsan, commodo massa eget, porta mauris. Mauris a lectus ac tellus ornare aliquet quis at arcu. Curabitur nec sem sodales, mattis velit non, tempor arcu. Morbi sit amet maximus lacus, nec venenatis est. Curabitur et congue dui. Nullam lacinia augue non quam hendrerit facilisis.
|
|
||||||
|
|
||||||
Curabitur molestie mauris eget tempor mattis. Donec velit arcu, iaculis quis leo et, sodales venenatis erat. Maecenas in malesuada erat, vitae iaculis odio. Praesent id ultrices sem. In hac habitasse platea dictumst. In aliquet, nisl laoreet bibendum sodales, justo lacus aliquam mi, non elementum urna odio et nunc. Nulla interdum, ante in vestibulum pellentesque, nunc enim iaculis urna, eget convallis lectus ex sed tortor. Morbi suscipit malesuada felis at aliquam.
|
|
||||||
]]
|
|
||||||
text = [[
|
|
||||||
<p>
|
|
||||||
<H2>The string library</H2>
|
|
||||||
<p>
|
|
||||||
Lua supplies a range of useful functions for processing and manipulating strings in its standard library. More details are supplied in the <a href="/wiki/StringLibraryTutorial" >StringLibraryTutorial</a>. Below are a few examples of usage of the string library.
|
|
||||||
<DL>
|
|
||||||
<dt><dd><pre class="code">
|
|
||||||
> = <span class="library">string.byte</span>(<span class="string">"ABCDE"</span>, 2) <span class="comment">-- return the ASCII value of the second character</span>
|
|
||||||
66
|
|
||||||
> = <span class="library">string.char</span>(65,66,67,68,69) <span class="comment">-- return a string constructed from ASCII values</span>
|
|
||||||
ABCDE
|
|
||||||
> = <span class="library">string.find</span>(<span class="string">"hello Lua user"</span>, <span class="string">"Lua"</span>) <span class="comment">-- find substring "Lua"</span>
|
|
||||||
7 9
|
|
||||||
> = <span class="library">string.find</span>(<span class="string">"hello Lua user"</span>, <span class="string">"l+"</span>) <span class="comment">-- find one or more occurrences of "l"</span>
|
|
||||||
3 4
|
|
||||||
> = <span class="library">string.format</span>(<span class="string">"%.7f"</span>, <span class="library">math.pi</span>) <span class="comment">-- format a number</span>
|
|
||||||
3.1415927
|
|
||||||
> = <span class="library">string.format</span>(<span class="string">"%8s"</span>, <span class="string">"Lua"</span>) <span class="comment">-- format a string</span>
|
|
||||||
Lua
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
</DL>
|
|
||||||
<p>
|
|
||||||
<H2>Coercion</H2>
|
|
||||||
<p>
|
|
||||||
Lua performs automatic conversion of numbers to strings and vice versa where it is appropriate. This is called <em>coercion</em>.
|
|
||||||
<DL>
|
|
||||||
<dt><dd><pre class="code">
|
|
||||||
> = <span class="string">"This is Lua version "</span> .. 5.1 .. <span class="string">" we are using."</span>
|
|
||||||
This is Lua version 5.1 we are using.
|
|
||||||
> = <span class="string">"Pi = "</span> .. <span class="library">math.pi</span>
|
|
||||||
Pi = 3.1415926535898
|
|
||||||
> = <span class="string">"Pi = "</span> .. 3.1415927
|
|
||||||
Pi = 3.1415927
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
</DL>
|
|
||||||
As shown above, during coercion, we do not have full control over the formatting of the conversion. To format the number as a string as we would like we can use the <code>string.format()</code> function. e.g.,
|
|
||||||
<DL>
|
|
||||||
<dt><dd><pre class="code">
|
|
||||||
> = <span class="library">string.format</span>(<span class="string">"%.3f"</span>, 5.1)
|
|
||||||
5.100
|
|
||||||
> = <span class="string">"Lua version "</span> .. <span class="library">string.format</span>(<span class="string">"%.1f"</span>, 5.1)
|
|
||||||
Lua version 5.1
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
]]
|
|
||||||
text = text:gsub("\n"," ")
|
|
||||||
function indent_entry(contents,init,break_at)
|
|
||||||
if contents:len() <= break_at then
|
|
||||||
return contents -- Done
|
|
||||||
end
|
|
||||||
|
|
||||||
local begin_tag,end_tag = contents:find("<(.-)>",init)
|
|
||||||
if not begin_tag or begin_tag > break_at then
|
|
||||||
-- No tag exists or next tag is behind preferred break
|
|
||||||
-- Find last space before break, if no space break word at break_at
|
|
||||||
for i=break_at,init,-1 do -- Iterate backwards over string
|
|
||||||
if contents:sub(i,i) == " " then
|
|
||||||
break_at = i
|
|
||||||
break;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
contents = contents:sub(1,break_at) .. "\n" .. contents:sub(break_at+1)
|
|
||||||
init = break_at+1 -- Not necessarily same value as passed to the function
|
|
||||||
break_at = break_at + line_width
|
|
||||||
debug = "No tag or tag behind break."
|
|
||||||
elseif end_tag < break_at then
|
|
||||||
-- Next tag is before preferred break
|
|
||||||
-- Increase break_at by length of tag and iterate (init = end_tag)
|
|
||||||
init = end_tag
|
|
||||||
break_at = break_at + 1 + end_tag - begin_tag
|
|
||||||
debug = "Tag entirely before break"
|
|
||||||
else
|
|
||||||
-- Case break_at in the middle of tag:
|
|
||||||
-- Increase break at by length of tag
|
|
||||||
init = end_tag + 1
|
|
||||||
break_at = break_at + 1 + end_tag - begin_tag
|
|
||||||
debug = "Tag in the middle of break"
|
|
||||||
end
|
|
||||||
return indent_entry(contents,init,break_at)
|
|
||||||
end
|
|
||||||
function parse_paragraph(par)
|
|
||||||
return indent_entry(par:gsub("\n", " "),1,line_width)
|
|
||||||
end
|
|
||||||
function substitute_tags(content)
|
|
||||||
return content:gsub("<code>",("${color4}${font %s}"):format(font_i(9)))
|
|
||||||
:gsub("<b>",("${font_b %s}"):format(font_b(9)))
|
|
||||||
:gsub("</(.-)>","${color}${font}")
|
|
||||||
:gsub("<a(.-)>","")
|
|
||||||
end
|
|
||||||
function parse_entry(contents)
|
|
||||||
local ret = ""
|
|
||||||
for paragraph in contents:gmatch("<p>(.-)</p>") do
|
|
||||||
if ret ~= "" then
|
|
||||||
ret = ret .. "\n\n" -- Add line break on all except first entry
|
|
||||||
end
|
|
||||||
ret = ret .. parse_paragraph(paragraph)
|
|
||||||
end
|
|
||||||
return substitute_tags(ret)
|
|
||||||
end
|
|
||||||
function format_entry(entry)
|
|
||||||
local entry_contents = parse_entry(entry.summary)
|
|
||||||
local res = ('${color2}${font %s}%s\n'):format(font(12),entry.title)
|
|
||||||
res = ('%s${color}${font}%s'):format(res,entry_contents)
|
|
||||||
res = ('%s${color3}${font %s}${alignr} Uppdated: %s\n\n'):format(res,font(8),os.date("%x",entry.updated_parsed))
|
|
||||||
return res
|
|
||||||
end
|
|
||||||
function conky_print()
|
|
||||||
local f = assert(get_file_handle('rb'))
|
|
||||||
local content = f:read("*all")
|
|
||||||
f:close()
|
|
||||||
return content
|
|
||||||
end
|
|
||||||
function fetch_feed()
|
|
||||||
-- Fetch over http
|
|
||||||
local http_request = require "http.request"
|
|
||||||
local url = "https://www.archlinux.org/feeds/news/"
|
|
||||||
local headers, stream = assert(http_request.new_from_uri(url):go())
|
|
||||||
local body = assert(stream:get_body_as_string())
|
|
||||||
if headers:get ":status" ~= "200" then
|
|
||||||
error(body)
|
|
||||||
end
|
|
||||||
a,s,c = headers:geti(3)
|
|
||||||
p="%a+, (%d+) (%a+) (%d+) (%d+):(%d+):(%d+) GMT"
|
|
||||||
day,month,year,hour,min,sec=s:match(p)
|
|
||||||
MON={Jan=1,Feb=2,Mar=3,Apr=4,May=5,Jun=6,Jul=7,Aug=8,Sep=9,Oct=10,Nov=11,Dec=12}
|
|
||||||
month=MON[month]
|
|
||||||
offset=os.time()-os.time(os.date("!*t"))
|
|
||||||
retrieved = os.date("%x",os.time({day=day,month=month,year=year,hour=hour,min=min,sec=sec})+offset)
|
|
||||||
|
|
||||||
-- Parse
|
|
||||||
local feedparser = require("feedparser")
|
|
||||||
entries = feedparser.parse(body).entries
|
|
||||||
s = entries[2].summary
|
|
||||||
local res = ('${alignr}${font %s}Retrieved: %s\n'):format(font(8),retrieved)
|
|
||||||
for key,entry in pairs(entries) do
|
|
||||||
res = res .. format_entry(entry)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Save to cache
|
|
||||||
local file = get_file_handle("w")
|
|
||||||
io.output(file)
|
|
||||||
io.write(res)
|
|
||||||
io.close(file)
|
|
||||||
return parsed
|
|
||||||
end
|
|
||||||
function font(size)
|
|
||||||
return ('DejaVu Sans:size=%d'):format(size)
|
|
||||||
end
|
|
||||||
function font_b(size)
|
|
||||||
return ('DejaVu Sans:bold:size=%d'):format(size)
|
|
||||||
end
|
|
||||||
function font_i(size)
|
|
||||||
return ('DejaVu Sans:italic:size=%d'):format(size)
|
|
||||||
end
|
|
||||||
function get_file_handle(opt)
|
|
||||||
local filename = '/home/kuba/.conky/arch/cache'
|
|
||||||
return io.open(filename, opt)
|
|
||||||
end
|
|
||||||
s = fetch_feed()
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
conky.config = {
|
|
||||||
use_spacer='none',
|
|
||||||
use_xft=true,
|
|
||||||
font='DejaVu Sans:size=9',
|
|
||||||
text_buffer_size=2048,
|
|
||||||
update_interval=600,
|
|
||||||
total_run_times=0,
|
|
||||||
|
|
||||||
own_window=true,
|
|
||||||
own_window_transparent=true,
|
|
||||||
own_window_type='normal',
|
|
||||||
own_window_hints='undecorated,skip_taskbar,skip_pager',
|
|
||||||
own_window_class='Conky-gmail',
|
|
||||||
own_window_argb_visual=true,
|
|
||||||
own_window_argb_value=0,
|
|
||||||
|
|
||||||
draw_shades=false,
|
|
||||||
draw_outline=false,
|
|
||||||
draw_borders=false,
|
|
||||||
stippled_borders=0,
|
|
||||||
double_buffer=true,
|
|
||||||
|
|
||||||
default_color='white',
|
|
||||||
default_shade_color='black',
|
|
||||||
--Minimum size of text area
|
|
||||||
maximum_width=1200 ,
|
|
||||||
minimum_width=1200 ,
|
|
||||||
|
|
||||||
--alignment=top_right,
|
|
||||||
--gap_x=20,
|
|
||||||
--gap_y=20,
|
|
||||||
|
|
||||||
no_buffers=true,
|
|
||||||
net_avg_samples=2,
|
|
||||||
|
|
||||||
override_utf8_locale=true,
|
|
||||||
|
|
||||||
use_spacer=none,
|
|
||||||
|
|
||||||
short_units=on,
|
|
||||||
|
|
||||||
default_color=000,
|
|
||||||
default_shade_color=black,
|
|
||||||
color1 = '0099ff',
|
|
||||||
color2 = '0000ff',
|
|
||||||
color3 = '3a3a3a',
|
|
||||||
color4 = 'dddddd',
|
|
||||||
default_outline_color='2edd2e'
|
|
||||||
};
|
|
||||||
conky.text = [[
|
|
||||||
${alignc}${font FontAwesome:size=24}${font Liberation Sans:size=24}mail${font}
|
|
||||||
${color7}${hr}${color}
|
|
||||||
# ${execp ~/.conky/gmail/gmail_imap.py}
|
|
||||||
]];
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
#! /usr/bin/env python3
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import imaplib
|
|
||||||
import email
|
|
||||||
import email.header
|
|
||||||
import datetime
|
|
||||||
from textwrap import wrap # For pretty printing assistance
|
|
||||||
import json
|
|
||||||
import time
|
|
||||||
import os.path
|
|
||||||
from os.path import expanduser
|
|
||||||
|
|
||||||
WRAP_LIMIT = 80
|
|
||||||
path = "/home/kuba/.conky/gmail/last.json"
|
|
||||||
|
|
||||||
def process_mailbox(M):
|
|
||||||
rv, data = M.search(None, "ALL")
|
|
||||||
if rv != 'OK':
|
|
||||||
print ("No messages found!")
|
|
||||||
return
|
|
||||||
numbers = data[0].split()
|
|
||||||
ln = len(numbers)
|
|
||||||
timestamp = str(round(time.time()))
|
|
||||||
|
|
||||||
parsed_data = {} #Find and save last 10 emails
|
|
||||||
parsed_data['timestamp'] = timestamp
|
|
||||||
emails = []
|
|
||||||
for num in numbers[ln:ln-10:-1]:
|
|
||||||
rv, data = M.fetch(num, '(RFC822)')
|
|
||||||
if rv != 'OK':
|
|
||||||
print ("ERROR getting message"), num
|
|
||||||
return
|
|
||||||
eml = {}
|
|
||||||
|
|
||||||
msg = email.message_from_bytes(data[0][1])
|
|
||||||
eml.update({'subject' : decode_field(msg['Subject'])})
|
|
||||||
eml.update({'sender' : decode_field(msg['From'])})
|
|
||||||
date_tuple = email.utils.parsedate_tz(msg['Date'])
|
|
||||||
if date_tuple:
|
|
||||||
local_date = datetime.datetime.fromtimestamp(
|
|
||||||
email.utils.mktime_tz(date_tuple))
|
|
||||||
eml.update({'date' : local_date.strftime("%a, %d %b %Y %H:%M:%S")})
|
|
||||||
emails.append(eml)
|
|
||||||
|
|
||||||
parsed_data['emails'] = emails
|
|
||||||
with open(path, 'w') as outfile:
|
|
||||||
json.dump(parsed_data, outfile)
|
|
||||||
|
|
||||||
def fetch_mail():
|
|
||||||
M = imaplib.IMAP4_SSL('imap.gmail.com')
|
|
||||||
|
|
||||||
try:
|
|
||||||
json_data=open(expanduser('~')+'/.conky/scripts/.passwords.json')
|
|
||||||
data = json.load(json_data)
|
|
||||||
username=data['gmail']['username']
|
|
||||||
password=data['gmail']['password']
|
|
||||||
rv, data = M.login(username, password)
|
|
||||||
except imaplib.IMAP4.error:
|
|
||||||
print ("LOGIN FAILED!!! ")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
rv, data = M.select()
|
|
||||||
if rv == 'OK':
|
|
||||||
# print("Processing mailbox...\n")
|
|
||||||
process_mailbox(M)
|
|
||||||
M.close()
|
|
||||||
else:
|
|
||||||
print("ERROR: Unable to open mailbox ", rv)
|
|
||||||
|
|
||||||
M.logout()
|
|
||||||
|
|
||||||
def fill(text, width):
|
|
||||||
'''A custom method to assist in pretty printing'''
|
|
||||||
if len(text) < width:
|
|
||||||
return text + ' '*(width-len(text))
|
|
||||||
else:
|
|
||||||
return text
|
|
||||||
|
|
||||||
def decode_field(data):
|
|
||||||
decode = email.header.decode_header(data)[0]
|
|
||||||
if decode[1] == None or decode[1] == 'unknown-8bit':
|
|
||||||
return str(decode[0])
|
|
||||||
else:
|
|
||||||
return str(decode[0], decode[1])
|
|
||||||
|
|
||||||
def print_output(data):
|
|
||||||
timestamp = int(data['timestamp'])
|
|
||||||
updated = time.strftime("%m/%d %H:%M", time.gmtime(timestamp))
|
|
||||||
print ("${alignr}Updated: ${color white}%s" % updated)
|
|
||||||
|
|
||||||
for mail in data['emails']:
|
|
||||||
subject = mail['subject']
|
|
||||||
sender = mail['sender']
|
|
||||||
dte = mail['date']
|
|
||||||
if(len(subject) > WRAP_LIMIT - 3):
|
|
||||||
print ("${color1}%s..." % subject)
|
|
||||||
else:
|
|
||||||
print ("${color1}%s" % subject)
|
|
||||||
|
|
||||||
# Does file exist?
|
|
||||||
if not (os.path.isfile(path)):
|
|
||||||
fetch_mail()
|
|
||||||
with open(path) as infile:
|
|
||||||
data = json.load(infile)
|
|
||||||
|
|
||||||
# Is data recently fetched?
|
|
||||||
ts = int(data['timestamp'])
|
|
||||||
now = round(time.time())
|
|
||||||
if (ts + 3600 < now):
|
|
||||||
fetch_mail()
|
|
||||||
with open(path) as infile:
|
|
||||||
data = json.load(infile)
|
|
||||||
|
|
||||||
# Format output
|
|
||||||
print_output(data)
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
line_width = 200
|
|
||||||
function indent_entry(contents,init,break_at)
|
|
||||||
if contents:len() <= break_at then
|
|
||||||
return contents -- Done
|
|
||||||
end
|
|
||||||
|
|
||||||
local begin_tag,end_tag = contents:find("<(.-)>",init)
|
|
||||||
if not begin_tag or begin_tag > break_at then
|
|
||||||
-- No tag exists or next tag is behind preferred break
|
|
||||||
-- Find last space before break, if no space break word at break_at
|
|
||||||
for i=break_at,init,-1 do -- Iterate backwards over string
|
|
||||||
if contents:sub(i,i) == " " then
|
|
||||||
break_at = i
|
|
||||||
break;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
contents = contents:sub(1,break_at) .. "\n" .. contents:sub(break_at+1)
|
|
||||||
init = break_at+1 -- Not necessarily same value as passed to the function
|
|
||||||
break_at = break_at + line_width
|
|
||||||
debug = "No tag or tag behind break."
|
|
||||||
elseif end_tag < break_at then
|
|
||||||
-- Next tag is before preferred break
|
|
||||||
-- Increase break_at by length of tag and iterate (init = end_tag)
|
|
||||||
init = end_tag
|
|
||||||
break_at = break_at + 1 + end_tag - begin_tag
|
|
||||||
debug = "Tag entirely before break"
|
|
||||||
else
|
|
||||||
-- Case break_at in the middle of tag:
|
|
||||||
-- Increase break at by length of tag
|
|
||||||
init = end_tag + 1
|
|
||||||
break_at = break_at + 1 + end_tag - begin_tag
|
|
||||||
debug = "Tag in the middle of break"
|
|
||||||
end
|
|
||||||
return indent_entry(contents,init,break_at)
|
|
||||||
end
|
|
||||||
function parse_paragraph(par)
|
|
||||||
return indent_entry(par:gsub("\n", " "),1,line_width)
|
|
||||||
end
|
|
||||||
function substitute_tags(content)
|
|
||||||
return content:gsub("<code>",("${color4}${font %s}"):format(font_i(9)))
|
|
||||||
:gsub("<b>",("${font_b %s}"):format(font_b(9)))
|
|
||||||
:gsub("</(.-)>","${color}${font}")
|
|
||||||
:gsub("<a(.-)>","")
|
|
||||||
end
|
|
||||||
function parse_entry(contents)
|
|
||||||
local ret = ""
|
|
||||||
for paragraph in contents:gmatch("<p>(.-)</p>") do
|
|
||||||
if ret ~= "" then
|
|
||||||
ret = ret .. "\n\n" -- Add line break on all except first entry
|
|
||||||
end
|
|
||||||
ret = ret .. parse_paragraph(paragraph)
|
|
||||||
end
|
|
||||||
return substitute_tags(ret)
|
|
||||||
end
|
|
||||||
function format_entry(entry)
|
|
||||||
local entry_contents = parse_entry(entry.summary)
|
|
||||||
local res = ('${color2}${font %s}%s\n'):format(font(12),entry.title)
|
|
||||||
res = ('%s${color}${font}%s'):format(res,entry_contents)
|
|
||||||
res = ('%s${color3}${font %s}${alignr} Uppdated: %s\n\n'):format(res,font(8),os.date("%x",entry.updated_parsed))
|
|
||||||
return res
|
|
||||||
end
|
|
||||||
function conky_print()
|
|
||||||
local f = assert(get_file_handle('rb'))
|
|
||||||
local content = f:read("*all")
|
|
||||||
f:close()
|
|
||||||
return content
|
|
||||||
end
|
|
||||||
function fetch_feed()
|
|
||||||
local imap4 = require "imap4"
|
|
||||||
local Message = require "pop3.message"
|
|
||||||
|
|
||||||
local connection = imap4('imap.gmail.com', 993)
|
|
||||||
|
|
||||||
assert(connection:isCapable('IMAP4rev1'))
|
|
||||||
|
|
||||||
connection:login('****', '****')
|
|
||||||
|
|
||||||
-- Select INBOX with read only permissions.
|
|
||||||
local info = connection:examine('INBOX')
|
|
||||||
print(info.exist, info.recent)
|
|
||||||
|
|
||||||
-- List info on the 4 most recent mails.
|
|
||||||
for _,v in pairs(connection:fetch('RFC822', (info.exist-4)..':*')) do
|
|
||||||
print("-------------------------")
|
|
||||||
local msg = Message(v.RFC822)
|
|
||||||
print("ID: ", msg:id())
|
|
||||||
print("subject: ", msg:subject())
|
|
||||||
print("to: ", msg:to())
|
|
||||||
print("from: ", msg:from())
|
|
||||||
print("from addr: ", msg:from_address())
|
|
||||||
print("reply: ", msg:reply_to())
|
|
||||||
print("reply addr: ", msg:reply_address())
|
|
||||||
print("trunc: ", msg:is_truncated())
|
|
||||||
for i,v in ipairs(msg:full_content()) do
|
|
||||||
if v.text then print(" ", i , "TEXT: ", v.type, #v.text)
|
|
||||||
else print(" ", i , "FILE: ", v.type, v.file_name or v.name, #v.data) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- close connection
|
|
||||||
connection:logout()
|
|
||||||
-- Fetch over http
|
|
||||||
local http_request = require "http.request"
|
|
||||||
local url = "https://www.archlinux.org/feeds/news/"
|
|
||||||
local headers, stream = assert(http_request.new_from_uri(url):go())
|
|
||||||
local body = assert(stream:get_body_as_string())
|
|
||||||
if headers:get ":status" ~= "200" then
|
|
||||||
error(body)
|
|
||||||
end
|
|
||||||
a,s,c = headers:geti(3)
|
|
||||||
p="%a+, (%d+) (%a+) (%d+) (%d+):(%d+):(%d+) GMT"
|
|
||||||
day,month,year,hour,min,sec=s:match(p)
|
|
||||||
MON={Jan=1,Feb=2,Mar=3,Apr=4,May=5,Jun=6,Jul=7,Aug=8,Sep=9,Oct=10,Nov=11,Dec=12}
|
|
||||||
month=MON[month]
|
|
||||||
offset=os.time()-os.time(os.date("!*t"))
|
|
||||||
retrieved = os.date("%x",os.time({day=day,month=month,year=year,hour=hour,min=min,sec=sec})+offset)
|
|
||||||
|
|
||||||
-- Parse
|
|
||||||
local feedparser = require("feedparser")
|
|
||||||
entries = feedparser.parse(body).entries
|
|
||||||
s = entries[2].summary
|
|
||||||
local res = ('${alignr}${font %s}Retrieved: %s\n'):format(font(8),retrieved)
|
|
||||||
for key,entry in pairs(entries) do
|
|
||||||
res = res .. format_entry(entry)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Save to cache
|
|
||||||
local file = get_file_handle("w")
|
|
||||||
io.output(file)
|
|
||||||
io.write(res)
|
|
||||||
io.close(file)
|
|
||||||
return parsed
|
|
||||||
end
|
|
||||||
function font(size)
|
|
||||||
return ('DejaVu Sans:size=%d'):format(size)
|
|
||||||
end
|
|
||||||
function font_b(size)
|
|
||||||
return ('DejaVu Sans:bold:size=%d'):format(size)
|
|
||||||
end
|
|
||||||
function font_i(size)
|
|
||||||
return ('DejaVu Sans:italic:size=%d'):format(size)
|
|
||||||
end
|
|
||||||
function get_file_handle(opt)
|
|
||||||
local filename = '/home/kuba/.conky/arch/cache'
|
|
||||||
return io.open(filename, opt)
|
|
||||||
end
|
|
||||||
s = fetch_feed()
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
conky.config = {
|
|
||||||
use_spacer='none',
|
|
||||||
use_xft=true,
|
|
||||||
font='Liberation Sans:Bold:size=24',
|
|
||||||
text_buffer_size=2048,
|
|
||||||
update_interval=1.0,
|
|
||||||
total_run_times=0,
|
|
||||||
|
|
||||||
own_window=true,
|
|
||||||
own_window_transparent=true,
|
|
||||||
own_window_type='normal',
|
|
||||||
own_window_hints='undecorated,skip_taskbar,skip_pager',
|
|
||||||
own_window_class='Conky-music',
|
|
||||||
own_window_argb_visual=true,
|
|
||||||
own_window_argb_value=0,
|
|
||||||
|
|
||||||
draw_shades=false,
|
|
||||||
draw_outline=false,
|
|
||||||
draw_borders=false,
|
|
||||||
stippled_borders=0,
|
|
||||||
double_buffer=true,
|
|
||||||
draw_blended=false,
|
|
||||||
|
|
||||||
default_color='white',
|
|
||||||
default_shade_color='black',
|
|
||||||
--Minimum size of text area
|
|
||||||
maximum_width=1200 ,
|
|
||||||
|
|
||||||
--alignment='top_left',
|
|
||||||
--gap_x=1940,
|
|
||||||
--gap_y=0,
|
|
||||||
|
|
||||||
no_buffers=true,
|
|
||||||
net_avg_samples=2,
|
|
||||||
|
|
||||||
override_utf8_locale=true,
|
|
||||||
|
|
||||||
use_spacer=none,
|
|
||||||
|
|
||||||
short_units=on,
|
|
||||||
|
|
||||||
default_color='dddddd',
|
|
||||||
color1 = 'C7FF8E',
|
|
||||||
color2 = '000000',
|
|
||||||
color7 = '333333'
|
|
||||||
};
|
|
||||||
conky.text = [[
|
|
||||||
${if_existing /tmp/kuba_now_playing }
|
|
||||||
${color2}${exec cat /tmp/kuba_now_playing 2> /dev/null}${color}
|
|
||||||
${image /tmp/kuba_now_playing_cover.png -p -f 3 0,0 -s 200x200}
|
|
||||||
${else}
|
|
||||||
Not playing
|
|
||||||
${endif}
|
|
||||||
]];
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Written by Demetrio Ferro <ferrodemetrio@gmail.com> <https://twitter.com/DemetrioFerro>
|
|
||||||
# Distributed under license GPLv3+ GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
|
||||||
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY. YOU USE AT YOUR OWN RISK. THE AUTHOR
|
|
||||||
# WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY
|
|
||||||
# OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.
|
|
||||||
# See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
first_cover=""
|
|
||||||
|
|
||||||
while :
|
|
||||||
do
|
|
||||||
if [ -e ~/.conky/music/meta ]
|
|
||||||
then
|
|
||||||
new_cover=$(cat ~/.conky/music/meta | awk -F \' '{for(i=1;i<=NF;i++) if ($i=="mpris:artUrl") print $(i+2)}')
|
|
||||||
if [ "$new_cover" != "$first_cover" ]
|
|
||||||
then
|
|
||||||
first_cover="$new_cover"
|
|
||||||
wget -O ~/.conky/music/last_album_pic.png $new_cover
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
old_meta=""
|
|
||||||
while :
|
|
||||||
do
|
|
||||||
if [ "$(playerctl status)" = "Playing" ]
|
|
||||||
then
|
|
||||||
new_meta=$(playerctl metadata)
|
|
||||||
if [ "$new_meta" != "$old_meta" ]
|
|
||||||
then
|
|
||||||
echo $new_meta > ~/.conky/music/meta
|
|
||||||
old_meta=$new_meta
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
new_meta=''
|
|
||||||
if [ -e ~/.conky/music/meta ]
|
|
||||||
then
|
|
||||||
rm ~/.conky/music/meta
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
width=26
|
|
||||||
space=' ' #20 spaces
|
|
||||||
if [ -f $META_FILE ]; then
|
|
||||||
artist=$(cat ~/.conky/music/meta | awk -F \' '{for(i=1;i<=NF;i++) if ($i=="xesam:artist") print $(i+2)}')
|
|
||||||
album=$(cat ~/.conky/music/meta | awk -F \' '{for(i=1;i<=NF;i++) if ($i=="xesam:album") print $(i+2)}')
|
|
||||||
title=$(cat ~/.conky/music/meta | awk -F \' '{for(i=1;i<=NF;i++) if ($i=="xesam:title") print $(i+2)}')
|
|
||||||
out=$(echo "$artist"; echo "$title"; echo "$album")
|
|
||||||
out=$(echo "$out" | fmt -s --width $width)
|
|
||||||
mapfile -t var <<< "$out"
|
|
||||||
for word in "${var[@]}"; do
|
|
||||||
echo "$space $word"
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "Nothing playing"
|
|
||||||
fi
|
|
||||||
|
Before Width: | Height: | Size: 35 KiB |
@@ -1,58 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
fetch_art(){
|
|
||||||
first_cover=""
|
|
||||||
if [ -e ~/.conky/music/meta ]
|
|
||||||
then
|
|
||||||
new_cover=$(cat ~/.conky/music/meta | awk -F \' '{for(i=1;i<=NF;i++) if ($i=="mpris:artUrl") print $(i+2)}')
|
|
||||||
if [ "$new_cover" != "$first_cover" ]
|
|
||||||
then
|
|
||||||
first_cover="$new_cover"
|
|
||||||
wget -O ~/.conky/music/last_album_pic.png $new_cover
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
fetch_meta(){
|
|
||||||
old_meta=""
|
|
||||||
if [ "$(playerctl status)" = "Playing" ]
|
|
||||||
then
|
|
||||||
new_meta=$(playerctl metadata)
|
|
||||||
if [ "$new_meta" != "$old_meta" ]
|
|
||||||
then
|
|
||||||
echo $new_meta > ~/.conky/music/meta
|
|
||||||
old_meta=$new_meta
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
new_meta=''
|
|
||||||
if [ -e ~/.conky/music/meta ]
|
|
||||||
then
|
|
||||||
rm ~/.conky/music/meta
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
running=false
|
|
||||||
|
|
||||||
while :
|
|
||||||
do
|
|
||||||
if [ $running = false ]; then
|
|
||||||
spotify_process_id=$(pidof spotify)
|
|
||||||
if [[ ! -z $spotify_process_id ]]; then
|
|
||||||
~/.conky/music/fetch_meta.sh & meta_PID=$!
|
|
||||||
~/.conky/music/fetch_art.sh & art_PID=$!
|
|
||||||
running=true
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
spotify_process_id=$(pidof spotify)
|
|
||||||
if [[ -z $spotify_process_id ]]; then
|
|
||||||
if [[ ! -z $meta_PID ]]; then
|
|
||||||
kill $meta_PID
|
|
||||||
fi
|
|
||||||
if [[ ! -z $art_PID ]]; then
|
|
||||||
kill $art_PID
|
|
||||||
fi
|
|
||||||
running=false
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
sleep 10
|
|
||||||
done
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import os
|
|
||||||
import urllib.request
|
|
||||||
import gi
|
|
||||||
gi.require_version('Playerctl', '2.0')
|
|
||||||
from gi.repository import Playerctl, GLib
|
|
||||||
|
|
||||||
metadata_file = '/tmp/kuba_now_playing'
|
|
||||||
album_cover_file = '/tmp/kuba_now_playing_cover.png'
|
|
||||||
manager = Playerctl.PlayerManager()
|
|
||||||
|
|
||||||
last_spotify_metadata = None # Keep this as spotify gives several notifications
|
|
||||||
|
|
||||||
def on_play(player, status, manager):
|
|
||||||
# print('player is playing: {}'.format(player.props.player_name))
|
|
||||||
pass
|
|
||||||
|
|
||||||
def download_album_cover(url):
|
|
||||||
image = urllib.request.urlopen(url)
|
|
||||||
with open(album_cover_file,'wb') as output:
|
|
||||||
output.write(image.read())
|
|
||||||
|
|
||||||
space = ' '
|
|
||||||
def on_metadata(player, metadata, manager):
|
|
||||||
global last_spotify_metadata
|
|
||||||
if last_spotify_metadata == metadata:
|
|
||||||
return
|
|
||||||
|
|
||||||
last_spotify_metadata = metadata
|
|
||||||
keys = metadata.keys()
|
|
||||||
with open(metadata_file, 'w+') as f:
|
|
||||||
f.write('{}{}\n'.format(space, metadata['xesam:artist'][0]))
|
|
||||||
f.write('{}{}\n'.format(space, metadata['xesam:title']))
|
|
||||||
f.write('{}{}'.format(space, metadata['xesam:album']))
|
|
||||||
download_album_cover(metadata['mpris:artUrl'])
|
|
||||||
|
|
||||||
def init_player(name):
|
|
||||||
# choose if you want to manage the player based on the name
|
|
||||||
if name.name in ['spotify']:#, 'vlc', 'cmus']:
|
|
||||||
player = Playerctl.Player.new_from_name(name)
|
|
||||||
#player.connect('playback-status::playing', on_play, manager)
|
|
||||||
player.connect('metadata', on_metadata, manager)
|
|
||||||
manager.manage_player(player)
|
|
||||||
return player
|
|
||||||
|
|
||||||
def on_name_appeared(manager, name):
|
|
||||||
player = init_player(name)
|
|
||||||
# if player != None:
|
|
||||||
# print('player has appeared: {}'.format(player.props.player_name))
|
|
||||||
|
|
||||||
def on_player_vanished(manager, player):
|
|
||||||
print('player has exited: {}'.format(player.props.player_name))
|
|
||||||
os.remove(metadata_file)
|
|
||||||
|
|
||||||
manager.connect('name-appeared', on_name_appeared)
|
|
||||||
manager.connect('player-vanished', on_player_vanished)
|
|
||||||
|
|
||||||
for name in manager.props.player_names:
|
|
||||||
init_player(name)
|
|
||||||
|
|
||||||
main = GLib.MainLoop()
|
|
||||||
main.run()
|
|
||||||
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import pathlib
|
|
||||||
import re
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
LOG_PATH = pathlib.Path("/var/log/pacman.log")
|
|
||||||
|
|
||||||
def get_log():
|
|
||||||
with LOG_PATH.open() as fp:
|
|
||||||
log_text = fp.read()
|
|
||||||
|
|
||||||
return log_text
|
|
||||||
|
|
||||||
def parse_pacman_line(line):
|
|
||||||
if len(line) > 0:
|
|
||||||
date_str = line[:18]
|
|
||||||
pacman_indicator = line[19:27]
|
|
||||||
message = line[28:]
|
|
||||||
|
|
||||||
if pacman_indicator == "[PACMAN]":
|
|
||||||
parsed_date = datetime.strptime(date_str,
|
|
||||||
"[%Y-%m-%d %H:%M]")
|
|
||||||
return {"date": parsed_date,
|
|
||||||
"message": message}
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_last_sync(log_text):
|
|
||||||
last_sync = None
|
|
||||||
for line in log_text.split("\n"):
|
|
||||||
|
|
||||||
parsed_line = parse_pacman_line(line)
|
|
||||||
if parsed_line is None:
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
if parsed_line["message"] == "synchronizing package lists":
|
|
||||||
last_sync = parsed_line["date"]
|
|
||||||
|
|
||||||
return last_sync
|
|
||||||
|
|
||||||
def get_last_system_upgrade(log_text):
|
|
||||||
last_upgrade = None
|
|
||||||
for line in log_text.split("\n"):
|
|
||||||
parsed_line = parse_pacman_line(line)
|
|
||||||
if parsed_line is None:
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
if parsed_line["message"] == "starting full system upgrade":
|
|
||||||
last_upgrade = parsed_line["date"]
|
|
||||||
|
|
||||||
return last_upgrade
|
|
||||||
|
|
||||||
def get_diffs(t):
|
|
||||||
now = datetime.now()
|
|
||||||
diff = now - t
|
|
||||||
|
|
||||||
if diff.days != 0:
|
|
||||||
return "{}d".format(diff.days)
|
|
||||||
elif diff.seconds > 3600:
|
|
||||||
return "{}h".format(diff.seconds // 3600)
|
|
||||||
else:
|
|
||||||
return "{}m".format(diff.seconds // 60)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
text = get_log()
|
|
||||||
last_sync = get_last_sync(text)
|
|
||||||
last_upgrade = get_last_system_upgrade(text)
|
|
||||||
last_sync_diff = get_diffs(last_sync)
|
|
||||||
last_upgrade_diff = get_diffs(last_upgrade)
|
|
||||||
|
|
||||||
print("S: {} U: {}".format(last_sync_diff,
|
|
||||||
last_upgrade_diff))
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"gmail":
|
|
||||||
{
|
|
||||||
"username":"jakub.fojt96@gmail.com",
|
|
||||||
"password":"donotforget"
|
|
||||||
},
|
|
||||||
"github":
|
|
||||||
{
|
|
||||||
"username": "kuben",
|
|
||||||
"password": "githubpassword",
|
|
||||||
"fav_repos" : ["madhur.github.com", "portablejekyll", "GAnalytics", "wunder-java", "msysgit-2.0.0"]
|
|
||||||
},
|
|
||||||
"feedly":
|
|
||||||
{
|
|
||||||
"access_token": "feedly_access_token",
|
|
||||||
"access_code" : "feedly_access_code",
|
|
||||||
"refresh_token" : "feedly_refresh_token"
|
|
||||||
},
|
|
||||||
"twitter":
|
|
||||||
{
|
|
||||||
"key": "xxxxxxxx",
|
|
||||||
"secret":"xxxxxxxx",
|
|
||||||
"access_token": "xxxxxxxx",
|
|
||||||
"user": "your twitter screen name"
|
|
||||||
},
|
|
||||||
"pocket":
|
|
||||||
{
|
|
||||||
"key": "xxxxx",
|
|
||||||
"request_token":"xxxxxx",
|
|
||||||
"access_token" : "xxxxxxx"
|
|
||||||
},
|
|
||||||
"so" :
|
|
||||||
{
|
|
||||||
"userid":"stackoverflow_user_id"
|
|
||||||
},
|
|
||||||
"weather":
|
|
||||||
{
|
|
||||||
"location_code":"SWXX0043"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
cat /proc/mounts | awk '{ if ( $1 ~ /\/dev/ )
|
|
||||||
{
|
|
||||||
num_elem = split($2,str_array,"/")
|
|
||||||
if (str_array[num_elem] == "")
|
|
||||||
{
|
|
||||||
str_array[num_elem] = "/";
|
|
||||||
}
|
|
||||||
printf "%5.5s: ${fs_free %s} / ${fs_size %s}\n${fs_bar 6 %s}\n", str_array[num_elem], $2, $2, $2
|
|
||||||
}
|
|
||||||
}'
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
msgcount=$(fbcmd NOTIFY | grep MESSAGES_UNREAD | grep -oE "[[:digit:]]{1,}")
|
|
||||||
notifycount=$(fbcmd NOTICES unread | grep -c :title)
|
|
||||||
friendcount=$(fbcmd NOTIFY | grep FRIEND_REQUESTS | grep -oE "[[:digit:]]{1,}")
|
|
||||||
currenttime=$(date +%I:%M)
|
|
||||||
|
|
||||||
if [[ "$msgcount" -eq "0" ]] && [[ "$notifycount" -eq "0" ]] && [[ "$friendcount" -eq "0" ]]
|
|
||||||
then
|
|
||||||
|
|
||||||
echo '${color}No new updates ${alignr}Updated: ${color white}'$currenttime
|
|
||||||
else
|
|
||||||
echo '${color white}'$msgcount'${color aaaaaa} NEW MESSAGE(S) ${alignr}Updated: ${color white}'$currenttime
|
|
||||||
echo '${color white}'$notifycount'${color aaaaaa} NEW NOTIFICATION(S)'
|
|
||||||
echo '${color white}'$friendcount'${color aaaaaa} NEW Friend Request(s)'
|
|
||||||
|
|
||||||
fi
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
from feedly import FeedlyClient
|
|
||||||
import json
|
|
||||||
from subprocess import call
|
|
||||||
from os.path import expanduser
|
|
||||||
import time
|
|
||||||
|
|
||||||
#Categories to ignore, you can add yours
|
|
||||||
ignored=["global.all", "global.must", "global.uncategorized", "Security", "Ignore", "GMAT", "sharepoint", "madhur"]
|
|
||||||
|
|
||||||
FEEDLY_REDIRECT_URI = "http://localhost"
|
|
||||||
|
|
||||||
def get_feedly_client(token=None):
|
|
||||||
if token:
|
|
||||||
return FeedlyClient(token=token, sandbox=False)
|
|
||||||
else:
|
|
||||||
return FeedlyClient(
|
|
||||||
client_id=FEEDLY_CLIENT_ID,
|
|
||||||
client_secret=FEEDLY_CLIENT_SECRET,
|
|
||||||
sandbox=False
|
|
||||||
)
|
|
||||||
def auth(request):
|
|
||||||
feedly = get_feedly_client()
|
|
||||||
# Redirect the user to the feedly authorization URL to get user code
|
|
||||||
code_url = feedly.get_code_url(FEEDLY_REDIRECT_URI)
|
|
||||||
return redirect(code_url)
|
|
||||||
|
|
||||||
def callback(request):
|
|
||||||
code=request.GET.get('code','')
|
|
||||||
if not code:
|
|
||||||
return HttpResponse('The authentication is failed.')
|
|
||||||
|
|
||||||
feedly = get_feedly_client()
|
|
||||||
|
|
||||||
#response of access token
|
|
||||||
res_access_token = feedly.get_access_token(FEEDLY_REDIRECT_URI, code)
|
|
||||||
# user id
|
|
||||||
if 'errorCode' in res_access_token.keys():
|
|
||||||
return HttpResponse('The authentication is failed.')
|
|
||||||
|
|
||||||
id = res_access_token['id']
|
|
||||||
access_token=res_access_token['access_token']
|
|
||||||
|
|
||||||
def feed(access_token):
|
|
||||||
'''get user's subscription'''
|
|
||||||
feedly = get_feedly_client()
|
|
||||||
user_subscriptions = feedly.get_user_subscriptions(access_token)
|
|
||||||
|
|
||||||
|
|
||||||
json_data=open(expanduser('~')+'/.conky/scripts/.passwords.json')
|
|
||||||
data = json.load(json_data)
|
|
||||||
access_token=data['feedly']['access_token']
|
|
||||||
|
|
||||||
client = get_feedly_client(access_token)
|
|
||||||
categories = client.get_user_categories(access_token)
|
|
||||||
counts = client.get_unread_count(access_token)
|
|
||||||
|
|
||||||
text=""
|
|
||||||
count=0
|
|
||||||
for item in counts['unreadcounts']:
|
|
||||||
itemcount = item['count']
|
|
||||||
itemname = item['id'][51:]
|
|
||||||
if(itemcount > 0 and itemname not in ignored and "user/23bbb2c4-62b9-4bb9-a756-556cef1512f9/category/" in item['id']):
|
|
||||||
count = count + itemcount
|
|
||||||
text=text + "${color1}%s${alignr}${color white} %d" %(itemname, itemcount) +"\n"
|
|
||||||
|
|
||||||
print "${color1}Total unread: ${color white}%s ${alignr}${color1}Updated: ${color white}%s" %(count, time.strftime("%I:%M"))
|
|
||||||
print text
|
|
||||||
|
|
||||||
#call(['notify-send','Feedly Updated'])
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
import requests
|
|
||||||
import json
|
|
||||||
|
|
||||||
class FeedlyClient(object):
|
|
||||||
def __init__(self, **options):
|
|
||||||
self.client_id = options.get('client_id')
|
|
||||||
self.client_secret = options.get('client_secret')
|
|
||||||
self.sandbox = options.get('sandbox', True)
|
|
||||||
if self.sandbox:
|
|
||||||
default_service_host = 'sandbox.feedly.com'
|
|
||||||
else:
|
|
||||||
default_service_host = 'cloud.feedly.com'
|
|
||||||
self.service_host = options.get('service_host', default_service_host)
|
|
||||||
self.additional_headers = options.get('additional_headers', {})
|
|
||||||
self.token = options.get('token')
|
|
||||||
self.secret = options.get('secret')
|
|
||||||
|
|
||||||
def get_code_url(self, callback_url):
|
|
||||||
scope = 'https://cloud.feedly.com/subscriptions'
|
|
||||||
response_type = 'code'
|
|
||||||
|
|
||||||
request_url = '%s?client_id=%s&redirect_uri=%s&scope=%s&response_type=%s' % (
|
|
||||||
self._get_endpoint('v3/auth/auth'),
|
|
||||||
self.client_id,
|
|
||||||
callback_url,
|
|
||||||
scope,
|
|
||||||
response_type
|
|
||||||
)
|
|
||||||
return request_url
|
|
||||||
|
|
||||||
def get_access_token(self,redirect_uri,code):
|
|
||||||
params = dict(
|
|
||||||
client_id=self.client_id,
|
|
||||||
client_secret=self.client_secret,
|
|
||||||
grant_type='authorization_code',
|
|
||||||
redirect_uri=redirect_uri,
|
|
||||||
code=code
|
|
||||||
)
|
|
||||||
|
|
||||||
quest_url=self._get_endpoint('v3/auth/token')
|
|
||||||
res = requests.post(url=quest_url, params=params)
|
|
||||||
return res.json()
|
|
||||||
|
|
||||||
def refresh_access_token(self,refresh_token):
|
|
||||||
'''obtain a new access token by sending a refresh token to the feedly Authorization server'''
|
|
||||||
params = dict(
|
|
||||||
refresh_token=refresh_token,
|
|
||||||
client_id=self.client_id,
|
|
||||||
client_secret=self.client_secret,
|
|
||||||
grant_type='refresh_token',
|
|
||||||
)
|
|
||||||
quest_url=self._get_endpoint('v3/auth/token')
|
|
||||||
res = requests.post(url=quest_url, params=params)
|
|
||||||
return res.json()
|
|
||||||
|
|
||||||
|
|
||||||
def get_user_subscriptions(self,access_token):
|
|
||||||
'''return list of user subscriptions'''
|
|
||||||
headers = {'Authorization': 'OAuth '+access_token}
|
|
||||||
quest_url=self._get_endpoint('v3/subscriptions')
|
|
||||||
res = requests.get(url=quest_url, headers=headers)
|
|
||||||
return res.json()
|
|
||||||
|
|
||||||
def get_user_categories(self,access_token):
|
|
||||||
'''return list of user subscriptions'''
|
|
||||||
headers = {'Authorization': 'OAuth '+access_token}
|
|
||||||
quest_url=self._get_endpoint('v3/categories')
|
|
||||||
res = requests.get(url=quest_url, headers=headers)
|
|
||||||
return res.json()
|
|
||||||
|
|
||||||
def get_unread_count(self,access_token):
|
|
||||||
'''return list of user subscriptions'''
|
|
||||||
headers = {'Authorization': 'OAuth '+access_token}
|
|
||||||
quest_url=self._get_endpoint('v3/markers/counts')
|
|
||||||
res = requests.get(url=quest_url, headers=headers)
|
|
||||||
return res.json()
|
|
||||||
|
|
||||||
|
|
||||||
def get_feed_content(self,access_token,streamId,unreadOnly,newerThan):
|
|
||||||
'''return contents of a feed'''
|
|
||||||
headers = {'Authorization': 'OAuth '+access_token}
|
|
||||||
quest_url=self._get_endpoint('v3/streams/contents')
|
|
||||||
params = dict(
|
|
||||||
streamId=streamId,
|
|
||||||
unreadOnly=unreadOnly,
|
|
||||||
newerThan=newerThan
|
|
||||||
)
|
|
||||||
res = requests.get(url=quest_url, params=params,headers=headers)
|
|
||||||
return res.json()
|
|
||||||
|
|
||||||
def mark_article_read(self, access_token, entryIds):
|
|
||||||
'''Mark one or multiple articles as read'''
|
|
||||||
headers = {'content-type': 'application/json',
|
|
||||||
'Authorization': 'OAuth ' + access_token
|
|
||||||
}
|
|
||||||
quest_url = self._get_endpoint('v3/markers')
|
|
||||||
params = dict(
|
|
||||||
action="markAsRead",
|
|
||||||
type="entries",
|
|
||||||
entryIds=entryIds,
|
|
||||||
)
|
|
||||||
res = requests.post(url=quest_url, data=json.dumps(params), headers=headers)
|
|
||||||
return res
|
|
||||||
|
|
||||||
def save_for_later(self, access_token, user_id, entryIds):
|
|
||||||
'''saved for later.entryIds is a list for entry id.'''
|
|
||||||
headers = {'content-type': 'application/json',
|
|
||||||
'Authorization': 'OAuth ' + access_token
|
|
||||||
}
|
|
||||||
request_url = self._get_endpoint('v3/tags') + '/user%2F' + user_id + '%2Ftag%2Fglobal.saved'
|
|
||||||
|
|
||||||
params = dict(
|
|
||||||
entryIds=entryIds
|
|
||||||
)
|
|
||||||
res = requests.put(url=request_url, data=json.dumps(params), headers=headers)
|
|
||||||
return res
|
|
||||||
|
|
||||||
def _get_endpoint(self, path=None):
|
|
||||||
url = "https://%s" % (self.service_host)
|
|
||||||
if path is not None:
|
|
||||||
url += "/%s" % path
|
|
||||||
return url
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
#! /usr/bin/env python
|
|
||||||
|
|
||||||
import urllib2
|
|
||||||
import json
|
|
||||||
import zlib
|
|
||||||
import base64
|
|
||||||
from subprocess import call
|
|
||||||
from os.path import expanduser
|
|
||||||
import time
|
|
||||||
|
|
||||||
json_data=open(expanduser('~')+'/.conky/scripts/.passwords.json')
|
|
||||||
data = json.load(json_data)
|
|
||||||
username=data['github']['username']
|
|
||||||
password=data['github']['password']
|
|
||||||
|
|
||||||
#Put repos to publish
|
|
||||||
repos = data['github']['fav_repos']
|
|
||||||
|
|
||||||
request = urllib2.Request("https://api.github.com/users/" + username)
|
|
||||||
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
|
|
||||||
request.add_header("Authorization", "Basic %s" % base64string)
|
|
||||||
|
|
||||||
j = urllib2.urlopen(request)
|
|
||||||
json_data = j.read()
|
|
||||||
j_obj = json.loads(json_data)
|
|
||||||
|
|
||||||
|
|
||||||
print "${color1}Followers: ${color white}%d ${alignr}${color1}Updated: ${color white}%s" %(j_obj['followers'], time.strftime("%I:%M"))
|
|
||||||
|
|
||||||
for repo in repos:
|
|
||||||
repourl = "https://api.github.com/repos/"+ username +"/" + repo
|
|
||||||
|
|
||||||
request = urllib2.Request(repourl)
|
|
||||||
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
|
|
||||||
request.add_header("Authorization", "Basic %s" % base64string)
|
|
||||||
|
|
||||||
j = urllib2.urlopen(request)
|
|
||||||
json_data = j.read()
|
|
||||||
j_obj = json.loads(json_data)
|
|
||||||
|
|
||||||
print "${color white}%s ${goto 200}${color1}Starred: ${color white}%d ${color1}${alignr}Forks: ${color white}%d" %(j_obj['name'], j_obj['stargazers_count'], j_obj['forks_count'])
|
|
||||||
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
#! /usr/bin/env python3
|
|
||||||
|
|
||||||
import urllib.request
|
|
||||||
import urllib # For BasicHTTPAuthentication
|
|
||||||
import feedparser # For parsing the feed
|
|
||||||
from textwrap import wrap # For pretty printing assistance
|
|
||||||
import json
|
|
||||||
from os.path import expanduser
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
|
|
||||||
_URL = "https://mail.google.com/gmail/feed/atom/unread"
|
|
||||||
WRAP_LIMIT = 50
|
|
||||||
|
|
||||||
def auth():
|
|
||||||
|
|
||||||
json_data=open(expanduser('~')+'/.conky/scripts/.passwords.json')
|
|
||||||
data = json.load(json_data)
|
|
||||||
username=data['gmail']['username']
|
|
||||||
password=data['gmail']['password']
|
|
||||||
|
|
||||||
auth_handler = urllib.request.HTTPBasicAuthHandler()
|
|
||||||
auth_handler.add_password(realm='New mail feed',
|
|
||||||
uri='https://mail.google.com/',
|
|
||||||
user= username,
|
|
||||||
passwd= password)
|
|
||||||
|
|
||||||
opener = urllib.request.build_opener(auth_handler)
|
|
||||||
# ...and install it globally so it can be used with urlopen.
|
|
||||||
urllib.request.install_opener(opener)
|
|
||||||
|
|
||||||
'''The method to do HTTPBasicAuthentication'''
|
|
||||||
|
|
||||||
f = opener.open(_URL)
|
|
||||||
feed = f.read()
|
|
||||||
return feed
|
|
||||||
|
|
||||||
def fill(text, width):
|
|
||||||
'''A custom method to assist in pretty printing'''
|
|
||||||
if len(text) < width:
|
|
||||||
return text + ' '*(width-len(text))
|
|
||||||
else:
|
|
||||||
return text
|
|
||||||
|
|
||||||
def readmail(feed):
|
|
||||||
'''Parse the Atom feed and print a summary'''
|
|
||||||
atom = feedparser.parse(feed)
|
|
||||||
|
|
||||||
print ("${color white}You have %s new mails${color} ${alignr}Updated: ${color white}%s" % ((len(atom.entries)), time.strftime("%I:%M")))
|
|
||||||
|
|
||||||
for i in range(len(atom.entries)):
|
|
||||||
if(i>10):
|
|
||||||
break
|
|
||||||
if(len(atom.entries[i].title) > WRAP_LIMIT):
|
|
||||||
#print ("%s" % (fill(wrap(atom.entries[i].title, 50)[0]+" ...", 55)))
|
|
||||||
print ("${color1}%s" % (wrap(atom.entries[i].title, WRAP_LIMIT)[0]+" ..."))
|
|
||||||
else:
|
|
||||||
print ("${color1}%s" % (wrap(atom.entries[i].title, WRAP_LIMIT)[0]))
|
|
||||||
|
|
||||||
def countmail(feed):
|
|
||||||
'''Parse the Atom feed and print a summary'''
|
|
||||||
atom = feedparser.parse(feed)
|
|
||||||
print ("Emails: %s new" %len(atom.entries))
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
f = auth() # Do auth and then get the feed
|
|
||||||
if(len(sys.argv) > 1):
|
|
||||||
countmail(f)
|
|
||||||
else:
|
|
||||||
readmail(f) # Let the feed be chewed by feedparse
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#! /usr/bin/env python
|
|
||||||
|
|
||||||
import urllib2
|
|
||||||
import urllib
|
|
||||||
import json
|
|
||||||
from subprocess import call
|
|
||||||
from os.path import expanduser
|
|
||||||
import time
|
|
||||||
|
|
||||||
json_data=open(expanduser('~')+'/.conky/scripts/.passwords.json')
|
|
||||||
data = json.load(json_data)
|
|
||||||
key=data['pocket']['key']
|
|
||||||
access_token=data['pocket']['access_token']
|
|
||||||
|
|
||||||
|
|
||||||
data = {'consumer_key': key, 'access_token': access_token}
|
|
||||||
data = urllib.urlencode(data)
|
|
||||||
|
|
||||||
request = urllib2.Request("https://getpocket.com/v3/stats")
|
|
||||||
|
|
||||||
j = urllib2.urlopen(request, data)
|
|
||||||
json_data = j.read()
|
|
||||||
j_obj = json.loads(json_data)
|
|
||||||
|
|
||||||
|
|
||||||
print "${color1}Pocket Unread: ${alignr}${color white}%d" %(j_obj['count_unread'])
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#! /usr/bin/env python
|
|
||||||
|
|
||||||
import urllib2
|
|
||||||
import json
|
|
||||||
import zlib
|
|
||||||
from subprocess import call
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
from os.path import expanduser
|
|
||||||
|
|
||||||
json_data=open(expanduser('~')+'/.conky/scripts/.passwords.json')
|
|
||||||
data = json.load(json_data)
|
|
||||||
userid=data['so']['userid']
|
|
||||||
|
|
||||||
so = 'https://api.stackexchange.com/2.2/users/'+userid+'?order=desc&sort=reputation&site=stackoverflow'
|
|
||||||
|
|
||||||
j = urllib2.urlopen(so)
|
|
||||||
json_data = j.read()
|
|
||||||
if j.info()['Content-Encoding'] == 'gzip':
|
|
||||||
json_data = zlib.decompress(json_data, zlib.MAX_WBITS + 16)
|
|
||||||
j_obj = json.loads(json_data)
|
|
||||||
if(len(sys.argv) > 1):
|
|
||||||
print "%s: %s" %("Reputation", j_obj['items'][0]['reputation'])
|
|
||||||
else:
|
|
||||||
print "${color}%s: ${alignr}${color white} %s" %("Stackoverflow Reputation", j_obj['items'][0]['reputation'])
|
|
||||||
print " ${color}%s: ${alignr}${color white} %s" %("Month", j_obj['items'][0]['reputation_change_month'])
|
|
||||||
print " ${color}%s: ${alignr}${color white} %s" %("Week", j_obj['items'][0]['reputation_change_week'])
|
|
||||||
print " ${color}%s: ${alignr}${color white} %s" %("Day", j_obj['items'][0]['reputation_change_day'])
|
|
||||||
|
|
||||||
|
|
||||||
#call(['notify-send','Conky Updated'])
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#! /usr/bin/env python
|
|
||||||
|
|
||||||
import urllib2
|
|
||||||
import json
|
|
||||||
import zlib
|
|
||||||
import base64
|
|
||||||
from subprocess import call
|
|
||||||
from os.path import expanduser
|
|
||||||
|
|
||||||
json_data=open(expanduser('~')+'/.conky/scripts/.passwords.json')
|
|
||||||
data = json.load(json_data)
|
|
||||||
access_token=data['twitter']['access_token']
|
|
||||||
user = data['twitter']['user']
|
|
||||||
|
|
||||||
request = urllib2.Request("https://api.twitter.com/1.1/users/show.json?screen_name=" + user)
|
|
||||||
bearer_value = 'Bearer %s' % access_token
|
|
||||||
request.add_header("Authorization", bearer_value)
|
|
||||||
|
|
||||||
j = urllib2.urlopen(request)
|
|
||||||
json_data = j.read()
|
|
||||||
j_obj = json.loads(json_data)
|
|
||||||
|
|
||||||
|
|
||||||
print "${color1}Twitter Followers: ${alignr}${color white}%d" %(j_obj['followers_count'])
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
conky.config = {
|
|
||||||
use_spacer='none',
|
|
||||||
use_xft=true,
|
|
||||||
font='Open Sans Light:size=11',
|
|
||||||
text_buffer_size=2048,
|
|
||||||
update_interval=3600.0,
|
|
||||||
total_run_times=0,
|
|
||||||
|
|
||||||
own_window=true,
|
|
||||||
own_window_transparent=true,
|
|
||||||
own_window_type='normal',
|
|
||||||
own_window_hints='undecorated,skip_taskbar,skip_pager',
|
|
||||||
own_window_class='Conky-weather',
|
|
||||||
own_window_argb_visual=true,
|
|
||||||
own_window_argb_value=0,
|
|
||||||
|
|
||||||
draw_shades=false,
|
|
||||||
draw_outline=false,
|
|
||||||
draw_borders=false,
|
|
||||||
stippled_borders=0,
|
|
||||||
double_buffer=true,
|
|
||||||
draw_blended=false,
|
|
||||||
|
|
||||||
default_color='white',
|
|
||||||
default_shade_color='black',
|
|
||||||
--Minimum size of text area
|
|
||||||
maximum_width=1200 ,
|
|
||||||
|
|
||||||
alignment=bottom_right,
|
|
||||||
gap_x=20,
|
|
||||||
gap_y=20,
|
|
||||||
border_inner_margin=15,
|
|
||||||
border_outer_margin=0,
|
|
||||||
|
|
||||||
no_buffers=true,
|
|
||||||
net_avg_samples=2,
|
|
||||||
|
|
||||||
override_utf8_locale=true,
|
|
||||||
|
|
||||||
use_spacer=none,
|
|
||||||
|
|
||||||
short_units=on,
|
|
||||||
|
|
||||||
default_color=white,
|
|
||||||
color1 = 'ffffff',
|
|
||||||
color7 = '333333'
|
|
||||||
-- default_outline_color='black',--'00ccee',
|
|
||||||
-- lua_load = '~/.conky/arch/lua.lua'
|
|
||||||
};
|
|
||||||
conky.text = [[
|
|
||||||
${execp ~/.conky/weather/weather.py 890869}
|
|
||||||
]];
|
|
||||||
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
conky.config = {
|
|
||||||
use_spacer='none',
|
|
||||||
use_xft=true,
|
|
||||||
font='Open Sans Light:size=11',
|
|
||||||
text_buffer_size=2048,
|
|
||||||
update_interval=3600.0,
|
|
||||||
total_run_times=0,
|
|
||||||
|
|
||||||
own_window=true,
|
|
||||||
own_window_transparent=true,
|
|
||||||
own_window_type='normal',
|
|
||||||
own_window_hints='undecorated,skip_taskbar,skip_pager',
|
|
||||||
own_window_class='Conky-weather',
|
|
||||||
own_window_argb_visual=true,
|
|
||||||
own_window_argb_value=0,
|
|
||||||
|
|
||||||
draw_shades=false,
|
|
||||||
draw_outline=false,
|
|
||||||
draw_borders=false,
|
|
||||||
stippled_borders=0,
|
|
||||||
double_buffer=true,
|
|
||||||
draw_blended=false,
|
|
||||||
|
|
||||||
default_color='white',
|
|
||||||
default_shade_color='black',
|
|
||||||
--Minimum size of text area
|
|
||||||
maximum_width=1200 ,
|
|
||||||
|
|
||||||
alignment=bottom_right,
|
|
||||||
gap_x=20,
|
|
||||||
gap_y=20,
|
|
||||||
border_inner_margin=15,
|
|
||||||
border_outer_margin=0,
|
|
||||||
|
|
||||||
no_buffers=true,
|
|
||||||
net_avg_samples=2,
|
|
||||||
|
|
||||||
override_utf8_locale=true,
|
|
||||||
|
|
||||||
use_spacer=none,
|
|
||||||
|
|
||||||
short_units=on,
|
|
||||||
|
|
||||||
default_color=white,
|
|
||||||
color1 = 'ffffff',
|
|
||||||
color7 = '333333'
|
|
||||||
-- default_outline_color='black',--'00ccee',
|
|
||||||
-- lua_load = '~/.conky/arch/lua.lua'
|
|
||||||
};
|
|
||||||
conky.text = [[
|
|
||||||
${execp ~/.conky/weather/weather.py 909319}
|
|
||||||
]];
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"timestamp": "1546242922", "location": {"city": "Gothenburg", "country": "Sweden", "region": " Vastra Gotaland"}, "wind": {"chill": "25", "direction": "165", "speed": "27.36"}, "atmosphere": {"humidity": "93", "pressure": "34473.45", "rising": "0", "visibility": "20.28"}, "astronomy": {"sunrise": "8:56 am", "sunset": "3:36 pm"}, "lat": "57.701328", "long": "11.96689", "condition": {"code": "26", "date": "Mon, 31 Dec 2018 08:00 AM CET", "temp": "0", "text": "Cloudy"}, "forecast": [{"code": "26", "date": "31 Dec 2018", "day": "Mon", "high": "7", "low": "-1", "text": "Cloudy"}, {"code": "24", "date": "01 Jan 2019", "day": "Tue", "high": "7", "low": "3", "text": "Windy"}, {"code": "32", "date": "02 Jan 2019", "day": "Wed", "high": "2", "low": "0", "text": "Sunny"}, {"code": "30", "date": "03 Jan 2019", "day": "Thu", "high": "1", "low": "-2", "text": "Partly Cloudy"}, {"code": "28", "date": "04 Jan 2019", "day": "Fri", "high": "6", "low": "0", "text": "Mostly Cloudy"}, {"code": "30", "date": "05 Jan 2019", "day": "Sat", "high": "4", "low": "0", "text": "Partly Cloudy"}, {"code": "28", "date": "06 Jan 2019", "day": "Sun", "high": "5", "low": "0", "text": "Mostly Cloudy"}, {"code": "30", "date": "07 Jan 2019", "day": "Mon", "high": "5", "low": "2", "text": "Partly Cloudy"}, {"code": "30", "date": "08 Jan 2019", "day": "Tue", "high": "3", "low": "0", "text": "Partly Cloudy"}, {"code": "30", "date": "09 Jan 2019", "day": "Wed", "high": "3", "low": "0", "text": "Partly Cloudy"}]}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"timestamp": "1546242922", "location": {"city": "Vasteras", "country": "Sweden", "region": " Vastmanland"}, "wind": {"chill": "19", "direction": "190", "speed": "16.09"}, "atmosphere": {"humidity": "100", "pressure": "34541.18", "rising": "0", "visibility": "7.24"}, "astronomy": {"sunrise": "8:53 am", "sunset": "3:2 pm"}, "lat": "59.61998", "long": "16.53591", "condition": {"code": "26", "date": "Mon, 31 Dec 2018 08:00 AM CET", "temp": "-3", "text": "Cloudy"}, "forecast": [{"code": "28", "date": "31 Dec 2018", "day": "Mon", "high": "4", "low": "-3", "text": "Mostly Cloudy"}, {"code": "28", "date": "01 Jan 2019", "day": "Tue", "high": "6", "low": "0", "text": "Mostly Cloudy"}, {"code": "23", "date": "02 Jan 2019", "day": "Wed", "high": "0", "low": "-3", "text": "Breezy"}, {"code": "30", "date": "03 Jan 2019", "day": "Thu", "high": "-2", "low": "-5", "text": "Partly Cloudy"}, {"code": "28", "date": "04 Jan 2019", "day": "Fri", "high": "2", "low": "-3", "text": "Mostly Cloudy"}, {"code": "30", "date": "05 Jan 2019", "day": "Sat", "high": "3", "low": "-1", "text": "Partly Cloudy"}, {"code": "28", "date": "06 Jan 2019", "day": "Sun", "high": "1", "low": "-1", "text": "Mostly Cloudy"}, {"code": "28", "date": "07 Jan 2019", "day": "Mon", "high": "1", "low": "0", "text": "Mostly Cloudy"}, {"code": "30", "date": "08 Jan 2019", "day": "Tue", "high": "0", "low": "-3", "text": "Partly Cloudy"}, {"code": "30", "date": "09 Jan 2019", "day": "Wed", "high": "-1", "low": "-3", "text": "Partly Cloudy"}]}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
#! /usr/bin/env python3
|
|
||||||
|
|
||||||
import urllib
|
|
||||||
import json
|
|
||||||
#from subprocess import call
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
import os.path
|
|
||||||
import urllib.parse
|
|
||||||
import urllib.request
|
|
||||||
#import time
|
|
||||||
|
|
||||||
woeid=sys.argv[1]
|
|
||||||
path="/home/kuba/.conky/weather/last-"+woeid+".json"
|
|
||||||
#Try to download new data; overwrite existing file
|
|
||||||
def fetch_data():
|
|
||||||
base_url = "https://query.yahooapis.com/v1/public/yql"
|
|
||||||
sel_url = "?q=select%20location,wind,atmosphere,astronomy,item%20from%20weather.forecast"
|
|
||||||
where_url = "%20where%20u='c'%20and%20woeid%20=%20" + woeid
|
|
||||||
format_url = "&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"
|
|
||||||
yql_url = base_url + sel_url + where_url + format_url
|
|
||||||
try:
|
|
||||||
result = urllib.request.urlopen(yql_url).read()
|
|
||||||
data = json.loads(result)
|
|
||||||
ch = data['query']['results']['channel']
|
|
||||||
|
|
||||||
timestamp = str(round(time.time()))
|
|
||||||
parsed_data = {}#Don't save everything
|
|
||||||
parsed_data['timestamp'] = timestamp
|
|
||||||
for s in ['location', 'wind', 'atmosphere', 'astronomy']:
|
|
||||||
parsed_data.update({s : ch[s]})
|
|
||||||
for s in ['lat','long','condition','forecast']:
|
|
||||||
parsed_data.update({s : ch['item'][s]})
|
|
||||||
with open(path, 'w') as outfile:
|
|
||||||
json.dump(parsed_data, outfile)
|
|
||||||
except urllib.error.URLError:
|
|
||||||
pass
|
|
||||||
return
|
|
||||||
|
|
||||||
def print_output(data):
|
|
||||||
timestamp = int(data['timestamp'])
|
|
||||||
|
|
||||||
city = data['location']['city']
|
|
||||||
country = data['location']['country']
|
|
||||||
|
|
||||||
current_condition = data['condition']['text']
|
|
||||||
current_code = data['condition']['code']
|
|
||||||
current_temp = data['condition']['temp']
|
|
||||||
#weather_date = data['condition']['date']
|
|
||||||
|
|
||||||
speed_unit = "km/h"
|
|
||||||
speed = data['wind']['speed']
|
|
||||||
|
|
||||||
humidity = data['atmosphere']['humidity']
|
|
||||||
|
|
||||||
forecast = []
|
|
||||||
for forec in data['forecast']:
|
|
||||||
forecast.append((forec['day'], forec['low'], forec['high'] , forec['code']))
|
|
||||||
|
|
||||||
|
|
||||||
print ("${font Open Sans:size=15:style=Light}%s, %s " % (city, country), end = '')
|
|
||||||
print ("${font :size=6}${alignr}${color7}Updated: ${color white}%s ${color7}Fetched: ${color white}%s" % (time.strftime("%I:%M"), time.strftime("%m/%d %H:%M", time.gmtime(timestamp))))
|
|
||||||
print ("${color7}${hr}${color}")
|
|
||||||
print ("${voffset -5}${font Open Sans:size=60:style=Light}%s°${font}" %(current_temp))
|
|
||||||
print ("${offset 250}${voffset -65}%s" %(current_condition))
|
|
||||||
print ("${image ~/.conky/.conky-google-now/%s.png -p 180,45 -s 60x60}" %(current_code))
|
|
||||||
print ("${image ~/.conky/.conky-google-now/wind.png -p 245,62 -s 15x15}${goto 35}${offset 250}${voffset -12}%s %s" %(speed, speed_unit), end = '')
|
|
||||||
print ("${goto 400}%s ${goto 530} %s" %(forecast[0][0].upper(), forecast[1][0].upper()))
|
|
||||||
print ("${image ~/.conky/.conky-google-now/humidity.png -p 245,81 -s 15x15}${goto 35}${offset 250}%s %s" %(humidity,"%"), end = '')
|
|
||||||
print ("${goto 400}%s°${color6}%s°${color}${goto 530}%s°${color6}%s°${color}${voffset 15}" %(forecast[0][2], forecast[0][1], forecast[1][2], forecast[1][1]))
|
|
||||||
print ("${image ~/.conky/.conky-google-now/%s.png -p 440,65 -s 30x30}${image ~/.conky/.conky-google-now/%s.png -p 570,65 -s 30x30}${voffset -10}" %(forecast[0][3], forecast[1][3]))
|
|
||||||
return
|
|
||||||
|
|
||||||
#Open existing file and check if it's not too old
|
|
||||||
if not (os.path.isfile(path)):
|
|
||||||
fetch_data()
|
|
||||||
with open(path) as infile:
|
|
||||||
data = json.load(infile)
|
|
||||||
ts = int(data['timestamp'])
|
|
||||||
now = round(time.time())
|
|
||||||
if (ts + 3600 < now):
|
|
||||||
fetch_data()
|
|
||||||
ts = now
|
|
||||||
print_output(data)
|
|
||||||
14
.etcfiles/krb5.conf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[domain_realm]
|
||||||
|
.pdc.kth.se = NADA.KTH.SE
|
||||||
|
.chalmers.se = CHALMERS.SE
|
||||||
|
chalmers.se = CHALMERS.SE
|
||||||
|
|
||||||
|
[appdefaults]
|
||||||
|
forwardable = yes
|
||||||
|
forward = yes
|
||||||
|
krb4_get_tickets = no
|
||||||
|
|
||||||
|
[libdefaults]
|
||||||
|
default_realm = NADA.KTH.SE
|
||||||
|
dns_lookup_realm = true
|
||||||
|
dns_lookup_kdc = true
|
||||||
2
.etcfiles/lightdm/lightdm.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[Seat:*]
|
||||||
|
greeter-session=lightdm-webkit2-greeter
|
||||||
8
.etcfiles/package-list-ubuntu
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
git-lfs
|
||||||
|
gnuplot-x11
|
||||||
|
graphviz
|
||||||
|
htop
|
||||||
|
terminator
|
||||||
|
tmux
|
||||||
|
gnome-session
|
||||||
|
lmod
|
||||||
17
.gitconfig
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
[user]
|
||||||
|
email = jakub.fojt96@gmail.com
|
||||||
|
name = Jakub Fojt
|
||||||
|
[filter "lfs"]
|
||||||
|
clean = git-lfs clean -- %f
|
||||||
|
smudge = git-lfs smudge -- %f
|
||||||
|
process = git-lfs filter-process
|
||||||
|
required = true
|
||||||
|
[credential]
|
||||||
|
helper = cache --timeout=3600
|
||||||
|
[color]
|
||||||
|
ui = auto
|
||||||
|
[pull]
|
||||||
|
ff = only
|
||||||
|
[init]
|
||||||
|
deafaultBranch = main
|
||||||
|
defaultBranch = main
|
||||||
6
.gitmodules
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[submodule "scripts/healthy-disk-usage"]
|
||||||
|
path = scripts/healthy-disk-usage
|
||||||
|
url = https://isabeljake.duckdns.org/gitea/kuba/healthy-disk-usage.git
|
||||||
|
[submodule ".i3"]
|
||||||
|
path = .i3
|
||||||
|
url = https://isabeljake.duckdns.org/gitea/kuba/i3-config.git
|
||||||
1
.i3
Submodule
@@ -1,10 +0,0 @@
|
|||||||
sleep 2
|
|
||||||
conky -c ~/.conky/arch/.conkyrc-arch &
|
|
||||||
conky -c ~/.conky/gmail/.conkyrc-gmail &
|
|
||||||
conky -c ~/.conky/weather/.conkyrc-weather1 &
|
|
||||||
conky -c ~/.conky/weather/.conkyrc-weather2 &
|
|
||||||
conky -c ~/.conky/music/.conkyrc-music &
|
|
||||||
python ~/.conky/music/playerctl_listen.py &
|
|
||||||
sh ~/.conky/music/launcher.sh &
|
|
||||||
python ~/.i3/lemonbar/i3_lemonbar_launcher.py --debug >> /tmp/kuba_lemonbar_launcher.log &
|
|
||||||
compton -b # --config=/home/kuba/.compton.conf
|
|
||||||
158
.i3/base.config
@@ -1,158 +0,0 @@
|
|||||||
# General setup
|
|
||||||
####
|
|
||||||
|
|
||||||
set $mod Mod4
|
|
||||||
set $TERMINAL terminator
|
|
||||||
|
|
||||||
font pango:FontAwesome 11
|
|
||||||
|
|
||||||
# Use Mouse+$mod to drag floating windows to their wanted position
|
|
||||||
floating_modifier $mod
|
|
||||||
|
|
||||||
focus_follows_mouse no
|
|
||||||
mouse_warping none
|
|
||||||
workspace_auto_back_and_forth yes
|
|
||||||
#force_display_urgency_hint 500 ms
|
|
||||||
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Key bindings
|
|
||||||
####
|
|
||||||
|
|
||||||
# start a terminal
|
|
||||||
bindsym $mod+Return exec $TERMINAL
|
|
||||||
|
|
||||||
# kill focused window
|
|
||||||
bindsym $mod+Shift+q kill
|
|
||||||
|
|
||||||
# start dmenu (a program launcher)
|
|
||||||
bindsym $mod+d exec dmenu_run
|
|
||||||
bindsym $mod+Shift+d exec --no-startup-id i3-dmenu-desktop
|
|
||||||
|
|
||||||
# change focus
|
|
||||||
bindsym $mod+j focus left
|
|
||||||
bindsym $mod+k focus down
|
|
||||||
bindsym $mod+l focus up
|
|
||||||
bindsym $mod+semicolon focus right
|
|
||||||
|
|
||||||
# alternatively, you can use the cursor keys:
|
|
||||||
bindsym $mod+Left focus left
|
|
||||||
bindsym $mod+Down focus down
|
|
||||||
bindsym $mod+Up focus up
|
|
||||||
bindsym $mod+Right focus right
|
|
||||||
|
|
||||||
# move focused window
|
|
||||||
bindsym $mod+Shift+j move left
|
|
||||||
bindsym $mod+Shift+k move down
|
|
||||||
bindsym $mod+Shift+l move up
|
|
||||||
bindsym $mod+Shift+semicolon move right
|
|
||||||
|
|
||||||
# alternatively, you can use the cursor keys:
|
|
||||||
bindsym $mod+Shift+Left move left
|
|
||||||
bindsym $mod+Shift+Down move down
|
|
||||||
bindsym $mod+Shift+Up move up
|
|
||||||
bindsym $mod+Shift+Right move right
|
|
||||||
|
|
||||||
# split in horizontal orientation
|
|
||||||
bindsym $mod+h split h
|
|
||||||
|
|
||||||
# split in vertical orientation
|
|
||||||
bindsym $mod+v split v
|
|
||||||
|
|
||||||
# enter fullscreen mode for the focused container
|
|
||||||
bindsym $mod+f fullscreen toggle
|
|
||||||
|
|
||||||
# change container layout (stacked, tabbed, toggle split)
|
|
||||||
bindsym $mod+s layout stacking
|
|
||||||
bindsym $mod+w layout tabbed
|
|
||||||
bindsym $mod+e layout toggle split
|
|
||||||
|
|
||||||
# toggle tiling / floating
|
|
||||||
bindsym $mod+Shift+space floating toggle
|
|
||||||
|
|
||||||
# change focus between tiling / floating windows
|
|
||||||
bindsym $mod+space focus mode_toggle
|
|
||||||
|
|
||||||
# focus the parent container
|
|
||||||
bindsym $mod+a focus parent
|
|
||||||
|
|
||||||
# focus the child container
|
|
||||||
#bindsym $mod+d focus child
|
|
||||||
|
|
||||||
# switch to workspace
|
|
||||||
bindsym $mod+1 workspace number $w1
|
|
||||||
bindsym $mod+2 workspace number $w2
|
|
||||||
bindsym $mod+3 workspace number $w3
|
|
||||||
bindsym $mod+4 workspace number $w4
|
|
||||||
bindsym $mod+5 workspace number $w5
|
|
||||||
bindsym $mod+6 workspace number $w6
|
|
||||||
bindsym $mod+7 workspace number $w7
|
|
||||||
bindsym $mod+8 workspace number $w8
|
|
||||||
bindsym $mod+9 workspace number $w9
|
|
||||||
bindsym $mod+0 workspace number $w10
|
|
||||||
|
|
||||||
# move focused container to workspace
|
|
||||||
bindsym $mod+Shift+1 move container to workspace number $w1
|
|
||||||
bindsym $mod+Shift+2 move container to workspace number $w2
|
|
||||||
bindsym $mod+Shift+3 move container to workspace number $w3
|
|
||||||
bindsym $mod+Shift+4 move container to workspace number $w4
|
|
||||||
bindsym $mod+Shift+5 move container to workspace number $w5
|
|
||||||
bindsym $mod+Shift+6 move container to workspace number $w6
|
|
||||||
bindsym $mod+Shift+7 move container to workspace number $w7
|
|
||||||
bindsym $mod+Shift+8 move container to workspace number $w8
|
|
||||||
bindsym $mod+Shift+9 move container to workspace number $w9
|
|
||||||
bindsym $mod+Shift+0 move container to workspace number $w10
|
|
||||||
|
|
||||||
bindsym $mod+o move workspace to output right
|
|
||||||
|
|
||||||
# reload the configuration file
|
|
||||||
bindsym $mod+Shift+c reload
|
|
||||||
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
|
|
||||||
bindsym $mod+Shift+r restart
|
|
||||||
# exit i3 (logs you out of your X session)
|
|
||||||
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
|
|
||||||
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Define modes
|
|
||||||
####
|
|
||||||
|
|
||||||
set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown
|
|
||||||
mode "$mode_system" {
|
|
||||||
bindsym l exec --no-startup-id .i3/i3exit.sh lock, mode "default"
|
|
||||||
bindsym e exec --no-startup-id .i3/i3exit.sh logout, mode "default"
|
|
||||||
bindsym s exec --no-startup-id .i3/i3exit.sh suspend, mode "default"
|
|
||||||
bindsym h exec --no-startup-id .i3/i3exit.sh hibernate, mode "default"
|
|
||||||
bindsym r exec --no-startup-id .i3/i3exit.sh reboot, mode "default"
|
|
||||||
bindsym Shift+s exec --no-startup-id .i3/i3exit.sh shutdown, mode "default"
|
|
||||||
|
|
||||||
# back to normal: Enter or Escape
|
|
||||||
bindsym Return mode "default"; exec sh .i3/lemonbar/set_mode.sh mode normal
|
|
||||||
bindsym Escape mode "default"; exec sh .i3/lemonbar/set_mode.sh mode normal
|
|
||||||
}
|
|
||||||
|
|
||||||
# resize window (you can also use the mouse for that)
|
|
||||||
mode "resize" {
|
|
||||||
# These bindings trigger as soon as you enter the resize mode
|
|
||||||
|
|
||||||
# Pressing left will shrink the window’s width.
|
|
||||||
# Pressing right will grow the window’s width.
|
|
||||||
# Pressing up will shrink the window’s height.
|
|
||||||
# Pressing down will grow the window’s height.
|
|
||||||
bindsym h resize shrink width 10 px or 10 ppt
|
|
||||||
bindsym k resize grow height 10 px or 10 ppt
|
|
||||||
bindsym j resize shrink height 10 px or 10 ppt
|
|
||||||
bindsym l resize grow width 10 px or 10 ppt
|
|
||||||
|
|
||||||
# same bindings, but for the arrow keys
|
|
||||||
bindsym Left resize shrink width 10 px or 10 ppt
|
|
||||||
bindsym Up resize grow height 10 px or 10 ppt
|
|
||||||
bindsym Down resize shrink height 10 px or 10 ppt
|
|
||||||
bindsym Right resize grow width 10 px or 10 ppt
|
|
||||||
|
|
||||||
# back to normal: Enter or Escape
|
|
||||||
bindsym Return mode "default"
|
|
||||||
bindsym Escape mode "default"
|
|
||||||
}
|
|
||||||
|
|
||||||
bindsym $mod+r mode "resize"
|
|
||||||
114
.i3/home.config
@@ -1,114 +0,0 @@
|
|||||||
set $w1 1 main
|
|
||||||
set $w2 2 web
|
|
||||||
set $w3 3 mu
|
|
||||||
set $w4 4 work
|
|
||||||
set $w5 5 terms
|
|
||||||
set $w6 6 stats
|
|
||||||
set $w7 7
|
|
||||||
set $w8 8
|
|
||||||
set $w9 9
|
|
||||||
set $w10 10 games
|
|
||||||
|
|
||||||
set $below_barY 24
|
|
||||||
#set $volX 1400
|
|
||||||
#set $brX 1485
|
|
||||||
#set $calX 1650
|
|
||||||
set $htopX 400
|
|
||||||
set $pavuX 800
|
|
||||||
|
|
||||||
for_window [class="Terminator"] border pixel 0
|
|
||||||
for_window [class="YADWIN"] floating enable
|
|
||||||
for_window [class="FLOAT_PAVU"] floating enable
|
|
||||||
for_window [class="FLOAT_PAVU"] resize set 800 540
|
|
||||||
for_window [class="FLOAT_PAVU"] border pixel 3
|
|
||||||
for_window [class="FLOAT_PAVU"] move absolute position $pavuX px $below_barY px
|
|
||||||
for_window [window_role="FLOAT_TERM"] floating enable
|
|
||||||
for_window [window_role="FLOAT_TERM"] move absolute position $htopX px $below_barY px
|
|
||||||
for_window [window_role="FLOAT_TERM"] border pixel 3
|
|
||||||
for_window [title="Memory"] floating enable
|
|
||||||
for_window [class="Matplotlib"] floating enable
|
|
||||||
for_window [class="Chromium"] border pixel 0
|
|
||||||
for_window [class="^.*"] border pixel 0
|
|
||||||
for_window [window_type="toolbar"] border pixel 3
|
|
||||||
for_window [window_type="splash"] border pixel 3
|
|
||||||
for_window [window_type="dialog"] border pixel 3
|
|
||||||
for_window [window_type="utility"] border pixel 3
|
|
||||||
for_window [window_role="pop-up"] floating enable
|
|
||||||
for_window [title="VMD 1.9.3 OpenGL Display"] floating enable
|
|
||||||
for_window [title="Terminator Preferences"] floating enable
|
|
||||||
for_window [title="Figure *"] floating enable
|
|
||||||
#for_window [title="VMD"] floating enable
|
|
||||||
|
|
||||||
assign [class="firefox"] → $w2
|
|
||||||
assign [class="Chromium"] → $w2
|
|
||||||
assign [class="libreoffice*"] → $w4
|
|
||||||
assign [class="soffice*"] → $w4
|
|
||||||
assign [class="MATLAB*"] → $w4
|
|
||||||
assign [window_role="ranger"] → $w1
|
|
||||||
assign [window_role="terms"] → $w5
|
|
||||||
assign [window_role="stats"] → $w6
|
|
||||||
assign [class="Minecraft*"] → $w10
|
|
||||||
assign [title="Feed The Beast Launcher*"] → $w10
|
|
||||||
#Spotify bug, assign doesn't work
|
|
||||||
for_window [class="Spotify"] move to workspace $w3
|
|
||||||
|
|
||||||
# Gaps settings
|
|
||||||
####
|
|
||||||
|
|
||||||
gaps inner 0
|
|
||||||
gaps outer 0
|
|
||||||
|
|
||||||
workspace 1 gaps inner 10
|
|
||||||
workspace 4 gaps inner 10
|
|
||||||
workspace 5 gaps inner 10
|
|
||||||
workspace 6 gaps inner 60
|
|
||||||
|
|
||||||
# Multimedia Bindings
|
|
||||||
####
|
|
||||||
|
|
||||||
# pulse audio volume control
|
|
||||||
bindsym XF86AudioRaiseVolume exec ~/.i3/scripts/level.sh -v up
|
|
||||||
bindsym XF86AudioLowerVolume exec ~/.i3/scripts/level.sh -v down
|
|
||||||
bindsym XF86AudioMute exec ~/.i3/scripts/level.sh -v toggle
|
|
||||||
bindsym XF86MonBrightnessUp exec ~/.i3/scripts/level.sh -b up
|
|
||||||
bindsym XF86MonBrightnessDown exec ~/.i3/scripts/level.sh -b down
|
|
||||||
bindsym $mod+F8 exec playerctl play-pause
|
|
||||||
bindsym $mod+F9 exec playerctl next
|
|
||||||
bindsym $mod+F7 exec playerctl previous
|
|
||||||
bindsym XF86AudioPlay exec playerctl play
|
|
||||||
bindsym XF86AudioPause exec playerctl pause
|
|
||||||
bindsym XF86AudioNext exec playerctl next
|
|
||||||
bindsym XF86AudioPrevious exec playerctl previous
|
|
||||||
|
|
||||||
bindsym Print exec scrot '%Y-%m-%d-%T_$wx$h_scrot.png' -e 'mv $f ~/Obrazy/screenshots/'
|
|
||||||
bindsym Shift + Print exec scrot -s '%Y-%m-%d-%T_$wx$h_scrot.png' -e 'mv $f ~/Obrazy/screenshots/'
|
|
||||||
|
|
||||||
bindsym $mod+m exec sh ~/.i3/scripts/lang.sh next
|
|
||||||
|
|
||||||
# Exiting
|
|
||||||
####
|
|
||||||
|
|
||||||
bindsym XF86Sleep exec sh ~/.i3/i3exit.sh lock
|
|
||||||
bindsym XF86PowerOff mode "$mode_system"; exec sh .i3/lemonbar/set_mode.sh mode power
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
####
|
|
||||||
# layout settings
|
|
||||||
####
|
|
||||||
bindsym $mod+u exec feh --bg-scale /home/kuba/Obrazy/Wallpapers/AxEcN\ -\ Imgur.jpg
|
|
||||||
#exec compton -b
|
|
||||||
#workspace 1 main
|
|
||||||
exec --no-startup-id $TERMINAL --role "ranger" -x ranger
|
|
||||||
|
|
||||||
#exec --no-startup-id i3-msg 'workspace 5 terms"
|
|
||||||
exec --no-startup-id $TERMINAL --role "terms"
|
|
||||||
exec --no-startup-id $TERMINAL --role "terms"
|
|
||||||
|
|
||||||
#workspace 6 stats;
|
|
||||||
exec --no-startup-id i3-msg 'append_layout /home/kuba/.i3/workspace_6.json; rename workspace to "6 stats"'
|
|
||||||
#Set appropriate background image before starting conkys
|
|
||||||
exec --no-startup-id feh --bg-scale /home/kuba/Obrazy/Wallpapers/6_stats
|
|
||||||
|
|
||||||
#Start conky's in .i3/.autostart
|
|
||||||
exec sh ~/.i3/.autostart
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
lock() {
|
|
||||||
# Credit: https://github.com/petvas/i3lock-blur
|
|
||||||
# TODO Handle several screens
|
|
||||||
TMPBG=/tmp/screen_locked.png
|
|
||||||
LOCK=~/.i3/lock.png
|
|
||||||
RES=$(xrandr | grep 'current' | sed -E 's/.*current\s([0-9]+)\sx\s([0-9]+).*/\1x\2/')
|
|
||||||
|
|
||||||
#ffmpeg -f x11grab -video_size $RES -y -i $DISPLAY -i $LOCK -filter_complex \
|
|
||||||
# "boxblur=5:1,overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" \
|
|
||||||
# -vframes 1 $TMPBG -loglevel quiet
|
|
||||||
ffmpeg -f x11grab -video_size $RES -y -i $DISPLAY -filter_complex \
|
|
||||||
"boxblur=5:1" -vframes 1 $TMPBG -loglevel quiet
|
|
||||||
i3lock -i $TMPBG
|
|
||||||
rm $TMPBG
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
lock)
|
|
||||||
lock
|
|
||||||
;;
|
|
||||||
logout)
|
|
||||||
i3-msg exit
|
|
||||||
;;
|
|
||||||
suspend)
|
|
||||||
lock && sudo pm-suspend
|
|
||||||
;;
|
|
||||||
lidclose)
|
|
||||||
lock && sudo pm-suspend
|
|
||||||
;;
|
|
||||||
hibernate)
|
|
||||||
lock && sudo pm-hibernate
|
|
||||||
;;
|
|
||||||
reboot)
|
|
||||||
systemctl reboot
|
|
||||||
;;
|
|
||||||
shutdown)
|
|
||||||
systemctl poweroff
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
|
|
||||||
exit 2
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
1
.i3/lemonbar/cache/credentials.json
vendored
@@ -1 +0,0 @@
|
|||||||
{"username":"kuben-","auth_type":1,"auth_data":"QVFDYzhMY0tnZ2g2M2N1czFhcXI4c0xRMkQzc3pRdXlFZVVVeEVzN0xRRE1VSnItVmw3Z05XWWhRVUNCX2pqS25mSXhGcVRyV0RFcGtTWVFMR3pzSG1jZVdTY0JnNnJFT0hDdFptdzM="}
|
|
||||||
1
.i3/lemonbar/cache/volume
vendored
@@ -1 +0,0 @@
|
|||||||
49151
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
-- Conky for external bar
|
|
||||||
-- out simple text to console
|
|
||||||
|
|
||||||
conky.config = {
|
|
||||||
background=false,
|
|
||||||
update_interval=0.2,
|
|
||||||
total_run_times=0,
|
|
||||||
override_utf8_locale=true,
|
|
||||||
short_units=true,
|
|
||||||
uppercase=false,
|
|
||||||
out_to_console=true,
|
|
||||||
out_to_x=false,
|
|
||||||
if_up_strictness='address',
|
|
||||||
format_human_readable=true,
|
|
||||||
}
|
|
||||||
|
|
||||||
conky.text = [[
|
|
||||||
CNK_FAST \
|
|
||||||
${time %a %d %b %H:%M:%S} \
|
|
||||||
${exec ~/.i3/lemonbar/get_vol.sh} \
|
|
||||||
${if_up wlp3s0}${downspeedf wlp3s0} ${upspeedf wlp3s0}\
|
|
||||||
${else}down down${endif}\
|
|
||||||
\
|
|
||||||
${if_up enp2s0}${downspeedf enp2s0} ${upspeedf enp2s0}\
|
|
||||||
${else}down down${endif}\
|
|
||||||
\
|
|
||||||
]]
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
-- Conky for external bar
|
|
||||||
-- out simple text to console
|
|
||||||
|
|
||||||
conky.config = {
|
|
||||||
background=false,
|
|
||||||
update_interval=5,
|
|
||||||
total_run_times=0,
|
|
||||||
override_utf8_locale=true,
|
|
||||||
short_units=true,
|
|
||||||
uppercase=false,
|
|
||||||
out_to_console=true,
|
|
||||||
out_to_x=false,
|
|
||||||
if_up_strictness='address',
|
|
||||||
format_human_readable=true,
|
|
||||||
}
|
|
||||||
|
|
||||||
conky.text = [[
|
|
||||||
CNK_SLOW \
|
|
||||||
${cpu} \
|
|
||||||
${mem} \
|
|
||||||
${fs_used_perc /} \
|
|
||||||
${fs_used_perc /home} \
|
|
||||||
${exec ~/.i3/lemonbar/get_bat.sh} \
|
|
||||||
${exec brillo} \
|
|
||||||
${exec /home/kuba/.i3/scripts/lang.sh show}
|
|
||||||
]]
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
acpi | head -n 1 | awk '{pct = substr($4, 1, length($4)-2);\
|
|
||||||
if($3 ~ "Dis") print "D"pct;\
|
|
||||||
else if($3 ~ "Cha") printf "C"pct;\
|
|
||||||
else print "F"substr($5, 1, length($5)-1);}'
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
RTN=$(amixer get Master | grep "Front Left: Playback" | \
|
|
||||||
awk -F'[]%[]' '{if ($5 == "off") {print "MUTE"} else {printf "%d", $2}}')
|
|
||||||
if [[ -z $RTN ]]; then
|
|
||||||
echo "NONE"
|
|
||||||
else
|
|
||||||
echo "$RTN"
|
|
||||||
fi
|
|
||||||
@@ -1,153 +0,0 @@
|
|||||||
import subprocess, os, getpass
|
|
||||||
import re # regexp
|
|
||||||
from enum import Enum
|
|
||||||
|
|
||||||
import i3_lemonbar_config as config
|
|
||||||
|
|
||||||
kill_on_unfocus = []
|
|
||||||
|
|
||||||
# Loggers, initialized in main function
|
|
||||||
logger = None
|
|
||||||
health_logger = None
|
|
||||||
|
|
||||||
screen = None
|
|
||||||
parsing_queue = None
|
|
||||||
|
|
||||||
class bar_mode(Enum):
|
|
||||||
power, normal, control = range(-1,2) # Don't cycle through power
|
|
||||||
|
|
||||||
def cycle(self):
|
|
||||||
try:
|
|
||||||
return bar_mode(self.value + 1)
|
|
||||||
except ValueError:
|
|
||||||
return bar_mode(0)
|
|
||||||
|
|
||||||
mode = bar_mode.normal
|
|
||||||
|
|
||||||
floatterm_args = lambda prog : ['terminator', '-r', 'FLOAT_TERM', '-p'
|
|
||||||
, 'dark', '-e', 'echo kill_unfocus $$ > {}; exec {}'.format(
|
|
||||||
config.fifo_file_executor, prog)]
|
|
||||||
def date_comm(args):
|
|
||||||
subprocess.Popen(['yad', '--no-buttons', '--calendar', '--sticky'
|
|
||||||
, '--on-top' , '--class' , '"YADWIN"', '--posx=1650', '--posy=24'
|
|
||||||
, '--close-on-unfocus'])
|
|
||||||
|
|
||||||
def pavu_comm(args):
|
|
||||||
global kill_on_unfocus
|
|
||||||
p = subprocess.Popen(['pavucontrol', '--class=FLOAT_PAVU'])
|
|
||||||
kill_on_unfocus.append(p.pid)
|
|
||||||
|
|
||||||
def htop_comm(args):
|
|
||||||
subprocess.Popen(floatterm_args('htop'))
|
|
||||||
|
|
||||||
def nmtui_comm(args):
|
|
||||||
subprocess.Popen(floatterm_args('nmtui'))
|
|
||||||
def lang_comm(args):
|
|
||||||
subprocess.Popen(['sh', '/home/kuba/.i3/scripts/lang.sh', 'next'])
|
|
||||||
def dpms_comm(args):
|
|
||||||
subprocess.Popen(['sh', '/home/kuba/.i3/scripts/dpmsctl.sh'])
|
|
||||||
def adj_br(args):
|
|
||||||
subprocess.Popen(['/home/kuba/.i3/scripts/adjbr.sh', '-b', config.fifo_file_executor])
|
|
||||||
def i3msg_comm(args):
|
|
||||||
subprocess.Popen(args.split())
|
|
||||||
def add_tokill(args):
|
|
||||||
global kill_on_unfocus
|
|
||||||
kill_on_unfocus.append(int(args.split()[1]))
|
|
||||||
def set_mode(args):
|
|
||||||
global mode
|
|
||||||
new_mode = args.split()[1]
|
|
||||||
if new_mode == "cycle":
|
|
||||||
mode = mode.cycle()
|
|
||||||
|
|
||||||
for m in bar_mode:
|
|
||||||
if new_mode == m.name:
|
|
||||||
mode = m
|
|
||||||
break
|
|
||||||
def bluetooth(args):
|
|
||||||
btcargs = args.split()[1:]
|
|
||||||
btcargs = [a.replace('pxc550', '00:16:94:22:29:0E') for a in btcargs]
|
|
||||||
inp = ' '.join(btcargs)
|
|
||||||
screen.send_cmd('bluetoothctl ' + inp)
|
|
||||||
|
|
||||||
show_secs = False
|
|
||||||
def toggle_secs(args):
|
|
||||||
global show_secs
|
|
||||||
show_secs = not show_secs
|
|
||||||
|
|
||||||
# Keymaps
|
|
||||||
def_keymap = 'pl'
|
|
||||||
keymaps = {'Firefox': 'se'}
|
|
||||||
cur_class = ''
|
|
||||||
def set_lang(args):
|
|
||||||
global keymaps
|
|
||||||
lang = args.split()[1]
|
|
||||||
keymaps[cur_class] = lang
|
|
||||||
|
|
||||||
commands_dict = {'toggle_secs': toggle_secs
|
|
||||||
,'date': date_comm
|
|
||||||
,'pavu': pavu_comm
|
|
||||||
,'load': htop_comm
|
|
||||||
,'wlan': nmtui_comm
|
|
||||||
,'dpms': dpms_comm
|
|
||||||
,'i3-msg': i3msg_comm
|
|
||||||
,'switch_lang': lang_comm
|
|
||||||
,'kill_unfocus': add_tokill
|
|
||||||
,'mode': set_mode
|
|
||||||
,'adj_br': adj_br
|
|
||||||
,'setlang': set_lang
|
|
||||||
,'bluetooth': bluetooth
|
|
||||||
}
|
|
||||||
|
|
||||||
# Helper functions
|
|
||||||
ansi_escape = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -/]*[@-~]')
|
|
||||||
def strip_ansi_unicode(s):
|
|
||||||
# ANSI escape sequences are for colors in terminal and similar
|
|
||||||
strip_ansi = ansi_escape.sub('', s)
|
|
||||||
strip_unicode = (strip_ansi.encode('ascii', 'ignore')).decode('utf-8')
|
|
||||||
return strip_unicode
|
|
||||||
|
|
||||||
def create_new_fifo(fifo_file):
|
|
||||||
"""
|
|
||||||
Create new fifo file, removing old one if it exists
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
os.remove(fifo_file)
|
|
||||||
logger.debug('''Removed old fifo file''')
|
|
||||||
except OSError:
|
|
||||||
logger.debug('''No old fifo file, good''')
|
|
||||||
|
|
||||||
try:
|
|
||||||
os.mkfifo(fifo_file)
|
|
||||||
except OSError:
|
|
||||||
logger.error('''Failed, couldn't create fifo file''')
|
|
||||||
os.remove(config.pid_file) # Clean up own PID file
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
class LemonbarScreen:
|
|
||||||
# Start, stop and send commands to screen instance
|
|
||||||
|
|
||||||
# Start detached, in UTF-8 mode. Log to fifo
|
|
||||||
start_flags = ['-d', '-m', '-U', '-L', '-Logfile', config.fifo_screen_log]
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.identifier = 'lemonbar_{}_{}'.format(getpass.getuser(), os.getpid())
|
|
||||||
|
|
||||||
create_new_fifo(config.fifo_screen_log)
|
|
||||||
self.send(self.start_flags) # Start screen
|
|
||||||
self.send_cmd('stty -echo') # Do not echo what is written to screen terminal
|
|
||||||
self.send_colon('logfile flush 0.1') # Log quickly
|
|
||||||
|
|
||||||
def destroy(self):
|
|
||||||
self.send_colon('kill')
|
|
||||||
|
|
||||||
def send(self, args):
|
|
||||||
# Send something to our screen instance
|
|
||||||
subprocess.call(['screen', '-S', self.identifier] + args)
|
|
||||||
|
|
||||||
def send_cmd(self, cmd):
|
|
||||||
# Send terminal input to our screen instance
|
|
||||||
self.send(['-X', 'stuff', cmd + '\n'])
|
|
||||||
|
|
||||||
def send_colon(self, cmd):
|
|
||||||
# Send colon command to our screen instance
|
|
||||||
self.send(['-X', 'colon', cmd + '\n'])
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
import subprocess
|
|
||||||
import getpass
|
|
||||||
|
|
||||||
# File locations
|
|
||||||
pid_file = '/tmp/i3_lemonbar_launcher.pid'
|
|
||||||
fifo_file_status = '/tmp/i3_lemonbar1_{}'.format(getpass.getuser())
|
|
||||||
fifo_screen_log = '/tmp/i3_screen_{}'.format(getpass.getuser())
|
|
||||||
health_file = '/tmp/i3_lemonbar_health.info'
|
|
||||||
|
|
||||||
path="/home/kuba/.i3/lemonbar/"
|
|
||||||
logpath="/home/kuba/lemonbar.log" # Write here on exceptions
|
|
||||||
|
|
||||||
# color definitions
|
|
||||||
color_back = "#FF1D1F21" # Default background
|
|
||||||
color_fore = "#FFC5C8C6" # Default foreground
|
|
||||||
color_poweropts = "#FF620A00"
|
|
||||||
color_head = "#FFB5BD68" # Background for first element
|
|
||||||
color_sec_b1 = "#FF282A2E" # Background for section 1
|
|
||||||
color_sec_b2 = "#FF454A4F" # Background for section 2
|
|
||||||
color_sec_b3 = "#FF60676E" # Background for section 3
|
|
||||||
color_vga = "#FF3F8C0F"
|
|
||||||
color_hdmi = "#FFDD5435"
|
|
||||||
color_icon = "#FF979997" # For icons
|
|
||||||
color_cpu = "#FF5F819D" # Background color for cpu alert
|
|
||||||
color_net = "#FF5E8D87" # Background color for net alert
|
|
||||||
color_disable = "#FF1D1F21" # Foreground for disable elements
|
|
||||||
color_wsp = "#FF8C9440" # Background for selected workspace
|
|
||||||
|
|
||||||
# Lemonbar settings
|
|
||||||
geometry="x24"
|
|
||||||
fonts = ["Hack:pixelsize=12" #":style=Bold"
|
|
||||||
,"Font Awesome 5 Free Solid:pixelsize=16"
|
|
||||||
,"Font Awesome 5 Brands:pixelsize=16"]
|
|
||||||
|
|
||||||
lemonbar_args = ['lemonbar', '-p', '-g', geometry, '-B', color_back
|
|
||||||
, '-F', color_fore, '-a' '20']
|
|
||||||
|
|
||||||
for font in fonts:
|
|
||||||
lemonbar_args.append('-f')
|
|
||||||
lemonbar_args.append(font)
|
|
||||||
|
|
||||||
# Misc. settings
|
|
||||||
cpu_alert = 75
|
|
||||||
net_alert = 5
|
|
||||||
|
|
||||||
#default space between sections
|
|
||||||
#if [ ${res_w} -gt 1024 ]; then
|
|
||||||
# stab=' '
|
|
||||||
#else
|
|
||||||
# stab=' '
|
|
||||||
#fi
|
|
||||||
|
|
||||||
# Icon definitions
|
|
||||||
sep_left = "" # Powerline separator left alt.
|
|
||||||
sep_right = "" # Powerline separator right
|
|
||||||
sep_l_left = "" # Powerline light separator left
|
|
||||||
sep_l_right = "" # Powerline light sepatator right
|
|
||||||
|
|
||||||
# Icon glyphs from Terminusicons2
|
|
||||||
icon_clock = "" # Clock icon
|
|
||||||
icon_cpu = "" # CPU icon
|
|
||||||
icon_mem = "" # MEM icon
|
|
||||||
icon_dl = "" # Download icon
|
|
||||||
icon_ul = "" # Upload icon
|
|
||||||
icon_vol = "" # Volume icon
|
|
||||||
icon_vol_low = "" # Volume icon
|
|
||||||
icon_vol_mute = "" # Volume icon
|
|
||||||
icon_hd = " [/]" # HD / icon
|
|
||||||
icon_home = " [/home]" # HD /home icon
|
|
||||||
icon_mail = "" # Mail icon
|
|
||||||
icon_chat = "Ò" # IRC/Chat icon
|
|
||||||
icon_music = "Î" # Music icon
|
|
||||||
icon_prog = "" # Window icon alt.
|
|
||||||
icon_contact = "Á" # Contact icon
|
|
||||||
icon_wsp = "" # Workspace icon
|
|
||||||
icon_wlan = ""
|
|
||||||
icon_eth = ""
|
|
||||||
icon_lang = ""
|
|
||||||
icon_keyset = ""
|
|
||||||
icon_bright = ""
|
|
||||||
icon_brightness = '☼'
|
|
||||||
icon_charged = ""
|
|
||||||
icon_charging = ""
|
|
||||||
icon_batt_0 = ""
|
|
||||||
icon_batt_1 = ""
|
|
||||||
icon_batt_2 = ""
|
|
||||||
icon_batt_3 = ""
|
|
||||||
icon_batt_4 = ""
|
|
||||||
icon_bluetooth = ""
|
|
||||||
@@ -1,269 +0,0 @@
|
|||||||
import fcntl, sys, os, time, logging
|
|
||||||
import queue
|
|
||||||
import signal, atexit
|
|
||||||
import subprocess
|
|
||||||
import contextlib
|
|
||||||
from threading import Thread
|
|
||||||
import argparse
|
|
||||||
|
|
||||||
import i3_lemonbar_config as config
|
|
||||||
import i3_lemonbar_common as common
|
|
||||||
import i3_lemonbar_modules as modules
|
|
||||||
import i3_lemonbar_parser as lemonparser
|
|
||||||
|
|
||||||
p_conky_slow = None
|
|
||||||
p_lemonbar = None
|
|
||||||
|
|
||||||
def assert_only_instance():
|
|
||||||
"""
|
|
||||||
If PID file exists:
|
|
||||||
Look for process with given PID
|
|
||||||
If found:
|
|
||||||
Exit program
|
|
||||||
If not found:
|
|
||||||
Delete PID file and continue
|
|
||||||
|
|
||||||
Look for fifo file
|
|
||||||
If exists:
|
|
||||||
Delete it
|
|
||||||
"""
|
|
||||||
|
|
||||||
try:
|
|
||||||
pid = None
|
|
||||||
with open(config.pid_file, 'r') as fp:
|
|
||||||
pid = int(fp.read())
|
|
||||||
except IOError:
|
|
||||||
common.logger.debug('Could not open PID file. Assuming non existent')
|
|
||||||
except ValueError:
|
|
||||||
common.logger.debug('''PID file contents broken''')
|
|
||||||
try:
|
|
||||||
os.remove(config.pid_file)
|
|
||||||
common.logger.debug('''Deleted old PID file, continuing as usual''')
|
|
||||||
except OSError:
|
|
||||||
common.logger.debug('''Failed deleting old PID file.''')
|
|
||||||
os._exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
if pid is not None:
|
|
||||||
try:
|
|
||||||
common.logger.debug('''Found old PID file. Looking for owner''')
|
|
||||||
os.kill(pid, 0)
|
|
||||||
common.logger.debug('''Owner exists''')
|
|
||||||
common.logger.debug('''Failed, another instance of the launcher is running
|
|
||||||
(PID {})'''.format(pid))
|
|
||||||
os._exit(1)
|
|
||||||
except ProcessLookupError:
|
|
||||||
common.logger.debug('''Owner does not exist''')
|
|
||||||
try:
|
|
||||||
os.remove(config.pid_file)
|
|
||||||
common.logger.debug('''Deleted old PID file, continuing as usual''')
|
|
||||||
except OSError:
|
|
||||||
common.logger.debug('''Failed deleting old PID file.''')
|
|
||||||
os._exit(1)
|
|
||||||
|
|
||||||
with open(config.pid_file, 'w+') as fp:
|
|
||||||
fp.write('{:d}'.format(os.getpid()))
|
|
||||||
common.logger.debug('''Created and wrote to PID file''')
|
|
||||||
|
|
||||||
common.create_new_fifo(config.fifo_file_status)
|
|
||||||
|
|
||||||
def handle_exit(signum, frame):
|
|
||||||
common.logger.info('Signal handler called with signal {}'.format(signum))
|
|
||||||
common.logger.info('Calling os._exit(0)')
|
|
||||||
os._exit(0)
|
|
||||||
|
|
||||||
# Terminates process p nicely
|
|
||||||
def nice_term(p):
|
|
||||||
if p is not None:
|
|
||||||
p.terminate()
|
|
||||||
|
|
||||||
def nice_delete(f):
|
|
||||||
with contextlib.suppress(FileNotFoundError):
|
|
||||||
os.remove(f)
|
|
||||||
|
|
||||||
def clean_up():
|
|
||||||
common.logger.debug('Cleaning up')
|
|
||||||
common.screen.destroy()
|
|
||||||
nice_delete(config.pid_file)
|
|
||||||
nice_delete(config.fifo_file_status)
|
|
||||||
nice_term(p_conky_slow)
|
|
||||||
modules.stop_all()
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
def queue_parse_job(job):
|
|
||||||
common.parsing_queue.put(job)
|
|
||||||
|
|
||||||
def keep_fifo_open():
|
|
||||||
with open(config.fifo_file_status, 'w', buffering=1) as fifo_write:
|
|
||||||
while True:
|
|
||||||
fifo_write.write('HEARTBEAT\n')
|
|
||||||
time.sleep(30)
|
|
||||||
def put_fifo_in_queue():
|
|
||||||
with open(config.fifo_file_status, 'r', buffering=1) as fifo_read:
|
|
||||||
# Let parser read from fifo
|
|
||||||
common.logger.debug("FIFO {} opened for reading".format(config.fifo_file_status))
|
|
||||||
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
data = fifo_read.readline() # Blocking read
|
|
||||||
if len(data) == 0:
|
|
||||||
common.logger.debug("Writer closed")
|
|
||||||
break
|
|
||||||
queue_parse_job(data)
|
|
||||||
except BrokenPipeError:
|
|
||||||
common.logger.debug('Broken pipe in parse status thread, exiting')
|
|
||||||
common.health_logger.info('Broken pipe in parse status thread, exiting')
|
|
||||||
clean_up()
|
|
||||||
except:
|
|
||||||
common.logger.debug('Unknown exception in parse status thread, exiting')
|
|
||||||
common.health_logger.info('Unknown exception in parse status thread, exiting')
|
|
||||||
clean_up()
|
|
||||||
|
|
||||||
def parse_status():
|
|
||||||
global p_lemonbar
|
|
||||||
p_lemonbar = subprocess.Popen(config.lemonbar_args, stdin=subprocess.PIPE
|
|
||||||
, stdout=subprocess.PIPE, text=True)
|
|
||||||
|
|
||||||
lemonparser.parse_line('WSPINA1___main INA2___web FOC5___terms INA6___stats ') # TODO modular
|
|
||||||
while True:
|
|
||||||
data = common.parsing_queue.get() # Blocking read
|
|
||||||
if data is None:
|
|
||||||
common.logger.debug('Queue closed')
|
|
||||||
common.health_logger.info('Queue closed')
|
|
||||||
break
|
|
||||||
|
|
||||||
# Ugly temporary solution
|
|
||||||
if (isinstance(data, list)):
|
|
||||||
psd = data[0]
|
|
||||||
else:
|
|
||||||
psd = lemonparser.parse_line(data)
|
|
||||||
p_lemonbar.stdin.write(psd + '\n')
|
|
||||||
p_lemonbar.stdin.flush()
|
|
||||||
#common.logger.debug('Read: "{0}"'.format(data))
|
|
||||||
#common.logger.debug('Parsed "{0}"'.format(psd))
|
|
||||||
|
|
||||||
def exec_commands():
|
|
||||||
global p_lemonbar
|
|
||||||
|
|
||||||
# Wait until up TODO better solution
|
|
||||||
while True:
|
|
||||||
if p_lemonbar is not None:
|
|
||||||
break
|
|
||||||
while True:
|
|
||||||
data = p_lemonbar.stdout.readline()
|
|
||||||
if not data:
|
|
||||||
common.logger.debug('Lemonbar closed, exiting')
|
|
||||||
common.health_logger.info('Lemonbar closed, exiting')
|
|
||||||
clean_up()
|
|
||||||
break
|
|
||||||
|
|
||||||
common.logger.debug('Trying reading: "{0}"'.format(data.strip('\n')))
|
|
||||||
try:
|
|
||||||
for key,func in common.commands_dict.items():
|
|
||||||
l = len(key)
|
|
||||||
if data[:l] == key:
|
|
||||||
func(data)
|
|
||||||
break
|
|
||||||
|
|
||||||
except:
|
|
||||||
common.logger.debug('Exception occured executing command\n Line in: {}\n Data: {}'.format(line_in, line_in[l:].split()))
|
|
||||||
if len(data) == 0:
|
|
||||||
common.logger.debug("Lemonbar output closed")
|
|
||||||
break
|
|
||||||
common.logger.debug('Read: "{0}"'.format(data.strip('\n')))
|
|
||||||
|
|
||||||
|
|
||||||
def user_screen():
|
|
||||||
# Create screen session, in UTF-8 mode, logging to fifo
|
|
||||||
common.screen = common.LemonbarScreen()
|
|
||||||
with open(config.fifo_screen_log, 'r', buffering=1) as screen_read:
|
|
||||||
empty_count = 0
|
|
||||||
while empty_count < 3:
|
|
||||||
try:
|
|
||||||
line = screen_read.readline().strip('\n')
|
|
||||||
line = common.strip_ansi_unicode(line)
|
|
||||||
common.logger.debug('Screen read line {}'.format(line))
|
|
||||||
if (not line.startswith('[CHG]')
|
|
||||||
and not line.isspace()):
|
|
||||||
#common.logger.debug('put in queue {}'.format(line))
|
|
||||||
queue_parse_job('RESP {}\n'.format(line))
|
|
||||||
|
|
||||||
if not line:
|
|
||||||
# End loop if many empty lines in a row
|
|
||||||
empty_count = empty_count + 1
|
|
||||||
else:
|
|
||||||
empty_count = 0
|
|
||||||
except:
|
|
||||||
raise
|
|
||||||
|
|
||||||
common.screen.destroy()
|
|
||||||
nice_delete(config.fifo_screen_log)
|
|
||||||
|
|
||||||
class i3_thread:
|
|
||||||
""" Helper class to start and stop threads"""
|
|
||||||
all_threads = [] # Static, contains all started threads
|
|
||||||
|
|
||||||
def __init__(self, target, desc):
|
|
||||||
self.thread = Thread(target = self.__class__.run, args=(target,desc))
|
|
||||||
self.desc = desc
|
|
||||||
|
|
||||||
self.all_threads.append(self)
|
|
||||||
common.health_logger.info('"%s" starting', desc)
|
|
||||||
self.thread.start()
|
|
||||||
|
|
||||||
# Wrapper around the target
|
|
||||||
def run(target, desc):
|
|
||||||
target()
|
|
||||||
common.health_logger.info('"%s" reached end', desc)
|
|
||||||
|
|
||||||
def join_threads():
|
|
||||||
for i3_th in i3_thread.all_threads:
|
|
||||||
i3_th.thread.join()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
parser = argparse.ArgumentParser(description='Blah blah blah.')
|
|
||||||
parser.add_argument('--debug', action='store_true')
|
|
||||||
args = parser.parse_args()
|
|
||||||
if(args.debug):
|
|
||||||
debuglvl = logging.DEBUG
|
|
||||||
else:
|
|
||||||
debuglvl = logging.INFO
|
|
||||||
|
|
||||||
# Setup logger to stdout
|
|
||||||
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
|
|
||||||
handler = logging.StreamHandler(sys.stdout)
|
|
||||||
handler.setFormatter(formatter)
|
|
||||||
|
|
||||||
common.logger = logging.getLogger('Normal logger')
|
|
||||||
common.logger.setLevel(debuglvl)
|
|
||||||
common.logger.addHandler(handler)
|
|
||||||
|
|
||||||
# Setup health logger to file in tmp
|
|
||||||
formatter = logging.Formatter('%(asctime)s %(message)s')
|
|
||||||
handler = logging.FileHandler(config.health_file)
|
|
||||||
handler.setFormatter(formatter)
|
|
||||||
|
|
||||||
common.health_logger = logging.getLogger('Health logger')
|
|
||||||
common.health_logger.addHandler(handler)
|
|
||||||
|
|
||||||
# common.logger.basicConfig(stream=sys.stdout, level=debuglvl)
|
|
||||||
assert_only_instance() # Creates pid file and fifo file
|
|
||||||
atexit.register(clean_up)
|
|
||||||
signal.signal(signal.SIGTERM, handle_exit)
|
|
||||||
signal.signal(signal.SIGINT, handle_exit)
|
|
||||||
|
|
||||||
common.parsing_queue = queue.Queue()
|
|
||||||
|
|
||||||
# Start writing and reading threads
|
|
||||||
# Create readers before writers
|
|
||||||
i3_thread(target = exec_commands, desc='Exec commands thread')
|
|
||||||
i3_thread(target = parse_status, desc='Parse status thread')
|
|
||||||
i3_thread(target = keep_fifo_open, desc='')
|
|
||||||
i3_thread(target = put_fifo_in_queue, desc='')
|
|
||||||
i3_thread(target = user_screen, desc='Screen thread for user commands')
|
|
||||||
modules.start_all()
|
|
||||||
|
|
||||||
common.logger.debug('Threads started')
|
|
||||||
i3_thread.join_threads()
|
|
||||||
|
|
||||||
common.logger.debug('Reached end')
|
|
||||||
@@ -1,443 +0,0 @@
|
|||||||
import threading
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
import i3_lemonbar_config as config
|
|
||||||
import i3_lemonbar_common as common
|
|
||||||
import i3_lemonbar_parser as parser
|
|
||||||
import i3_workspaces as wspaces
|
|
||||||
|
|
||||||
class LemonModule(threading.Thread):
|
|
||||||
# Module generates some status message, parses it, and handles on click actions
|
|
||||||
# Every module runs in its own thread
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__()
|
|
||||||
self._start_module()
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
if self.status_handle is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
common.logger.info('Started module {}'.format(self.__class__.__name__))
|
|
||||||
common.health_logger.info('Module {} up'.format(self.__class__.__name__))
|
|
||||||
while True:
|
|
||||||
line = self.status_handle.readline()
|
|
||||||
if not line:
|
|
||||||
common.logger.info('Reached end of module {}'.format(self.__class__.__name__))
|
|
||||||
common.health_logger.info('Module {} down'.format(self.__class__.__name__))
|
|
||||||
break
|
|
||||||
|
|
||||||
parsed = self.parse(line)
|
|
||||||
common.parsing_queue.put([parsed]) # TODO Wrapped in list, temporary solution
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
self._stop_module()
|
|
||||||
|
|
||||||
def parse(self, line):
|
|
||||||
# TODO get rid of prefix
|
|
||||||
data = line[len(self.prefix):].split()
|
|
||||||
self._parse_data(data) # Update correct field
|
|
||||||
|
|
||||||
formatted_line = parser.format_line() # Construct entire line
|
|
||||||
return formatted_line
|
|
||||||
|
|
||||||
def format_load(data, module, alert):
|
|
||||||
# Helper function to format network modules
|
|
||||||
# Changes colors scheme to inactive when interfaces are down, or to alert when
|
|
||||||
# alert level is reached
|
|
||||||
# Returns tuple (down, up)
|
|
||||||
if data[0] == 'down': # wlan
|
|
||||||
module.alt_scheme = parser.COLOR_SCHEME.INA
|
|
||||||
return ('x', 'x')
|
|
||||||
else:
|
|
||||||
(d_v, u_v) = (data[0],data[1])
|
|
||||||
if max(float(d_v), float(u_v)) > float(alert):
|
|
||||||
module.alt_scheme = parser.COLOR_SCHEME.NET_ALERT
|
|
||||||
else:
|
|
||||||
# Reset to default
|
|
||||||
module.alt_scheme = None
|
|
||||||
return (d_v, u_v)
|
|
||||||
|
|
||||||
class ConkyFastModule(LemonModule):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.prefix = 'CNK_FAST'
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
def _start_module(self):
|
|
||||||
self.p_handle = subprocess.Popen(['conky', '-c', config.path+'conky_fast'],
|
|
||||||
stdout=subprocess.PIPE, text=True)
|
|
||||||
self.status_handle = self.p_handle.stdout
|
|
||||||
|
|
||||||
self.wlan_load = parser.IconTextUnit('wlan_load', action='wlan', order=13)
|
|
||||||
self.eth_load = parser.IconTextUnit('eth_load', action='eth', order=14)
|
|
||||||
self.volume = parser.IconTextUnit('volume', action='pavu', order=20)
|
|
||||||
self.date = parser.IconTextUnit('date', action='date', order=40)
|
|
||||||
self.time = parser.IconTextUnit('time', action='toggle_secs', order=41
|
|
||||||
, alt_scheme=parser.COLOR_SCHEME.SPECIAL)
|
|
||||||
self.time.modes = [mode for mode in common.bar_mode]
|
|
||||||
|
|
||||||
parser.g_parser.register_unit(self.wlan_load)
|
|
||||||
parser.g_parser.register_unit(self.eth_load)
|
|
||||||
parser.g_parser.register_unit(self.volume)
|
|
||||||
parser.g_parser.register_unit(self.date)
|
|
||||||
parser.g_parser.register_unit(self.time)
|
|
||||||
|
|
||||||
def _stop_module(self):
|
|
||||||
if self.p_handle is not None:
|
|
||||||
self.p_handle.terminate()
|
|
||||||
|
|
||||||
parser.g_parser.remove_unit(self.wlan_load)
|
|
||||||
parser.g_parser.remove_unit(self.eth_load)
|
|
||||||
parser.g_parser.remove_unit(self.volume)
|
|
||||||
parser.g_parser.remove_unit(self.date)
|
|
||||||
parser.g_parser.remove_unit(self.time)
|
|
||||||
|
|
||||||
def _parse_data(self, data):
|
|
||||||
# wlan and eth
|
|
||||||
(wland_v, wlanu_v) = format_load(data[5:7], self.wlan_load, config.net_alert)
|
|
||||||
self.wlan_load.items = [(config.icon_wlan + config.icon_dl, wland_v)
|
|
||||||
,(config.icon_ul, wlanu_v)]
|
|
||||||
|
|
||||||
(ethd_v, ethu_v) = format_load(data[7:9], self.eth_load, config.net_alert)
|
|
||||||
self.eth_load.items = [(config.icon_eth + config.icon_dl, ethd_v)
|
|
||||||
,(config.icon_ul, ethu_v)]
|
|
||||||
|
|
||||||
# Volume
|
|
||||||
mute = data[4] == 'MUTE' or data[4] == 'NONE'
|
|
||||||
(vol,vols) = (-1,'×') if mute else (int(data[4]), data[4]+'%')
|
|
||||||
icon_v = config.icon_vol_mute if vol == 0 else \
|
|
||||||
config.icon_vol_low if vol < 50 else config.icon_vol
|
|
||||||
self.volume.items = [(icon_v, vols)]
|
|
||||||
|
|
||||||
# Date and time
|
|
||||||
self.date.items = [(config.icon_clock, ' '.join(data[0:3]))]
|
|
||||||
self.time.items = [('', data[3] if common.show_secs else data[3][:-3])]
|
|
||||||
|
|
||||||
class ConkySlowModule(LemonModule):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.prefix = 'CNK_SLOW'
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
def _start_module(self):
|
|
||||||
self.p_handle = subprocess.Popen(['conky', '-c', config.path+'conky_slow'],
|
|
||||||
stdout=subprocess.PIPE, text=True)
|
|
||||||
self.status_handle = self.p_handle.stdout
|
|
||||||
|
|
||||||
self.sys_load = parser.IconTextUnit('sys_load', action='load', order=10)
|
|
||||||
self.disk = parser.IconTextUnit('disk', order=11)
|
|
||||||
self.brightness = parser.IconTextUnit('brightness', action='adj_br', order=21
|
|
||||||
, external={'BRIGHT': self.parse_brightness})
|
|
||||||
self.battery = parser.IconTextUnit('battery', action='dpms', order=22)
|
|
||||||
self.language = parser.IconTextUnit('language', action='lang', order=32
|
|
||||||
, external={'LANG': self.parse_language})
|
|
||||||
|
|
||||||
parser.g_parser.register_unit(self.sys_load)
|
|
||||||
parser.g_parser.register_unit(self.disk)
|
|
||||||
parser.g_parser.register_unit(self.brightness)
|
|
||||||
parser.g_parser.register_unit(self.battery)
|
|
||||||
parser.g_parser.register_unit(self.language)
|
|
||||||
|
|
||||||
def _stop_module(self):
|
|
||||||
parser.g_parser.remove_unit(self.sys_load)
|
|
||||||
parser.g_parser.remove_unit(self.disk)
|
|
||||||
parser.g_parser.remove_unit(self.brightness)
|
|
||||||
parser.g_parser.remove_unit(self.battery)
|
|
||||||
parser.g_parser.remove_unit(self.language)
|
|
||||||
|
|
||||||
if self.p_handle is not None:
|
|
||||||
self.p_handle.terminate()
|
|
||||||
|
|
||||||
def _parse_data(self, data):
|
|
||||||
self.parse_sys_load (data[0:2]) # System load
|
|
||||||
self.parse_disk (data[2:4]) # Disk usage
|
|
||||||
self.parse_battery (data[4:5]) # Battery
|
|
||||||
self.parse_brightness (data[5:6]) # Screen brightness
|
|
||||||
self.parse_language (data[6:7]) # Language
|
|
||||||
|
|
||||||
def parse_sys_load(self, data):
|
|
||||||
if int(data[0]) > int(config.cpu_alert):
|
|
||||||
self.sys_load.alt_scheme = parser.COLOR_SCHEME.CPU_ALERT
|
|
||||||
else:
|
|
||||||
self.sys_load.alt_scheme = None
|
|
||||||
|
|
||||||
self.sys_load.items = [(config.icon_cpu, data[0] + '%')
|
|
||||||
,(config.icon_ul, data[1])]
|
|
||||||
|
|
||||||
def parse_disk(self, data):
|
|
||||||
self.disk.items = [(config.icon_hd , data[0] + '%')
|
|
||||||
,(config.icon_home, data[1] + '%')]
|
|
||||||
def parse_battery(self, data):
|
|
||||||
(batt_stat, batt) = (data[0][0], data[0][1:])
|
|
||||||
batt_i = int(batt)
|
|
||||||
icon_batt = config.icon_charging if batt_stat == 'C' else \
|
|
||||||
config.icon_charged if batt_stat == 'F' else \
|
|
||||||
config.icon_batt_0 if batt_i < 20 else \
|
|
||||||
config.icon_batt_1 if batt_i < 40 else \
|
|
||||||
config.icon_batt_2 if batt_i < 60 else \
|
|
||||||
config.icon_batt_3 if batt_i < 80 else \
|
|
||||||
config.icon_batt_4
|
|
||||||
self.battery.items = [(icon_batt, batt+'%')]
|
|
||||||
|
|
||||||
def parse_brightness(self, data):
|
|
||||||
brtxt = str(int(float(data[0])))
|
|
||||||
self.brightness.items = [(config.icon_bright, brtxt+'%')]
|
|
||||||
|
|
||||||
def parse_language(self, data):
|
|
||||||
self.language.items = [(config.icon_lang, data[0])]
|
|
||||||
|
|
||||||
class i3Module(LemonModule):
|
|
||||||
# Handles outputs (displays), workspaces and active window
|
|
||||||
# TODO trigger formatting
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__()
|
|
||||||
self.displays = ''
|
|
||||||
self.win_title = ''
|
|
||||||
self.workspaces = ''
|
|
||||||
|
|
||||||
def _start_module(self):
|
|
||||||
self.i3_ws_obj = wspaces.i3ws(logger=common.logger)
|
|
||||||
|
|
||||||
self.displays = parser.CustomUnit('displays', format_function = self.format_displays, order=-30)
|
|
||||||
self.workspaces = parser.CustomUnit('workspaces', format_function = self.format_workspaces, order=-20)
|
|
||||||
self.title = parser.CustomUnit('title', format_function = self.format_title, order=-10)
|
|
||||||
self.displays.modes.append(common.bar_mode.control)
|
|
||||||
self.workspaces.modes.append(common.bar_mode.control)
|
|
||||||
|
|
||||||
parser.g_parser.register_unit(self.displays)
|
|
||||||
parser.g_parser.register_unit(self.workspaces)
|
|
||||||
parser.g_parser.register_unit(self.title)
|
|
||||||
|
|
||||||
# Add callbacks for parsing
|
|
||||||
self.i3_ws_obj.change_callbacks.append(self.parse_displays)
|
|
||||||
self.i3_ws_obj.change_callbacks.append(self.parse_workspaces)
|
|
||||||
self.i3_ws_obj.focus_callbacks.append(self.parse_title)
|
|
||||||
|
|
||||||
# Add callbacks for special actions
|
|
||||||
self.i3_ws_obj.change_callbacks.append(i3Module.set_bg)
|
|
||||||
self.i3_ws_obj.focus_callbacks.append(i3Module.set_keymap)
|
|
||||||
self.i3_ws_obj.focus_callbacks.append(i3Module.kill_floating_windows)
|
|
||||||
|
|
||||||
def _stop_module(self):
|
|
||||||
parser.g_parser.remove_unit(self.displays)
|
|
||||||
parser.g_parser.remove_unit(self.workspaces)
|
|
||||||
parser.g_parser.remove_unit(self.title)
|
|
||||||
|
|
||||||
if self.i3_ws_obj is not None:
|
|
||||||
self.i3_ws_obj.quit()
|
|
||||||
|
|
||||||
# Overload run as i3_ws_obj.work() is a blocking command
|
|
||||||
# Parsing is instead done through callbacks
|
|
||||||
def run(self):
|
|
||||||
common.logger.info('Started module {}'.format(self.__class__.__name__))
|
|
||||||
common.health_logger.info('Module {} up'.format(self.__class__.__name__))
|
|
||||||
|
|
||||||
self.i3_ws_obj.work() # This is a blocking command
|
|
||||||
|
|
||||||
common.logger.info('Reached end of module {}'.format(self.__class__.__name__))
|
|
||||||
common.health_logger.info('Module {} down'.format(self.__class__.__name__))
|
|
||||||
|
|
||||||
def parse_displays(self, i3ws):
|
|
||||||
parsed_list = [parser.block(click='displays', font='2')]
|
|
||||||
for output in i3ws.outputs:
|
|
||||||
output_name = output.name
|
|
||||||
if output.active:
|
|
||||||
if output_name == 'eDP1':
|
|
||||||
col_head = config.color_head
|
|
||||||
elif output_name == 'DP1':
|
|
||||||
col_head = config.color_vga
|
|
||||||
elif output_name == 'HDMI2':
|
|
||||||
col_head = config.color_hdmi
|
|
||||||
else:
|
|
||||||
col_head = '#00000000' # Undefined
|
|
||||||
parsed_list.append(parser.block(fg=config.color_back, bg=col_head))
|
|
||||||
parsed_list.append(config.icon_wsp)
|
|
||||||
parsed_list.append(parser.block(click=''))
|
|
||||||
|
|
||||||
self.displays = ' '.join(parsed_list)
|
|
||||||
|
|
||||||
def parse_workspaces(self, i3ws):
|
|
||||||
prefix = parser.block(font='1', fg=config.color_back, bg=config.color_head)
|
|
||||||
prefix_foc = ''.join([parser.block(fg = config.color_head, bg=config.color_wsp)
|
|
||||||
, ' ', config.sep_right, ' '
|
|
||||||
, parser.block(fg=config.color_back, bg=config.color_wsp, font='1')])
|
|
||||||
prefix_ina = parser.block(fg=config.color_back, bg=config.color_head, font='1', append=' ')
|
|
||||||
wspces = []
|
|
||||||
|
|
||||||
for workspace in i3ws.workspaces:
|
|
||||||
# Find out which output the workspace is on
|
|
||||||
output = None # TODO actually use this information
|
|
||||||
for output_ in i3ws.outputs:
|
|
||||||
if output_['name'] == workspace['output']:
|
|
||||||
output = output_
|
|
||||||
break
|
|
||||||
if not output:
|
|
||||||
continue
|
|
||||||
status = i3ws.state.get_state(workspace, output) # FOC or INA
|
|
||||||
name = workspace['name'] # e.g. 5 terms
|
|
||||||
current = ''.join([parser.block(click=('i3-msg workspace' + name))
|
|
||||||
, name, parser.block(click='')])
|
|
||||||
if status == "FOC":
|
|
||||||
wspces.append(''.join([prefix_foc, current]))
|
|
||||||
else:
|
|
||||||
wspces.append(''.join([prefix_ina, current]))
|
|
||||||
|
|
||||||
self.workspaces = ''.join([prefix, ' '.join(wspces)])
|
|
||||||
|
|
||||||
def parse_title(self, i3ws):
|
|
||||||
if i3ws.focused_window is None:
|
|
||||||
return
|
|
||||||
self.win_title = ' '.join([parser.block(fg=config.color_head, bg=config.color_sec_b2)
|
|
||||||
, config.sep_right, parser.block(fg=config.color_head, bg=config.color_sec_b2, click='mode cycle')
|
|
||||||
, config.icon_prog
|
|
||||||
, parser.block(fg=config.color_sec_b2, bg='-')
|
|
||||||
, i3ws.focused_window.name])
|
|
||||||
|
|
||||||
def format_displays(self):
|
|
||||||
return self.displays
|
|
||||||
|
|
||||||
def format_workspaces(self):
|
|
||||||
return self.workspaces
|
|
||||||
|
|
||||||
def format_title(self):
|
|
||||||
return self.win_title
|
|
||||||
|
|
||||||
def img_path(num):
|
|
||||||
dir = '/home/kuba/Obrazy/Wallpapers/'
|
|
||||||
return dir + {
|
|
||||||
1: '1_main',
|
|
||||||
2: '2_web',
|
|
||||||
3: '3_music',
|
|
||||||
4: '4_work',
|
|
||||||
5: '5_terms',
|
|
||||||
6: '6_stats',
|
|
||||||
7: '7',
|
|
||||||
8: '8',
|
|
||||||
9: '9',
|
|
||||||
}.get(int(num), 'default')
|
|
||||||
|
|
||||||
def set_bg(i3ws):
|
|
||||||
cmd_args = ['sh', '/home/kuba/scripts/set_bg.sh']
|
|
||||||
for output in i3ws.outputs:
|
|
||||||
if output.active:
|
|
||||||
bg = i3Module.img_path(output.current_workspace.partition(' ')[0])
|
|
||||||
cmd_args.append(bg)
|
|
||||||
subprocess.call(cmd_args)
|
|
||||||
|
|
||||||
def kill_floating_windows(i3ws):
|
|
||||||
if i3ws.focused_window is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
role = i3ws.focused_window.window_role
|
|
||||||
wclass = i3ws.focused_window.window_class
|
|
||||||
|
|
||||||
if role != 'FLOAT_TERM' and wclass != 'FLOAT_PAVU' and wclass != 'YADWINBR':
|
|
||||||
# Is there a window that the bar has opened?
|
|
||||||
for pid in common.kill_on_unfocus:
|
|
||||||
try:
|
|
||||||
os.kill(pid, signal.SIGTERM)
|
|
||||||
except ProcessLookupError:
|
|
||||||
common.logger.debug('Tried killing process {} but it doesn\'t exist'.format(pid))
|
|
||||||
common.kill_on_unfocus = []
|
|
||||||
|
|
||||||
def set_keymap(i3ws):
|
|
||||||
if i3ws.focused_window is None:
|
|
||||||
return
|
|
||||||
wclass = i3ws.focused_window.window_class
|
|
||||||
common.cur_class = wclass
|
|
||||||
|
|
||||||
if wclass in common.keymaps:
|
|
||||||
new_km = common.keymaps[wclass]
|
|
||||||
common.logger.debug('Setting {} as keymap for {}'.format(new_km, wclass))
|
|
||||||
else:
|
|
||||||
new_km = common.def_keymap
|
|
||||||
common.logger.debug('Setting default keymap {} for {}'.format(new_km, wclass))
|
|
||||||
subprocess.call(['/home/kuba/.i3/scripts/lang.sh', 'qset', new_km])
|
|
||||||
|
|
||||||
class ScreenModule(LemonModule):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.prefix = 'RESP'
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
def _start_module(self):
|
|
||||||
# No external commands needed
|
|
||||||
self.status_handle = None
|
|
||||||
|
|
||||||
self.controls = parser.ButtonsUnit('controls', order=-10)
|
|
||||||
self.response = parser.IconTextUnit('response', order=10)
|
|
||||||
|
|
||||||
self.controls.items = [('', config.icon_prog, 'mode cycle')
|
|
||||||
,('', '', None)
|
|
||||||
,('', 'on', 'bluetooth power on')
|
|
||||||
,('', 'off', 'bluetooth power off')
|
|
||||||
,('PXC 550', '', None)
|
|
||||||
,('', 'conn.', 'bluetooth connect pxc550')
|
|
||||||
,('', 'disc.', 'bluetooth disconnect pxc550')
|
|
||||||
]
|
|
||||||
|
|
||||||
self.response.modes = [common.bar_mode.control]
|
|
||||||
self.controls.modes = [common.bar_mode.control]
|
|
||||||
|
|
||||||
parser.g_parser.register_unit(self.response)
|
|
||||||
parser.g_parser.register_unit(self.controls)
|
|
||||||
|
|
||||||
def _stop_module(self):
|
|
||||||
parser.g_parser.remove_unit(self.response)
|
|
||||||
parser.g_parser.remove_unit(self.controls)
|
|
||||||
|
|
||||||
def _parse_data(self, data):
|
|
||||||
self.response.items = [('', ' '.join(data))]
|
|
||||||
|
|
||||||
class PowerOptionsModule(LemonModule):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.prefix = ''
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
def _start_module(self):
|
|
||||||
# No external commands needed
|
|
||||||
self.status_handle = None
|
|
||||||
|
|
||||||
self.power_opts = parser.CustomUnit('power', format_function=self.format_power_opts, order=-1)
|
|
||||||
|
|
||||||
self.power_opts.modes = [common.bar_mode.power]
|
|
||||||
|
|
||||||
parser.g_parser.register_unit(self.power_opts)
|
|
||||||
|
|
||||||
def _stop_module(self):
|
|
||||||
parser.g_parser.remove_unit(self.power_opts)
|
|
||||||
|
|
||||||
def _parse_data(self, data):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def format_power_opts(self):
|
|
||||||
return ''.join([parser.block(fg=config.color_fore, bg=config.color_poweropts)
|
|
||||||
, ' Abort (Esc) | System (l) lock, (e) logout, (s) suspend, (h) hibernate'
|
|
||||||
, ', (r) reboot, (Shift+s) shutdown'])
|
|
||||||
|
|
||||||
def start_all():
|
|
||||||
global m_conky_fast, m_conky_slow, m_i3ws
|
|
||||||
|
|
||||||
m_i3ws = i3Module()
|
|
||||||
m_conky_slow = ConkySlowModule()
|
|
||||||
m_conky_fast = ConkyFastModule()
|
|
||||||
m_screen = ScreenModule()
|
|
||||||
m_power = PowerOptionsModule()
|
|
||||||
|
|
||||||
m_i3ws.start()
|
|
||||||
m_conky_slow.start()
|
|
||||||
m_conky_fast.start()
|
|
||||||
m_screen.start()
|
|
||||||
m_power.start()
|
|
||||||
|
|
||||||
def stop_all():
|
|
||||||
global m_conky_fast, m_conky_slow, m_i3ws
|
|
||||||
|
|
||||||
m_i3ws.stop()
|
|
||||||
m_conky_slow.stop()
|
|
||||||
m_conky_fast.stop()
|
|
||||||
m_screen.stop()
|
|
||||||
m_power.stop()
|
|
||||||
@@ -1,204 +0,0 @@
|
|||||||
import sys
|
|
||||||
import bisect # Sorting of list
|
|
||||||
from enum import Enum
|
|
||||||
import i3_lemonbar_config as config
|
|
||||||
import i3_lemonbar_common as common
|
|
||||||
|
|
||||||
sr = config.sep_right
|
|
||||||
slr = config.sep_l_right
|
|
||||||
sl = config.sep_left
|
|
||||||
sll = config.sep_l_left
|
|
||||||
|
|
||||||
class IconTextUnit:
|
|
||||||
def __init__(self, name, order, action = None, alt_scheme=None, external=None):
|
|
||||||
self.name = name
|
|
||||||
self.action = action
|
|
||||||
self.order = order
|
|
||||||
self.alt_scheme = alt_scheme # None means default
|
|
||||||
self.external = external
|
|
||||||
self.items = [] # List of tuples (icon, text)
|
|
||||||
self.modes = [common.bar_mode.normal]
|
|
||||||
|
|
||||||
def format(self):
|
|
||||||
close = block(click='') if self.action is not None else ''
|
|
||||||
|
|
||||||
b_color = self.alt_scheme.back_color
|
|
||||||
i_color = self.alt_scheme.icon_color
|
|
||||||
t_color = self.alt_scheme.text_color
|
|
||||||
|
|
||||||
# Start with a major separator. Keep previous background color, set foreground color
|
|
||||||
# of separator to background color of this unit
|
|
||||||
blocks = []
|
|
||||||
blocks.append(block(fg=b_color, append=sl))
|
|
||||||
blocks.append(' ') # TODO perhaps more nice solution than manual spacing
|
|
||||||
if len(self.items) >= 1:
|
|
||||||
(icon, text) = self.items[0]
|
|
||||||
blocks.append(block(click=self.action, fg=i_color, bg=b_color, font='2'
|
|
||||||
, append=' ' + icon))
|
|
||||||
blocks.append(' ')
|
|
||||||
blocks.append(block(fg=t_color, font='1', append=text))
|
|
||||||
if len(self.items) >= 2:
|
|
||||||
for item in self.items[1:]:
|
|
||||||
(icon, text) = item
|
|
||||||
# Append minor separator
|
|
||||||
blocks.append(' ')
|
|
||||||
blocks.append(sll)
|
|
||||||
|
|
||||||
blocks.append(block(fg=i_color, bg=b_color, font='2', append=' ' + icon))
|
|
||||||
blocks.append(' ')
|
|
||||||
blocks.append(block(fg=t_color, font='1', append=text))
|
|
||||||
|
|
||||||
if len(self.items) >= 1:
|
|
||||||
blocks.append(close)
|
|
||||||
return ''.join(blocks)
|
|
||||||
|
|
||||||
def __lt__(self, other):
|
|
||||||
return self.order < other.order
|
|
||||||
|
|
||||||
class ButtonsUnit:
|
|
||||||
def __init__(self, name, order, alt_scheme=None, external=None):
|
|
||||||
self.name = name
|
|
||||||
self.order = order
|
|
||||||
self.alt_scheme = alt_scheme # None means default
|
|
||||||
self.external = external
|
|
||||||
self.items = [] # List of tuples (icon, text, action)
|
|
||||||
self.modes = [common.bar_mode.normal]
|
|
||||||
|
|
||||||
def format(self):
|
|
||||||
b_color = self.alt_scheme.back_color
|
|
||||||
i_color = self.alt_scheme.icon_color
|
|
||||||
t_color = self.alt_scheme.text_color
|
|
||||||
|
|
||||||
# Start with a major separator. Keep previous background color, set foreground color
|
|
||||||
# of separator to background color of this unit
|
|
||||||
blocks = []
|
|
||||||
blocks.append(block(fg=b_color, append=sl))
|
|
||||||
blocks.append(' ')
|
|
||||||
for item in self.items:
|
|
||||||
(icon, text, action) = item
|
|
||||||
close = block(click='') if action is not None else ''
|
|
||||||
|
|
||||||
blocks.append(block(click=action, fg=i_color, bg=b_color, font='2'
|
|
||||||
, append=' ' + icon))
|
|
||||||
blocks.append(' ')
|
|
||||||
blocks.append(block(fg=t_color, font='1', append=text))
|
|
||||||
blocks.append(close)
|
|
||||||
|
|
||||||
return ''.join(blocks)
|
|
||||||
|
|
||||||
def __lt__(self, other):
|
|
||||||
return self.order < other.order
|
|
||||||
|
|
||||||
class CustomUnit:
|
|
||||||
def __init__(self, name, format_function, order, action = None, alt_scheme=None, external=None):
|
|
||||||
self.name = name
|
|
||||||
self.action = action
|
|
||||||
self.order = order
|
|
||||||
self.alt_scheme = alt_scheme # None means default
|
|
||||||
self.external = external
|
|
||||||
self.format = format_function
|
|
||||||
self.items = [] # List of tuples (icon, text)
|
|
||||||
self.modes = [common.bar_mode.normal]
|
|
||||||
|
|
||||||
def __lt__(self, other):
|
|
||||||
return self.order < other.order
|
|
||||||
|
|
||||||
class LemonParser:
|
|
||||||
# Handle parsing of units
|
|
||||||
# Apply alternating colors
|
|
||||||
# Contains list of units
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.units = []
|
|
||||||
|
|
||||||
def register_unit(self, unit):
|
|
||||||
# Keep the list sorted
|
|
||||||
bisect.insort_left(self.units, unit)
|
|
||||||
|
|
||||||
def remove_unit(self, unit):
|
|
||||||
self.units.remove(unit)
|
|
||||||
|
|
||||||
def format(self):
|
|
||||||
formatted = ['%{l}'] # Start left-justified
|
|
||||||
previously_left_justified = True
|
|
||||||
# Iterate over all units. Apply alternating color schemes
|
|
||||||
alt = 1
|
|
||||||
for unit in self.units:
|
|
||||||
# Show only units appropriate for the current mode
|
|
||||||
if common.mode not in unit.modes:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Negative order means left justified, positive means right justified
|
|
||||||
if previously_left_justified and unit.order > 0:
|
|
||||||
# Switch to right justified
|
|
||||||
formatted.append(block(fg='-', bg='-')) # Reset so the color doesn't fill
|
|
||||||
formatted.append('%{r}')
|
|
||||||
previously_left_justified = False
|
|
||||||
|
|
||||||
if unit.alt_scheme is None:
|
|
||||||
# Apply default color scheme, which is alternating
|
|
||||||
unit.alt_scheme = COLOR_SCHEME.A1 if alt == 1 else COLOR_SCHEME.A2
|
|
||||||
else:
|
|
||||||
# Keep alternate color scheme
|
|
||||||
# INA is a special case
|
|
||||||
if unit.alt_scheme == COLOR_SCHEME.INA:
|
|
||||||
unit.alt_scheme = COLOR_SCHEME.A1_INA if alt == 1 else COLOR_SCHEME.A2_INA
|
|
||||||
|
|
||||||
formatted.append(unit.format())
|
|
||||||
alt = alt + 1 if alt + 1 <= 2 else 1
|
|
||||||
|
|
||||||
formatted.append(block(fg='-', bg='-')) # Not sure if needed
|
|
||||||
return ' '.join(formatted)
|
|
||||||
|
|
||||||
g_parser = LemonParser()
|
|
||||||
|
|
||||||
def block(fg = None, bg = None, font = None, click = None, append=''):
|
|
||||||
# Remeber that clickable blocks need to be closed
|
|
||||||
rtn = []
|
|
||||||
if click is not None:
|
|
||||||
if click == '':
|
|
||||||
rtn.append('A')
|
|
||||||
else:
|
|
||||||
rtn.append('A:'+click+':')
|
|
||||||
if fg is not None:
|
|
||||||
rtn.append('F'+fg)
|
|
||||||
if bg is not None:
|
|
||||||
rtn.append('B'+bg)
|
|
||||||
if font is not None:
|
|
||||||
rtn.append('T'+font)
|
|
||||||
return ''.join(['%{', ' '.join(rtn), '}', append])
|
|
||||||
|
|
||||||
class COLOR_SCHEME(Enum):
|
|
||||||
A1 = (config.color_sec_b1, config.color_fore, config.color_icon)
|
|
||||||
A2 = (config.color_sec_b2, config.color_fore, config.color_icon)
|
|
||||||
INA = (None, None, None) # This one is special, dynamically changed to A1_INA or A2_INA
|
|
||||||
A1_INA = (config.color_sec_b1, config.color_disable, config.color_disable)
|
|
||||||
A2_INA = (config.color_sec_b2, config.color_disable, config.color_disable)
|
|
||||||
CPU_ALERT= (config.color_cpu, config.color_back, config.color_back)
|
|
||||||
NET_ALERT= (config.color_net, config.color_back, config.color_back)
|
|
||||||
SPECIAL = (config.color_head, config.color_back, config.color_back)
|
|
||||||
def __init__(self, back_color, text_color, icon_color):
|
|
||||||
self.back_color = back_color
|
|
||||||
self.text_color = text_color
|
|
||||||
self.icon_color = icon_color
|
|
||||||
|
|
||||||
def format_line():
|
|
||||||
return g_parser.format()
|
|
||||||
|
|
||||||
def parse_line(line_in):
|
|
||||||
# Parse lines that external programs have written to fifo
|
|
||||||
|
|
||||||
for unit in g_parser.units:
|
|
||||||
if unit.external is not None:
|
|
||||||
for key,func in unit.external.items():
|
|
||||||
l = len(key)
|
|
||||||
if line_in[:l] == key:
|
|
||||||
func(line_in[l:].split())
|
|
||||||
break
|
|
||||||
|
|
||||||
formatted_line = format_line()
|
|
||||||
return formatted_line
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
for line in sys.stdin:
|
|
||||||
print(parse_line(line))
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# Print i3 workspaces on every change.
|
|
||||||
#
|
|
||||||
# Format:
|
|
||||||
# For every workspace (x = workspace name)
|
|
||||||
# - "FOCx" -> Focused workspace
|
|
||||||
# - "INAx" -> Inactive workspace
|
|
||||||
# - "ACTx" -> Ative workspace
|
|
||||||
# - "URGx" -> Urgent workspace
|
|
||||||
#
|
|
||||||
# Based in wsbar.py en examples dir
|
|
||||||
#
|
|
||||||
# 16 feb 2015 - Electro7
|
|
||||||
|
|
||||||
|
|
||||||
import sys, os, signal
|
|
||||||
import logging
|
|
||||||
import time
|
|
||||||
from subprocess import call
|
|
||||||
import i3ipc
|
|
||||||
|
|
||||||
print_stdout = False
|
|
||||||
|
|
||||||
class State(object):
|
|
||||||
# workspace states
|
|
||||||
focused = 'FOC'
|
|
||||||
active = 'ACT'
|
|
||||||
inactive = 'INA'
|
|
||||||
urgent = 'URG'
|
|
||||||
|
|
||||||
def get_state(self, workspace, output):
|
|
||||||
if workspace['focused']:
|
|
||||||
if output['current_workspace'] == workspace['name']:
|
|
||||||
return self.focused
|
|
||||||
else:
|
|
||||||
return self.active
|
|
||||||
if workspace['urgent']:
|
|
||||||
return self.urgent
|
|
||||||
else:
|
|
||||||
return self.inactive
|
|
||||||
|
|
||||||
|
|
||||||
# Create the i3ws object, then call locking function work()
|
|
||||||
# Another implementation would be to create a thread in __init__
|
|
||||||
# and implement a locking join() function
|
|
||||||
class i3ws(object):
|
|
||||||
ws_format = '%s%s '
|
|
||||||
end_format = 'WSP%s'
|
|
||||||
|
|
||||||
def __init__(self, logger, state=None):
|
|
||||||
self.state = State()
|
|
||||||
self.outputs = []
|
|
||||||
self.workspaces = []
|
|
||||||
self.focused_window = None
|
|
||||||
self.running = True
|
|
||||||
if state:
|
|
||||||
self.state = state
|
|
||||||
self.logger = logger
|
|
||||||
|
|
||||||
# Callback functions have argument i3ws
|
|
||||||
self.change_callbacks = []
|
|
||||||
self.focus_callbacks = []
|
|
||||||
|
|
||||||
def work(self):
|
|
||||||
# While loop to restart connection as long as there is an i3 ipc socket
|
|
||||||
while self.running:
|
|
||||||
self.resetConn()
|
|
||||||
self.logger.debug('Started i3 workspaces manager')
|
|
||||||
self.enterMain()
|
|
||||||
self.logger.debug('Finished i3 workspaces manager')
|
|
||||||
time.sleep(0.5) # TODO max number of attempts + catch exception instead
|
|
||||||
|
|
||||||
def resetConn(self):
|
|
||||||
self.conn = i3ipc.Connection()
|
|
||||||
|
|
||||||
# Run call backs once
|
|
||||||
for cb in self.change_callbacks:
|
|
||||||
cb(self)
|
|
||||||
|
|
||||||
for cb in self.focus_callbacks:
|
|
||||||
cb(self)
|
|
||||||
|
|
||||||
self.conn.on('workspace::focus' , self.change)
|
|
||||||
self.conn.on('workspace::init' , self.change)
|
|
||||||
self.conn.on('workspace::empty' , self.change)
|
|
||||||
self.conn.on('window::focus' , self.win_focused)
|
|
||||||
self.conn.on('shutdown' , self.shutdown)
|
|
||||||
|
|
||||||
def enterMain(self):
|
|
||||||
try:
|
|
||||||
# Locking call
|
|
||||||
self.conn.main()
|
|
||||||
except BrokenPipeError:
|
|
||||||
self.logger.debug('Broken pipe in i3 workspaces thread, exiting')
|
|
||||||
except:
|
|
||||||
self.logger.debug('Unknown exception in i3 workspaces thread, exiting')
|
|
||||||
|
|
||||||
def shutdown(self, i3, e):
|
|
||||||
self.logger.debug('Shut down i3ipc')
|
|
||||||
|
|
||||||
def change(self, i3, e):
|
|
||||||
# Receives event and workspace data
|
|
||||||
self.outputs = i3.get_outputs()
|
|
||||||
fmt_outputs = ['DISP']
|
|
||||||
for output in self.outputs:
|
|
||||||
if output.active:
|
|
||||||
fmt_outputs.append(output.name)
|
|
||||||
self.display(':'.join(fmt_outputs))
|
|
||||||
|
|
||||||
self.workspaces = i3.get_workspaces()
|
|
||||||
text = self.format(self.workspaces, self.outputs)
|
|
||||||
self.display(text)
|
|
||||||
|
|
||||||
# Callbacks
|
|
||||||
for cb in self.change_callbacks:
|
|
||||||
cb(self)
|
|
||||||
|
|
||||||
def win_focused(self, i3, e):
|
|
||||||
self.focused_window = i3.get_tree().find_focused()
|
|
||||||
name = self.focused_window.name
|
|
||||||
text = 'WIN{}'.format(name)
|
|
||||||
self.display(text)
|
|
||||||
|
|
||||||
# Callbacks
|
|
||||||
for cb in self.focus_callbacks:
|
|
||||||
cb(self)
|
|
||||||
|
|
||||||
def format(self, workspaces, outputs):
|
|
||||||
# Formats the text according to the workspace data given.
|
|
||||||
# Only important when running in free standing mode
|
|
||||||
out = ''
|
|
||||||
for workspace in workspaces:
|
|
||||||
output = None
|
|
||||||
for output_ in outputs:
|
|
||||||
if output_['name'] == workspace['output']:
|
|
||||||
output = output_
|
|
||||||
break
|
|
||||||
if not output:
|
|
||||||
continue
|
|
||||||
st = self.state.get_state(workspace, output)
|
|
||||||
name = workspace['name'].replace(" ","___")
|
|
||||||
item= self.ws_format % (st, name)
|
|
||||||
out += item
|
|
||||||
return self.end_format % out
|
|
||||||
|
|
||||||
def display(self, text):
|
|
||||||
global print_stdout
|
|
||||||
if print_stdout:
|
|
||||||
# Displays the text in stout
|
|
||||||
print(text)
|
|
||||||
sys.stdout.flush()
|
|
||||||
|
|
||||||
def quit(self):
|
|
||||||
self.logger.debug('Quitting i3 workspace script')
|
|
||||||
self.running = False
|
|
||||||
self.conn.main_quit()
|
|
||||||
|
|
||||||
def handle_exit(signal, frame):
|
|
||||||
global ws
|
|
||||||
print("Recieved Keyboard Interrupt from user")
|
|
||||||
ws.quit()
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
# Run as stand-alone
|
|
||||||
print_stdout = True
|
|
||||||
|
|
||||||
# Setup logger to stdout with debug log level
|
|
||||||
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
|
|
||||||
handler = logging.StreamHandler(sys.stdout)
|
|
||||||
handler.setFormatter(formatter)
|
|
||||||
|
|
||||||
logger = logging.getLogger('Normal logger')
|
|
||||||
logger.setLevel(logging.DEBUG)
|
|
||||||
logger.addHandler(handler)
|
|
||||||
|
|
||||||
# Capture Keyboard Interrupt (i3ipc captures this internally)
|
|
||||||
signal.signal(signal.SIGINT, handle_exit)
|
|
||||||
|
|
||||||
# Start main
|
|
||||||
ws = i3ws(logger = logger)
|
|
||||||
ws.work()
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
function get_index(){
|
|
||||||
for i in "${!xra_out[@]}"; do
|
|
||||||
if [[ "${xra_out[$i]}" = "$value" ]]; then
|
|
||||||
echo "${i}";
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
xra_out=($(xrandr | grep ' connected' | awk '{print $1}'))
|
|
||||||
in=($@)
|
|
||||||
for i in `seq 0 2 ${#in[@]}`; do
|
|
||||||
value="${in[$i]}"
|
|
||||||
idx=$(get_index)
|
|
||||||
if [ ! -z "$idx" ]; then
|
|
||||||
screen_idx="$idx"
|
|
||||||
#"${xra_out[$idx-1]}"
|
|
||||||
paths[${screen_idx%:}]="--bg-scale ${in[$i+1]}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
#echo "${paths[@]}"
|
|
||||||
str=`printf -v var "%s\n" "${System[@]}"`
|
|
||||||
sh -c "feh ${paths[@]}"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [[ -p /tmp/i3_lemonbar2_$USER ]]; then
|
|
||||||
echo "$@" > /tmp/i3_lemonbar2_$USER
|
|
||||||
fi
|
|
||||||
BIN
.i3/lock.png
|
Before Width: | Height: | Size: 13 KiB |
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Launches a yad window to change the brightness (or volume, not in use)
|
|
||||||
panel_fifo="/tmp/i3_lemonbar1_${USER}"
|
|
||||||
panel_commands="/tmp/i3_lemonbar2_${USER}"
|
|
||||||
|
|
||||||
if [ "$1" == "-b" ]; then
|
|
||||||
CLASS="YADWINBR"
|
|
||||||
ICON='☼'
|
|
||||||
COLOR='yellow'
|
|
||||||
elif [ "$1" == "-v" ]; then
|
|
||||||
CLASS="YADWINV"
|
|
||||||
ICON='🔈'
|
|
||||||
COLOR='white'
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
LEVEL=$(bc <<< "scale=0; $(brillo -G)/1")
|
|
||||||
[[ "$3" == "-t" ]] && TIMER="--timeout=1"
|
|
||||||
|
|
||||||
declare -a YADARGS=("--sticky" "--undecorated" "--on-top" "--class=$CLASS"
|
|
||||||
"--scale" "--text='<span color=\"$COLOR\" font=\"20\">$ICON</span>'"
|
|
||||||
"--value" "$LEVEL" "--no-buttons"
|
|
||||||
"--geometry=15x150" "--vertical" "--text-align" "center" "$TIMER" "--print-partial")
|
|
||||||
YARGS=${YADARGS[@]}
|
|
||||||
|
|
||||||
FIFO="$2"
|
|
||||||
|
|
||||||
(echo "kill_unfocus $BASHPID" > $FIFO; exec sh -c "yad $YARGS") | \
|
|
||||||
while read out; do
|
|
||||||
~/.i3/scripts/level.sh -b set $out
|
|
||||||
done
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
STATUS=`xset q | awk '{for (I=1;I<=NF;I++) if ($I == "DPMS" && $(I+1) == "is") {print $(I+2)};}'`
|
|
||||||
if [ "$STATUS" == "Enabled" ]; then
|
|
||||||
xset -dpms
|
|
||||||
yad --timeout 1 --text "<span font=\"20\">DPMS Disabled</span>" --no-buttons --sticky --on-top
|
|
||||||
else
|
|
||||||
xset dpms
|
|
||||||
yad --timeout 1 --text "<span font=\"20\">DPMS Enabled</span>" --no-buttons --sticky --on-top
|
|
||||||
fi
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
panel_fifo="/tmp/i3_lemonbar1_${USER}"
|
|
||||||
panel_commands="/tmp/i3_lemonbar2_${USER}"
|
|
||||||
|
|
||||||
function show(){
|
|
||||||
setxkbmap -print | grep xkb_symbols | awk '{print $4}' | awk -F"+" '{print $2}'
|
|
||||||
}
|
|
||||||
if [ $# -lt 1 ]; then
|
|
||||||
echo LANG$(show)
|
|
||||||
fi
|
|
||||||
if [ "$1" == "next" ]; then
|
|
||||||
cur=$(show)
|
|
||||||
next='se'
|
|
||||||
if [ "$cur" == "se" ]; then
|
|
||||||
next='pl'
|
|
||||||
fi
|
|
||||||
setxkbmap $next
|
|
||||||
if [ -e $panel_fifo ]; then
|
|
||||||
echo -e "LANG$next\n" > "${panel_fifo}"
|
|
||||||
fi
|
|
||||||
if [ -e $panel_commands ]; then
|
|
||||||
echo -e "setlang $next\n" > "${panel_commands}"
|
|
||||||
fi
|
|
||||||
elif [ "$1" == "qset" ]; then
|
|
||||||
next=$2
|
|
||||||
setxkbmap $next
|
|
||||||
if [ -e $panel_fifo ]; then
|
|
||||||
echo -e "LANG$next\n" > "${panel_fifo}"
|
|
||||||
fi
|
|
||||||
elif [ "$1" == "show" ]; then
|
|
||||||
show
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
panel_fifo="/tmp/i3_lemonbar1_${USER}"
|
|
||||||
panel_commands="/tmp/i3_lemonbar2_${USER}"
|
|
||||||
|
|
||||||
if [[ "$1" == "-b" ]]; then
|
|
||||||
icon="-s /usr/share/pixmaps/volnoti/display-brightness-symbolic.svg"
|
|
||||||
if [[ "$2" == "up" ]]; then
|
|
||||||
level=$(brillo -A 5 -u 100000; brillo)
|
|
||||||
elif [[ "$2" == "down" ]]; then
|
|
||||||
level=$(brillo -U 5 -u 100000; brillo)
|
|
||||||
elif [[ "$2" == "set" ]]; then
|
|
||||||
level=$(brillo -S $3; brillo)
|
|
||||||
fi
|
|
||||||
echo "BRIGHT$level" > $panel_fifo
|
|
||||||
elif [[ "$1" == "-v" ]]; then
|
|
||||||
if [[ "$2" == "up" ]]; then
|
|
||||||
amixer -q set Master 5%+
|
|
||||||
elif [[ "$2" == "down" ]]; then
|
|
||||||
amixer -q set Master 5%-
|
|
||||||
elif [[ "$2" == "toggle" ]]; then
|
|
||||||
amixer -q set Master toggle
|
|
||||||
fi
|
|
||||||
level=$(~/.i3/lemonbar/get_vol.sh)
|
|
||||||
if [[ "$level" == "MUTE" ]]; then
|
|
||||||
level="-m"
|
|
||||||
elif [[ "$level" == "NONE" ]]; then
|
|
||||||
echo "Missing"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$2" != "set" ]]; then
|
|
||||||
volnoti-show $icon $level
|
|
||||||
fi
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
[[ "$1" == "up" ]] && amixer set Master 5%+
|
|
||||||
[[ "$1" == "down" ]] && amixer set Master 5%-
|
|
||||||
[[ "$1" == "mute" ]] && amixer sset Master toggle
|
|
||||||
|
|
||||||
VOL=$(amixer get Master | grep 'Front Left:' | cut -c 31-33)
|
|
||||||
[[ $(amixer get Master | grep "\[off\]") ]] && sudo -u kuba volnoti-show -m $VOL && exit
|
|
||||||
sudo -u kuba volnoti-show $VOL
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
{
|
|
||||||
"layout": "splith",
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"border": "normal",
|
|
||||||
"floating": "auto_off",
|
|
||||||
"layout": "splitv",
|
|
||||||
"percent": 0.65,
|
|
||||||
"type": "con",
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"border": "normal",
|
|
||||||
"floating": "auto_off",
|
|
||||||
"layout": "splith",
|
|
||||||
"percent": 0.5,
|
|
||||||
"type": "con",
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"border": "none",
|
|
||||||
"current_border_width": 2,
|
|
||||||
"floating": "auto_off",
|
|
||||||
"geometry": {
|
|
||||||
"height": 10,
|
|
||||||
"width": 10,
|
|
||||||
"x": 0,
|
|
||||||
"y": 0
|
|
||||||
},
|
|
||||||
"name": "Conky (kuba-Arch)",
|
|
||||||
"percent": 1,
|
|
||||||
"swallows": [
|
|
||||||
{
|
|
||||||
"class": "Conky-arch"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"type": "con"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"border": "none",
|
|
||||||
"current_border_width": 2,
|
|
||||||
"floating": "auto_off",
|
|
||||||
"geometry": {
|
|
||||||
"height": 434,
|
|
||||||
"width": 722,
|
|
||||||
"x": 0,
|
|
||||||
"y": 0
|
|
||||||
},
|
|
||||||
"name": "Conky (kuba-Arch)",
|
|
||||||
"percent": 0.5,
|
|
||||||
"swallows": [
|
|
||||||
{
|
|
||||||
"class": "Conky-gmail"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"type": "con"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"border": "normal",
|
|
||||||
"floating": "auto_off",
|
|
||||||
"layout": "splitv",
|
|
||||||
"percent": 0.35,
|
|
||||||
"type": "con",
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"border": "none",
|
|
||||||
"current_border_width": 2,
|
|
||||||
"floating": "auto_off",
|
|
||||||
"geometry": {
|
|
||||||
"height": 32,
|
|
||||||
"width": 32,
|
|
||||||
"x": 0,
|
|
||||||
"y": 0
|
|
||||||
},
|
|
||||||
"name": "Conky (kuba-Arch)",
|
|
||||||
"percent": 0.20,
|
|
||||||
"swallows": [
|
|
||||||
{
|
|
||||||
"class": "Conky-weather"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"type": "con"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"border": "none",
|
|
||||||
"current_border_width": 2,
|
|
||||||
"floating": "auto_off",
|
|
||||||
"geometry": {
|
|
||||||
"height": 32,
|
|
||||||
"width": 32,
|
|
||||||
"x": 0,
|
|
||||||
"y": 0
|
|
||||||
},
|
|
||||||
"name": "Conky (kuba-Arch)",
|
|
||||||
"percent": 0.20,
|
|
||||||
"swallows": [
|
|
||||||
{
|
|
||||||
"class": "Conky-weather"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"type": "con"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"border": "none",
|
|
||||||
"current_border_width": 2,
|
|
||||||
"floating": "auto_off",
|
|
||||||
"geometry": {
|
|
||||||
"height": 10,
|
|
||||||
"width": 10,
|
|
||||||
"x": 0,
|
|
||||||
"y": 0
|
|
||||||
},
|
|
||||||
"name": "Conky (kuba-Arch)",
|
|
||||||
"percent": 0.60,
|
|
||||||
"swallows": [
|
|
||||||
{
|
|
||||||
"class": "Conky-music"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"type": "con"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
22
.i3initrc
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Generate my i3 config based on hostname
|
||||||
|
# Needs to be sourced by .xprofile (GDM) or .xinitrc (startx)
|
||||||
|
|
||||||
|
# Generate i3 config file
|
||||||
|
i3config="/tmp/i3_${USER}_config"
|
||||||
|
rm -f $i3config
|
||||||
|
|
||||||
|
if [ -f ~/.i3/base.config ]; then
|
||||||
|
cat ~/.i3/base.config >> $i3config
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "`hostname`" = "kubaArch-Laptop" ] && [ -f ~/.i3/home.config ]; then
|
||||||
|
cat ~/.i3/home.config >> $i3config
|
||||||
|
elif [ "`hostname`" = "kubaDesktop" ] && [ -f ~/.i3/home.config ]; then
|
||||||
|
cat ~/.i3/home.config >> $i3config
|
||||||
|
elif [ "`hostname`" = "JakubArch" ] && [ -f ~/.i3/work.config ]; then
|
||||||
|
cat ~/.i3/work.config >> $i3config
|
||||||
|
fi
|
||||||
|
|
||||||
|
#exec i3 -c $i3config -V >> ~/${WM}.log 2>&1
|
||||||
|
sh ~/.i3/scripts/displays.sh auto
|
||||||
|
exec i3 -c $i3config
|
||||||
27
.modules.kuba/ase/Vera/dev.lua
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
whatis("Ase")
|
||||||
|
|
||||||
|
conflict("ASE")
|
||||||
|
|
||||||
|
function ld (m)
|
||||||
|
if not ( isloaded(m) ) then
|
||||||
|
load(m)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ld("iccifort/2019.5.281")
|
||||||
|
ld("impi/2018.5.288")
|
||||||
|
ld("imkl/2019.5.281")
|
||||||
|
ld("Python/3.7.4")
|
||||||
|
ld("Tkinter/3.7.4")
|
||||||
|
ld("matplotlib/3.1.1-Python-3.7.4")
|
||||||
|
|
||||||
|
ld("clusterappl") -- Sets up MYNOBACKUP
|
||||||
|
|
||||||
|
local nobackup = os.getenv("MYNOBACKUP")
|
||||||
|
local root = pathJoin(nobackup, "git/ase/dev")
|
||||||
|
|
||||||
|
prepend_path("PYTHONPATH", root)
|
||||||
|
prepend_path("PATH", pathJoin(root, "tools"))
|
||||||
|
prepend_path("PATH", pathJoin(root, "bin"))
|
||||||
|
|
||||||
|
execute {cmd='complete -o default -C "/usr/bin/python3 ' .. root .. '/ase/cli/complete.py" ase', modeA={"load"}}
|
||||||
25
.modules.kuba/clusterappl.lua
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
whatis([==[
|
||||||
|
Creates $USERAPPL environment variable and adds paths
|
||||||
|
]==])
|
||||||
|
|
||||||
|
local pyver = subprocess([[python --version 2>&1 | sed 's/.*\([23]\.[0-9]\).*/\1/']])
|
||||||
|
if pyver:sub(1, 1) == "2" then
|
||||||
|
LmodError("Must have Python 3 loaded")
|
||||||
|
end
|
||||||
|
|
||||||
|
local home = os.getenv("HOME")
|
||||||
|
local nobackup = pathJoin(home, "nobackup")
|
||||||
|
local userappl = pathJoin(nobackup, "appl")
|
||||||
|
local git = pathJoin(nobackup, "git")
|
||||||
|
local pythonp = pathJoin(userappl, "lib", "python" .. pyver, "site-packages")
|
||||||
|
local binp = pathJoin(userappl, "bin")
|
||||||
|
local libp = pathJoin(userappl, "lib")
|
||||||
|
|
||||||
|
setenv("MYNOBACKUP", nobackup)
|
||||||
|
setenv("USERAPPL", userappl)
|
||||||
|
|
||||||
|
prepend_path("PYTHONPATH", pythonp)
|
||||||
|
prepend_path("PYTHONPATH", ".")
|
||||||
|
prepend_path("PATH", binp)
|
||||||
|
prepend_path("LD_LIBRARY_PATH", libp)
|
||||||
|
execute {cmd='`snakemake --bash-completion`', modeA={"load"}}
|
||||||
7
.modules.kuba/gpaw-setups/0.9.20000.lua
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
local name = myModuleName()
|
||||||
|
local version = myModuleVersion()
|
||||||
|
local home = os.getenv("HOME")
|
||||||
|
local setups_root = pathJoin(home, "gpaw-setups", version)
|
||||||
|
|
||||||
|
prepend_path("GPAW_SETUP_PATH", pathJoin(setups_root, "gpaw-setups-" .. version))
|
||||||
|
prepend_path("GPAW_SETUP_PATH", pathJoin(setups_root, "gpaw-basis-pvalence-" .. version))
|
||||||
0
.modules.kuba/gpaw/.version
Normal file
26
.modules.kuba/gpaw/Tetralith/20.1.0.lua
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
whatis([==[My compiled version of GPAW]==])
|
||||||
|
|
||||||
|
unload("GPAW")
|
||||||
|
|
||||||
|
function ld (m)
|
||||||
|
if not ( isloaded(m) ) then
|
||||||
|
load(m)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ld("clusterappl")
|
||||||
|
|
||||||
|
local nobackup = os.getenv("MYNOBACKUP")
|
||||||
|
local root = pathJoin(nobackup, "git/gpaw/20.1.0")
|
||||||
|
|
||||||
|
ld("Python/3.6.7-env-nsc1-gcc-2018a-eb")
|
||||||
|
-- ld("Python/3.6.3-anaconda-5.0.1-nsc1")
|
||||||
|
ld("ASE/3.18.0-nsc1")
|
||||||
|
|
||||||
|
ld("gpaw-setups/0.9.20000")
|
||||||
|
|
||||||
|
setenv("OMP_NUM_THREADS", 1)
|
||||||
|
prepend_path("PATH", pathJoin(root, "tools"))
|
||||||
|
prepend_path("PYTHONPATH", root)
|
||||||
|
prepend_path("PYTHONPATH", pathJoin(root, "build/lib.linux-x86_64-3.7"))
|
||||||
|
execute {cmd='complete -o default -C "/usr/bin/python3 ' .. root .. '/gpaw/cli/complete.py" gpaw', modeA={"load"}}
|
||||||
1
.modules.kuba/gpaw/Vera/20.1.0.lua
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
dev.lua
|
||||||
23
.modules.kuba/gpaw/Vera/dev.lua
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
whatis([==[My compiled version of GPAW]==])
|
||||||
|
|
||||||
|
unload("GPAW")
|
||||||
|
|
||||||
|
function ld (m)
|
||||||
|
if not ( isloaded(m) ) then
|
||||||
|
load(m)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ld("ase/dev")
|
||||||
|
ld("libxc/4.3.4")
|
||||||
|
ld("gpaw-setups/0.9.20000")
|
||||||
|
|
||||||
|
local _, version = splitFileName(myModuleVersion())
|
||||||
|
local nobackup = os.getenv("MYNOBACKUP")
|
||||||
|
local root = pathJoin(nobackup, "git/gpaw", version)
|
||||||
|
|
||||||
|
setenv("OMP_NUM_THREADS", 1)
|
||||||
|
prepend_path("PATH", pathJoin(root, "tools"))
|
||||||
|
prepend_path("PYTHONPATH", root)
|
||||||
|
prepend_path("PYTHONPATH", pathJoin(root, "build/lib.linux-x86_64-3.7"))
|
||||||
|
execute {cmd='complete -o default -C "/usr/bin/python3 ' .. root .. '/gpaw/cli/complete.py" gpaw', modeA={"load"}}
|
||||||
1
.modules.kuba/gpaw/Vera/jfojt.lua
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
dev.lua
|
||||||
8
.modules.kuba/slurm-aliases.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
whatis([==[
|
||||||
|
Defines useful SLURM aliases
|
||||||
|
]==])
|
||||||
|
|
||||||
|
set_alias("si", 'sinfo -e -o "%9P %4a %8s %.10l %11A %6z %.7m %40N"')
|
||||||
|
set_alias("q", 'squeue -u $USER -o "%7A %56j %2t %16S %.10M %.10L %.2D %4N"')
|
||||||
|
set_alias("ql", 'squeue -u $USER -o "%8A %7K %56j %2t %3r %16S %.10M %.10L %.4D %8N %4f"')
|
||||||
|
set_alias("qa", 'squeue -o "%8A %10u %.6Q %24j %2t %3r %16S %.10M %.10L %.4D %16N" -S t,-p | less')
|
||||||
93
.ssh/config
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
# If ssh does not have gssapi enabled:
|
||||||
|
IgnoreUnknown GSSAPIKeyExchange
|
||||||
|
|
||||||
|
ForwardX11 yes
|
||||||
|
ForwardX11Trusted yes
|
||||||
|
ForwardAgent yes
|
||||||
|
|
||||||
|
Host home
|
||||||
|
HostName isabeljake.duckdns.org
|
||||||
|
User kuba
|
||||||
|
Port 9216
|
||||||
|
|
||||||
|
Host aino
|
||||||
|
HostName aino.fy.chalmers.se
|
||||||
|
User jakub
|
||||||
|
Port 22209
|
||||||
|
|
||||||
|
Host tahoe
|
||||||
|
HostName tahoe.fy.chalmers.se
|
||||||
|
User jakub
|
||||||
|
Port 22209
|
||||||
|
|
||||||
|
Host geym
|
||||||
|
HostName geym.fy.chalmers.se
|
||||||
|
User jakub
|
||||||
|
Port 22209
|
||||||
|
|
||||||
|
Host pi4
|
||||||
|
HostName 192.168.0.200
|
||||||
|
User ubuntu
|
||||||
|
Port 22
|
||||||
|
|
||||||
|
Host pi3
|
||||||
|
HostName 192.168.0.202
|
||||||
|
User ubuntu
|
||||||
|
Port 22
|
||||||
|
|
||||||
|
Host hebbe
|
||||||
|
Hostname hebbe1.c3se.chalmers.se
|
||||||
|
User fojt
|
||||||
|
|
||||||
|
Host vera
|
||||||
|
Hostname vera1.c3se.chalmers.se
|
||||||
|
User fojt
|
||||||
|
|
||||||
|
Host vera2
|
||||||
|
Hostname vera2.c3se.chalmers.se
|
||||||
|
User fojt
|
||||||
|
|
||||||
|
Host tetralith
|
||||||
|
Hostname tetralith1.nsc.liu.se
|
||||||
|
User x_jakfo
|
||||||
|
|
||||||
|
Host tetralith2
|
||||||
|
Hostname tetralith2.nsc.liu.se
|
||||||
|
User x_jakfo
|
||||||
|
|
||||||
|
Host remote11
|
||||||
|
HostName remote11.chalmers.se
|
||||||
|
User fojt
|
||||||
|
Port 22
|
||||||
|
ControlMaster auto
|
||||||
|
ControlPersist yes
|
||||||
|
ControlPath ~/.ssh/socket-%r@%h:%p
|
||||||
|
|
||||||
|
Host beskow
|
||||||
|
Hostname beskow.pdc.kth.se
|
||||||
|
User fojt
|
||||||
|
GSSAPIAuthentication yes
|
||||||
|
GSSAPIKeyExchange yes
|
||||||
|
GSSAPIDelegateCredentials yes
|
||||||
|
PreferredAuthentications gssapi-keyex,gssapi-with-mic
|
||||||
|
|
||||||
|
Host pdctransfer
|
||||||
|
Hostname t04n27.pdc.kth.se
|
||||||
|
User fojt
|
||||||
|
GSSAPIAuthentication yes
|
||||||
|
GSSAPIKeyExchange yes
|
||||||
|
GSSAPIDelegateCredentials yes
|
||||||
|
PreferredAuthentications gssapi-keyex,gssapi-with-mic
|
||||||
|
|
||||||
|
Host tegner
|
||||||
|
Hostname tegner.pdc.kth.se
|
||||||
|
User fojt
|
||||||
|
GSSAPIAuthentication yes
|
||||||
|
GSSAPIKeyExchange yes
|
||||||
|
GSSAPIDelegateCredentials yes
|
||||||
|
PreferredAuthentications gssapi-keyex,gssapi-with-mic
|
||||||
|
|
||||||
|
Host *
|
||||||
|
ForwardAgent no
|
||||||
|
ForwardX11 no
|
||||||
|
ForwardX11Trusted no
|
||||||
5
.ssh/rc
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
# Create symlink to current ssh socket, if a symlink to an active socket
|
||||||
|
# does not exist
|
||||||
|
if [ ! -S ~/.ssh/ssh_auth_sock ] && [ -S "$SSH_AUTH_SOCK" ]; then
|
||||||
|
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
|
||||||
|
fi
|
||||||
12
.tmux.conf
@@ -2,3 +2,15 @@ unbind C-b
|
|||||||
set-option -g prefix C-a
|
set-option -g prefix C-a
|
||||||
bind-key C-a send-prefix
|
bind-key C-a send-prefix
|
||||||
set -g mouse on
|
set -g mouse on
|
||||||
|
|
||||||
|
set -g default-terminal "screen-256color"
|
||||||
|
|
||||||
|
# pane movement
|
||||||
|
bind-key j command-prompt -p "join pane from:" "join-pane -s '%%'"
|
||||||
|
bind-key s command-prompt -p "send pane to:" "join-pane -t '%%'"
|
||||||
|
|
||||||
|
# ssh socket, important to create symlink in ~/.ssh/rc
|
||||||
|
set-environment -g 'SSH_AUTH_SOCK' ~/.ssh/ssh_auth_sock
|
||||||
|
|
||||||
|
# Shorten delay for relaying Esc (to e.g. vim). Too short and PgUp will not work
|
||||||
|
set -sg escape-time 20
|
||||||
|
|||||||
247
.vimrc
@@ -18,30 +18,67 @@ if filereadable(expand(vundle_dir) . "/README.md")
|
|||||||
Plugin 'tpope/vim-surround'
|
Plugin 'tpope/vim-surround'
|
||||||
Plugin 'ctrlpvim/ctrlp.vim'
|
Plugin 'ctrlpvim/ctrlp.vim'
|
||||||
Plugin 'rhysd/vim-clang-format'
|
Plugin 'rhysd/vim-clang-format'
|
||||||
" Plugin 'shougo/neocomplete'
|
|
||||||
Plugin 'godlygeek/tabular'
|
Plugin 'godlygeek/tabular'
|
||||||
Plugin 'airblade/vim-gitgutter'
|
Plugin 'airblade/vim-gitgutter'
|
||||||
Plugin 'jeetsukumaran/vim-pythonsense'
|
Plugin 'jeetsukumaran/vim-pythonsense'
|
||||||
Plugin 'easymotion/vim-easymotion'
|
Plugin 'easymotion/vim-easymotion'
|
||||||
Plugin 'file:///home/kuba/git/vim-indexer'
|
|
||||||
Plugin 'cpiger/NeoDebug'
|
Plugin 'cpiger/NeoDebug'
|
||||||
|
Plugin 'ivan-krukov/vim-snakemake'
|
||||||
|
Plugin 'nvie/vim-flake8'
|
||||||
|
Plugin 'ludovicchabant/vim-gutentags'
|
||||||
|
Plugin 'junegunn/vim-peekaboo'
|
||||||
|
if empty($VIM_DISABLE_YCM)
|
||||||
|
Plugin 'ycm-core/YouCompleteMe'
|
||||||
|
endif
|
||||||
|
Plugin 'dense-analysis/ale'
|
||||||
|
Plugin 'tpope/vim-unimpaired'
|
||||||
|
|
||||||
call vundle#end() " required
|
call vundle#end() " required
|
||||||
else
|
else
|
||||||
let vundle_repo="https://github.com/VundleVim/Vundle.vim.git"
|
let vundle_repo="https://github.com/VundleVim/Vundle.vim.git"
|
||||||
echo "Vundle not installed, type :CloneVundle to clone the vundle repo and install it"
|
echo "Vundle not installed, type :CloneVundle to clone the vundle repo and install it"
|
||||||
command CloneVundle execute "!git clone " . vundle_repo . " " . vundle_dir
|
command! CloneVundle execute "!git clone " . vundle_repo . " " . vundle_dir | source $MYVIMRC | echo "Cloned Vundle. Do :PluginInstall"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !exists("vimrc_autocmds_loaded")
|
||||||
|
let vimrc_autocmds_loaded = 1
|
||||||
|
|
||||||
|
" Set the filetype based on the file's extension, but only if
|
||||||
|
" 'filetype' has not already been set
|
||||||
|
au BufRead,BufNewFile .i3initrc setfiletype sh
|
||||||
|
au BufRead,BufNewFile *.config setfiletype conf
|
||||||
|
au BufRead,BufNewFile [Ss]nakefile.* setfiletype snakemake
|
||||||
|
|
||||||
|
au BufWritePost * if search('\s\+$', 'wn') | call WhitespaceWarn() | endif
|
||||||
|
|
||||||
|
au BufRead,BufNewFile * setlocal textwidth=0 | setlocal colorcolumn=
|
||||||
|
au BufRead,BufNewFile *.md setlocal textwidth=80 | setlocal colorcolumn=80
|
||||||
|
au BufRead,BufNewFile *.py setlocal colorcolumn=100
|
||||||
|
au FileType html setlocal shiftwidth=2 tabstop=2
|
||||||
|
|
||||||
|
if exists(":NERDTree")
|
||||||
|
" Open NERDTree if no file specified
|
||||||
|
au StdinReadPre * let s:std_in=1
|
||||||
|
au VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
au BufEnter,FocusGained,InsertLeave * set rnu
|
||||||
|
au BufLeave,FocusLost,InsertEnter * set nornu
|
||||||
|
endif
|
||||||
set updatetime=1000 " Default is 4s, but reduce it to make things more real time, like git gutter
|
set updatetime=1000 " Default is 4s, but reduce it to make things more real time, like git gutter
|
||||||
highlight Search ctermbg=5
|
|
||||||
|
|
||||||
filetype plugin indent on " required
|
filetype plugin indent on " required
|
||||||
syntax on
|
syntax on
|
||||||
"
|
|
||||||
" Set the filetype based on the file's extension, but only if
|
" These two lines will fully disable any visual or noisy bell
|
||||||
" 'filetype' has not already been set
|
" on both windows and linux. >:)
|
||||||
au BufRead,BufNewFile *.config setfiletype conf
|
set noerrorbells visualbell t_vb=
|
||||||
|
autocmd GUIEnter * set visualbell t_vb=
|
||||||
|
|
||||||
|
" Make indenting and unindenting in visual mode retain the selection so
|
||||||
|
" you don't have to re-select or type gv every time.
|
||||||
|
vnoremap > ><CR>gv
|
||||||
|
vnoremap < <<CR>gv
|
||||||
|
|
||||||
set tabstop=4 " show existing tab with 4 spaces width
|
set tabstop=4 " show existing tab with 4 spaces width
|
||||||
set shiftwidth=4 " when indenting with '>', use 4 spaces width
|
set shiftwidth=4 " when indenting with '>', use 4 spaces width
|
||||||
@@ -53,6 +90,9 @@ set scrolloff=5 " Don't let cursor be within 5 lines from top or bottom
|
|||||||
|
|
||||||
" Warn for trailing whitespace. Search with wrap (w) do not move cursor (n)
|
" Warn for trailing whitespace. Search with wrap (w) do not move cursor (n)
|
||||||
function! WhitespaceWarn()
|
function! WhitespaceWarn()
|
||||||
|
if &ft =~ 'markdown'
|
||||||
|
return
|
||||||
|
endif
|
||||||
echohl WarningMsg
|
echohl WarningMsg
|
||||||
echo 'Found whitespace.'
|
echo 'Found whitespace.'
|
||||||
echohl None
|
echohl None
|
||||||
@@ -67,16 +107,11 @@ function! StripTrailingWhitespace()
|
|||||||
call winrestview(l:save)
|
call winrestview(l:save)
|
||||||
echo "Stripped trailing whitespace"
|
echo "Stripped trailing whitespace"
|
||||||
endfunction
|
endfunction
|
||||||
autocmd BufWritePost * if search('\s\+$', 'wn') | call WhitespaceWarn() | endif
|
|
||||||
command TrailWhitespace call StripTrailingWhitespace()
|
command! TrailWhitespace call StripTrailingWhitespace()
|
||||||
|
|
||||||
" Hybrid line numbers on active buffer
|
" Hybrid line numbers on active buffer
|
||||||
set nu rnu
|
set nu rnu
|
||||||
augroup numbertoggle
|
|
||||||
autocmd!
|
|
||||||
autocmd BufEnter,FocusGained,InsertLeave * set rnu
|
|
||||||
autocmd BufLeave,FocusLost,InsertEnter * set nornu
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
" Do incremental searching when it's possible to timeout.
|
" Do incremental searching when it's possible to timeout.
|
||||||
if has('reltime')
|
if has('reltime')
|
||||||
@@ -90,14 +125,137 @@ noremap Y y$
|
|||||||
command! -bang -range=% -complete=file -nargs=* W <line1>,<line2>write<bang> <args>
|
command! -bang -range=% -complete=file -nargs=* W <line1>,<line2>write<bang> <args>
|
||||||
command! -bang Q quit<bang>
|
command! -bang Q quit<bang>
|
||||||
|
|
||||||
|
" Gutentags configuration
|
||||||
|
if !executable('ctags')
|
||||||
|
let g:gutentags_enabled = 0
|
||||||
|
else
|
||||||
|
let g:gutentags_add_default_project_roots = 0
|
||||||
|
let g:gutentags_project_root = ['.git']
|
||||||
|
|
||||||
|
let g:gutentags_generate_on_new = 1
|
||||||
|
let g:gutentags_generate_on_missing = 1
|
||||||
|
let g:gutentags_generate_on_write = 1
|
||||||
|
let g:gutentags_generate_on_empty_buffer = 0
|
||||||
|
|
||||||
|
" Put all tags in one place
|
||||||
|
let g:gutentags_cache_dir = expand('~/.cache/vim/ctags/')
|
||||||
|
|
||||||
|
" Extra tag information
|
||||||
|
let g:gutentags_ctags_extra_args = [
|
||||||
|
\ '--tag-relative=yes',
|
||||||
|
\ '--fields=+ailmnS',
|
||||||
|
\ ]
|
||||||
|
|
||||||
|
let g:gutentags_ctags_exclude = [
|
||||||
|
\ '*.git', '*.svg', '*.hg',
|
||||||
|
\ '*/tests/*',
|
||||||
|
\ 'build',
|
||||||
|
\ 'dist',
|
||||||
|
\ '*sites/*/files/*',
|
||||||
|
\ 'bin',
|
||||||
|
\ 'node_modules',
|
||||||
|
\ 'bower_components',
|
||||||
|
\ 'cache',
|
||||||
|
\ 'compiled',
|
||||||
|
\ 'docs',
|
||||||
|
\ 'example',
|
||||||
|
\ 'bundle',
|
||||||
|
\ 'vendor',
|
||||||
|
\ '*.md',
|
||||||
|
\ '*-lock.json',
|
||||||
|
\ '*.lock',
|
||||||
|
\ '*bundle*.js',
|
||||||
|
\ '*build*.js',
|
||||||
|
\ '.*rc*',
|
||||||
|
\ '*.json',
|
||||||
|
\ '*.min.*',
|
||||||
|
\ '*.map',
|
||||||
|
\ '*.bak',
|
||||||
|
\ '*.zip',
|
||||||
|
\ '*.pyc',
|
||||||
|
\ '*.class',
|
||||||
|
\ '*.sln',
|
||||||
|
\ '*.Master',
|
||||||
|
\ '*.csproj',
|
||||||
|
\ '*.tmp',
|
||||||
|
\ '*.csproj.user',
|
||||||
|
\ '*.cache',
|
||||||
|
\ '*.pdb',
|
||||||
|
\ 'tags*',
|
||||||
|
\ 'cscope.*',
|
||||||
|
\ '*.css',
|
||||||
|
\ '*.less',
|
||||||
|
\ '*.scss',
|
||||||
|
\ '*.exe', '*.dll',
|
||||||
|
\ '*.mp3', '*.ogg', '*.flac',
|
||||||
|
\ '*.swp', '*.swo',
|
||||||
|
\ '*.bmp', '*.gif', '*.ico', '*.jpg', '*.png',
|
||||||
|
\ '*.rar', '*.zip', '*.tar', '*.tar.gz', '*.tar.xz', '*.tar.bz2',
|
||||||
|
\ '*.pdf', '*.doc', '*.docx', '*.ppt', '*.pptx',
|
||||||
|
\ ]
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
" YouCompleteMe Python interpreter
|
||||||
|
let g:ycm_python_interpreter_path = '~/.python-venv.kuba/bin/python'
|
||||||
|
"let g:ycm_autoclose_preview_window_after_insertion = 1 " Close after leaving insert mode
|
||||||
|
let g:ycm_autoclose_preview_window_after_completion = 1 " Close after accepting completion
|
||||||
|
|
||||||
|
" ALE
|
||||||
|
let g:ale_linters = {
|
||||||
|
\ 'python': ['flake8'],
|
||||||
|
\ 'c': ['gcc']
|
||||||
|
\}
|
||||||
|
let g:ale_set_highlights = 1
|
||||||
|
let g:ale_sign_error = '>>'
|
||||||
|
let g:ale_sign_warning = '--'
|
||||||
|
let g:ale_lint_on_text_changed = 'never'
|
||||||
|
let g:ale_lint_on_enter = 0
|
||||||
|
let g:ale_c_parse_makefile = 1
|
||||||
|
let g:ale_lint_on_insert_leave = 1
|
||||||
|
let g:ale_set_loclist = 1
|
||||||
|
|
||||||
" fugitive.vim looks for tags in .git
|
" fugitive.vim looks for tags in .git
|
||||||
" set tags +=~/tags " Recursively move upwards in tree, searching in subfolders for tags file
|
" set tags +=~/tags " Recursively move upwards in tree, searching in subfolders for tags file
|
||||||
|
|
||||||
if exists(":NERDTree")
|
" Status line
|
||||||
" Open NERDTree if no file specified
|
set laststatus=2
|
||||||
autocmd StdinReadPre * let s:std_in=1
|
set statusline=
|
||||||
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
|
set statusline+=%#StatusLineTerm#
|
||||||
|
if exists('g:loaded_fugitive')
|
||||||
|
set statusline+=%{FugitiveStatusline()}
|
||||||
endif
|
endif
|
||||||
|
set statusline+=%#MoreMsg#
|
||||||
|
set statusline+=\ %f
|
||||||
|
set statusline+=%m\ "
|
||||||
|
set statusline+=%=
|
||||||
|
set statusline+=%#WildMenu#
|
||||||
|
set statusline+=%y
|
||||||
|
set statusline+=\ %p%%
|
||||||
|
set statusline+=\ %l:%c"
|
||||||
|
set statusline+=%#MoreMsg#
|
||||||
|
set statusline+=\ "
|
||||||
|
|
||||||
|
" Colors
|
||||||
|
" Useful for testing:
|
||||||
|
" :runtime syntax/colortest.vim
|
||||||
|
" :runtime syntax/hitest.vim
|
||||||
|
highlight SignColumn ctermbg=NONE
|
||||||
|
highlight GitGutterAdd ctermbg=NONE ctermfg=DarkGreen
|
||||||
|
highlight GitGutterChange ctermbg=NONE ctermfg=Yellow
|
||||||
|
highlight GitGutterDelete ctermbg=NONE ctermfg=DarkRed
|
||||||
|
highlight GitGutterDelete ctermbg=NONE ctermfg=DarkRed
|
||||||
|
highlight Search ctermbg=Brown ctermfg=LightRed
|
||||||
|
highlight ColorColumn ctermbg=DarkBlue
|
||||||
|
highlight Visual ctermbg=LightBlue
|
||||||
|
highlight ALEInfo ctermbg=DarkBlue ctermfg=White
|
||||||
|
highlight ALEWarning ctermbg=DarkBlue ctermfg=Black
|
||||||
|
highlight ALEError ctermbg=DarkRed ctermfg=Black
|
||||||
|
highlight SpellCap ctermbg=DarkBlue ctermfg=Black
|
||||||
|
highlight SpellBad ctermbg=DarkRed ctermfg=Black
|
||||||
|
|
||||||
|
" flake8
|
||||||
|
let g:flake8_show_in_gutter=1
|
||||||
|
|
||||||
" CtrlP
|
" CtrlP
|
||||||
let g:ctrlp_working_path_mode = 'ra'
|
let g:ctrlp_working_path_mode = 'ra'
|
||||||
@@ -122,14 +280,31 @@ function! ToggleMiniMaxiWin()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! ToggleNumbersAndGutter()
|
||||||
|
if !exists('b:numbers_and_gutter_on') || b:numbers_and_gutter_on == 1
|
||||||
|
set nonumber
|
||||||
|
set norelativenumber
|
||||||
|
GitGutterBufferDisable
|
||||||
|
let b:numbers_and_gutter_on=0
|
||||||
|
else
|
||||||
|
set number
|
||||||
|
set relativenumber
|
||||||
|
GitGutterBufferEnable
|
||||||
|
let b:numbers_and_gutter_on=1
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
nnoremap <leader>1 :call ToggleNumbersAndGutter()<CR>
|
||||||
|
|
||||||
" Key binds
|
" Key binds
|
||||||
"
|
"
|
||||||
command! Csc cscope find c <cword>
|
command! Csc cscope find c <cword>
|
||||||
|
|
||||||
" Easymotion leader
|
" Easymotion leader
|
||||||
map <Leader><tab> <Plug>(easymotion-prefix)
|
map <Leader><tab> <Plug>(easymotion-prefix)
|
||||||
" Forwards and backwards jump
|
" Forwards and backwards jump and visual select
|
||||||
map <tab> <Plug>(easymotion-s)
|
map <tab> <Plug>(easymotion-s)
|
||||||
|
map <space> <C-V><Plug>(easymotion-s)
|
||||||
" Forwards and backwards word jump
|
" Forwards and backwards word jump
|
||||||
map <Leader>w <Plug>(easymotion-bd-w)
|
map <Leader>w <Plug>(easymotion-bd-w)
|
||||||
" Easymotion overwin line
|
" Easymotion overwin line
|
||||||
@@ -146,36 +321,46 @@ vnoremap <leader>* y:%sno/<c-r>"//g<left><left>
|
|||||||
nmap <F2> :NERDTreeToggle<CR>
|
nmap <F2> :NERDTreeToggle<CR>
|
||||||
nmap <F3> :NERDTreeFind<CR>
|
nmap <F3> :NERDTreeFind<CR>
|
||||||
map <F5> :call CurtineIncSw()<CR>
|
map <F5> :call CurtineIncSw()<CR>
|
||||||
nmap <F8> :silent !/home/efjtjkb/bin/comp<enter>
|
|
||||||
" Remap <F9> (c-vim uses this)
|
|
||||||
"nmap <F9> :silent !/home/efjtjkb/bin/run<enter>
|
|
||||||
autocmd VimEnter * noremap <F9> :silent !/home/efjtjkb/bin/run<enter>
|
|
||||||
nmap <F10> :silent !/home/efjtjkb/bin/run old<enter>
|
|
||||||
|
|
||||||
nmap <Leader>cf :cd %:p:h <CR> " Change dir to parent of current file
|
nmap <Leader>cf :cd %:p:h <CR> " Change dir to parent of current file
|
||||||
nmap <Leader>cg :cd $git_root_location <CR> " Change dir to git root
|
nmap <Leader>cg :cd $git_root_location <CR> " Change dir to git root
|
||||||
nmap <Leader>vs :sp $MYVIMRC <CR>
|
nmap <Leader>vs :sp $HOME/.vimrc <CR>
|
||||||
nmap <Leader>vv :vsp $MYVIMRC <CR>
|
nmap <Leader>vv :vsp $HOME/.vimrc <CR>
|
||||||
nmap <Leader>vt :tabnew $MYVIMRC <CR>
|
nmap <Leader>vt :tabnew $HOME/.vimrc <CR>
|
||||||
nmap <Leader>vo :e $MYVIMRC <CR>
|
nmap <Leader>vo :e $HOME/.vimrc <CR>
|
||||||
nmap <Leader>v :e $MYVIMRC <CR>
|
nmap <Leader>v :e $HOME/.vimrc <CR>
|
||||||
|
|
||||||
" Match git conflict markers
|
" Match git conflict markers
|
||||||
nmap <Leader>/g /[<=>]\{7,}.*$<CR>
|
nmap <Leader>/g /[<=>]\{7,}.*$<CR>
|
||||||
|
" Git-Gutter status, commit, grep, blame
|
||||||
|
nmap <Leader>gs :Gstatus<CR>
|
||||||
|
nmap <Leader>gS :!git add %<CR>
|
||||||
|
nmap <Leader>gc :Gcommit<CR>
|
||||||
|
nmap <Leader>gg :Ggrep<space>
|
||||||
|
nmap <Leader>gb :Gblame<CR>
|
||||||
|
nmap <Leader>gu :GitGutterUndoHunk<CR>
|
||||||
|
|
||||||
|
" Fugitive Conflict Resolution
|
||||||
|
nnoremap <leader>gd :Gvdiffsplit!<CR>
|
||||||
|
nnoremap gdh :diffget //2<CR>
|
||||||
|
nnoremap gdl :diffget //3<CR>
|
||||||
|
|
||||||
" Toggle wrapping of long lines
|
" Toggle wrapping of long lines
|
||||||
nmap <Leader>l :set wrap!<CR>
|
nmap <Leader>l :set wrap!<CR>
|
||||||
|
|
||||||
" Strip trailing whitespace
|
" Strip trailing whitespace
|
||||||
nmap <Leader><space> :TrailWhitespace <CR>
|
nmap <Leader><space> :TrailWhitespace <CR>
|
||||||
|
|
||||||
" Scroll window while keeping cursor on same line with shift
|
" Scroll window while keeping cursor on same line with shift
|
||||||
nmap <S-j> <c-e>
|
nmap <S-j> <c-e>
|
||||||
nmap <S-k> <c-y>
|
nmap <S-k> <c-y>
|
||||||
vmap <S-j> <c-e>
|
vmap <S-j> <c-e>
|
||||||
vmap <S-k> <c-y>
|
vmap <S-k> <c-y>
|
||||||
|
|
||||||
|
" Toggle paste mode
|
||||||
|
nmap <Leader>p :set paste! <CR>
|
||||||
|
|
||||||
" Misc.
|
" Misc.
|
||||||
map <Leader>n :noh<CR>
|
map <Leader>n :noh<CR>
|
||||||
vmap <Leader>T :'<,'> Tabularize /
|
vmap <Leader>T :'<,'> Tabularize /
|
||||||
nnoremap <leader>c :execute "set colorcolumn=" . (&colorcolumn == "" ? "120" : "")<CR>
|
nnoremap <leader>c :execute "set colorcolumn=" . (&colorcolumn == "" ? "120" : "")<CR>
|
||||||
noremap <space> :
|
|
||||||
|
|||||||
19
.xinitrc
@@ -21,30 +21,13 @@ export CUPS_GSSSERVICENAME=HTTP
|
|||||||
|
|
||||||
[[ -f ~/.Xresources ]] && xrdb -merge ~/.Xresources
|
[[ -f ~/.Xresources ]] && xrdb -merge ~/.Xresources
|
||||||
|
|
||||||
volnoti &
|
|
||||||
owncloud &
|
|
||||||
|
|
||||||
rm -f "~/${WM}.log.old"
|
rm -f "~/${WM}.log.old"
|
||||||
mv -f "~/${WM}.log" "~/${WM}.log.old"
|
mv -f "~/${WM}.log" "~/${WM}.log.old"
|
||||||
rm -f "~/${WM}.log"
|
rm -f "~/${WM}.log"
|
||||||
rm -f "~/${WM}.log"
|
rm -f "~/${WM}.log"
|
||||||
|
|
||||||
if [ "$WM" = "i3" ]; then
|
if [ "$WM" = "i3" ]; then
|
||||||
# Generate i3 config file
|
. ~/.i3initrc
|
||||||
i3config="/tmp/i3_${USER}_config"
|
|
||||||
rm -f $i3config
|
|
||||||
|
|
||||||
if [ -f ~/.i3/base.config ]; then
|
|
||||||
cat ~/.i3/base.config >> $i3config
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "`hostname`" = "kubaArch" ] && [ -f ~/.i3/home.config ]; then
|
|
||||||
cat ~/.i3/home.config >> $i3config
|
|
||||||
elif [ "`hostname`" = "JakubArch" ] && [ -f ~/.i3/work.config ]; then
|
|
||||||
cat ~/.i3/work.config >> $i3config
|
|
||||||
fi
|
|
||||||
#exec i3 -c $i3config -V >> ~/${WM}.log 2>&1
|
|
||||||
exec i3 -c $i3config
|
|
||||||
else
|
else
|
||||||
exec $WM >> "~/${WM}.log" 2>&1
|
exec $WM >> "~/${WM}.log" 2>&1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
[Dolphin]
|
|
||||||
PreviewsShown=true
|
|
||||||
Timestamp=2013,5,20,10,21,15
|
|
||||||
Version=3
|
|
||||||
|
Before Width: | Height: | Size: 673 KiB |
|
Before Width: | Height: | Size: 341 KiB |
|
Before Width: | Height: | Size: 429 KiB |
|
Before Width: | Height: | Size: 334 KiB |
|
Before Width: | Height: | Size: 375 KiB |
|
Before Width: | Height: | Size: 957 KiB |
|
Before Width: | Height: | Size: 253 KiB |
|
Before Width: | Height: | Size: 472 KiB |
|
Before Width: | Height: | Size: 293 KiB |
@@ -1 +0,0 @@
|
|||||||
/home/kuba/Obrazy/Wallpapers/AxEcN - Imgur.jpg
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
OnBlH - Imgur.jpg
|
|
||||||
|
Before Width: | Height: | Size: 197 KiB |
@@ -1 +0,0 @@
|
|||||||
/home/kuba/Obrazy/Wallpapers/XQeqNhY.jpg
|
|
||||||