dotfiles

Cem's Dotfiles
git clone git://git.ckyln.com/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 4a8ee2b5a349af6d057b57eee24ff4832a7415fc
parent 67f3d0781b18b5d35ad54d2f7841b0948824e0fd
Author: Cem Keylan <cem@ckyln.com>
Date:   Mon, 23 Sep 2019 14:43:22 +0300

New changes

Diffstat:
M.config/rofi/config | 4++--
Rbin/bar.sh -> .local/bin/bar.sh | 0
A.local/bin/bug | 367+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rbin/cfi -> .local/bin/cfi | 0
Rbin/cfp -> .local/bin/cfp | 0
A.local/bin/checkdwm | 15+++++++++++++++
Rbin/checksunset -> .local/bin/checksunset | 0
Rbin/checktoday -> .local/bin/checktoday | 0
Rbin/dmenumount -> .local/bin/dmenumount | 0
Rbin/dmenuumount -> .local/bin/dmenuumount | 0
Rbin/dwatch -> .local/bin/dwatch | 0
Rbin/editstdout -> .local/bin/editstdout | 0
A.local/bin/gmks | 2++
A.local/bin/irc | 21+++++++++++++++++++++
Rbin/lockme -> .local/bin/lockme | 0
Rbin/mpctoggle -> .local/bin/mpctoggle | 0
Rbin/nightmodecheck -> .local/bin/nightmodecheck | 0
A.local/bin/nightmodetoggle | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rbin/nlr -> .local/bin/nlr | 0
Rbin/powercheck -> .local/bin/powercheck | 0
Rbin/sdmenu -> .local/bin/sdmenu | 0
Rbin/startdwm -> .local/bin/startdwm | 0
Rbin/todo -> .local/bin/todo | 0
Rbin/todoadd -> .local/bin/todoadd | 0
Rbin/todorm -> .local/bin/todorm | 0
Rbin/updot -> .local/bin/updot | 0
Rbin/wallset -> .local/bin/wallset | 0
Rbin/yousure -> .local/bin/yousure | 0
Rbin/yousurereb -> .local/bin/yousurereb | 0
M.profile | 2+-
M.xinitrc | 3++-
Dbin/nightmodetoggle | 55-------------------------------------------------------
32 files changed, 465 insertions(+), 59 deletions(-)

diff --git a/.config/rofi/config b/.config/rofi/config @@ -32,8 +32,8 @@ rofi.display-window: Currently Open rofi.display-run: Execute rofi.display-drun: Applications rofi.display-ssh: Secure Socket Shell -rofi.eh: 1 -rofi.line-margin: 2 +rofi.eh: 1 +rofi.line-margin: 2 rofi.line-padding: 3 rofi.opacity: 100 diff --git a/bin/bar.sh b/.local/bin/bar.sh diff --git a/.local/bin/bug b/.local/bin/bug @@ -0,0 +1,367 @@ +#!/bin/bash +# (encoding: UTF-8) +# +# bug 1.1 - Simple Bug / ToDo tracker for the command line. +# (Instructions below the license) +# LICENSE +# Copyright (C) 2006 LluĂ­s Batlle i Rossell +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Instructions: +# 1. Your $BUG_PROJECT should point to a file. It will be the database you'll +# be using. Use an absolute path. It may be, for instance, "~/todo.bug" +# +# Having the $BUG_PROJECT set: +# 1. Create the database: +# bug create +# 2. Add an issue +# bug add +# Use integers for the priorities. Higher -> more priority. +# Use any words you prefer for the state +# Don't break the number of lines until "-- Description --". Write +# multilines only below that label. +# 3. List the issues (all but description, priority sorted) +# bug list [ | grep as_you_wish ] +# 4. View an issue +# bug view <ID> +# 5. Edit an issue +# bug edit <ID> +# Change the state, the priority, add data as long as you fix it, ... +# When I consider an issue is fulfilled, I negate its priority. +# 6. Delete an issue +# bug delete <ID> +# Do that whenever you will not need the issue anymore. +# +# +# Contributions: +# -------------- +# +# pancake <pancake@youterm.com> +# - drop bashisms +# - implement -h flag +# - error messages to stderr +# - more checks and help on BUG_PROJECT environ +# +# TODO: +# Support for an array of bug report files ?? readonly +# Check BUG_PROJECT file format before processing +# + +PNAME=`basename "$0"` +CMD="$1" + +if [ -z "$EDITOR" ]; then + EDITOR=vim +fi + +function usage +{ + echo "Usage: $PNAME [add | list | view | edit | delete | create | project | version]" +} + +function create +{ + if [ ! -f "$BUG_PROJECT" ]; then + echo 0 > "$BUG_PROJECT" + return 0 + else + echo "The project exists. Please remove the file before create." 2>&1 + return 1 + fi +} + +function getnext +{ + head -n 1 "$BUG_PROJECT" +} + +function updatenext +{ + NEXT=$1 + ed $BUG_PROJECT >&/dev/null << END +1 +c +$NEXT +. +w +q +END + +} + +function trim +{ + sed 's/^ *//g; s/ *$//g' +} +function trimlastdbNL +{ + sed 's/\\n$//g' +} + +function noNL +{ + tr -d "\\n" +} + +function string2db +{ + noNL | trim | sed 's/\t/\\t/g' +} + +function text2db +{ + sed 's/\t/\\t/g ; s/$/\\/g' | tr "\\n" n +} + +function db2text +{ + sed 's/\\t/\t/g ; s/\\n/\n/g' +} + +function addfile +{ + ID=`grep "^Id:" $1 | head -n 1 | cut -d : -f 2- | string2db` + SUBJECT=`grep "^Subject:" $1 | head -n 1 | cut -d : -f 2- | string2db` + STATE=`grep "^State:" $1 | head -n 1 | cut -d : -f 2- | string2db` + PRIORITY=`grep "^Priority:" $1 | head -n 1 | cut -d : -f 2- | string2db` + + if [ -z "$PRIORITY" ]; then + echo "Error in ticket: subject or priority." > /dev/stderr + return 1 + fi + + if [ -z "$SUBJECT" ]; then + echo "Error in ticket: subject or priority." > /dev/stderr + return 1 + fi + + LINES=`cat $1 | wc -l` + + # Substract Id, Subject, State and Priority + #TOTAIL=$(( LINES - 5 )) + let TOTAIL=LINES-5 + DESCRIPTION=`tail -n $TOTAIL $1 | text2db | trimlastdbNL` + + echo "$ID $PRIORITY $STATE $SUBJECT $DESCRIPTION" >> $BUG_PROJECT + + # Update the next ID number + NEXT=`getnext` + if [ $NEXT -gt $ID ]; then + updatenext $((NEXT + 1)) + else + updatenext $((ID + 1)) + fi + + return 0 +} + +function list +{ + echo "Id Prior. State Subject" + catlist | cut -f 1,2,3,4 | sort -n -r -k 2 +} + +function view +{ + ID=$1 + + LINE=`catlist | grep "^$ID "` + + if [ -n "$LINE" ]; then + PRIORITY=`echo "$LINE" | cut -f 2` + STATE=`echo "$LINE" | cut -f 3` + SUBJECT=`echo "$LINE" | cut -f 4` + DESCRIPTION=`echo "$LINE" | cut -f 5` + + echo "Id: $ID" | db2text + echo "Priority: $PRIORITY" | db2text + echo "State: $STATE" | db2text + echo "Subject: $SUBJECT" | db2text + echo "-- Description below --" + echo "$DESCRIPTION" | db2text + return 0 + else + echo "Id not found." 2>&1 + return 1 + fi +} + +function catlist +{ + LINES=`cat $BUG_PROJECT | wc -l` + let TOTAIL=LINES-1 + #TOTAIL=$(( LINES - 1 )) + tail -n $TOTAIL $BUG_PROJECT | grep -v "^#" +} + +function version +{ + echo "bug 1.1 - Simple Bug / ToDo tracker for the command line." + echo "Copyright (C) 2006 Lluis Batlle i Rossell" +} + +function searchline +{ + ID=$1 + + LINE=`cat $BUG_PROJECT | grep -n "^$ID " | cut -d : -f 1` + if [ -n "$LINE" ]; then + echo $LINE + return 0 + else + return 1 + fi +} + +function delete +{ + ID=$1 + LINE=`searchline $ID` + if [ $? -eq 0 ]; then + ed $BUG_PROJECT >&/dev/null << END +$LINE +d +w +q +END + else + echo "Id not found." 2>&1 + fi +} + +function edit +{ + ID=$1 + + # Get a random file + FILE="/tmp/$RANDOM.txt" + while [ -f "$FILE" ]; do + FILE="/tmp/$RANDOM.txt" + done + + view $ID > $FILE + + if [ $? -eq 0 ]; then + MD5=`md5sum "$FILE"` + + "$EDITOR" "$FILE" + + MD5_bis=`md5sum "$FILE"` + + if [ "$MD5" != "$MD5_bis" ]; then + delete $ID + addfile "$FILE" && rm "$FILE" + else + echo "File not changed. Not changing the ticket." + rm "$FILE" + fi + else + echo "Id not found." + rm "$FILE" + fi +} + +function add +{ + # Get a random file + FILE="/tmp/$RANDOM.txt" + while [ -f "$FILE" ]; do + FILE="/tmp/$RANDOM.txt" + done + + ID=`getnext` + + cat > "$FILE" << TEMPLATE +Id: $ID +Priority: +State: +Subject: +-- Description below -- +TEMPLATE + MD5=`md5sum "$FILE"` + + "$EDITOR" "$FILE" + + MD5_bis=`md5sum "$FILE"` + + if [ "$MD5" != "$MD5_bis" ]; then + addfile "$FILE" && rm "$FILE" + else + echo "File not changed. Not adding a ticket." + rm "$FILE" + fi + +} + +if [ -z "$BUG_PROJECT" ]; then + echo "\$BUG_PROJECT is not set." + exit 1 +fi + +if [ ! "`echo $BUG_PROJECT | cut -c 1`" = "/" ]; then + echo "Do not use relative paths in BUG_PROJECT environ." + exit 1 +fi + +if [ ! "$CMD" = "create" ]; then +if [ ! -f "$BUG_PROJECT" ]; then + echo "BUG_PROJECT file does not exist. Type 'bug create'" + exit 0 +fi +fi + +if [ -z "$CMD" ]; then + usage + exit 1 +fi + +case "$CMD" in + -h) + echo "Usage: bug [[alvpe] [del] [create]] [args]" + exit 1 + ;; + a*) + add || exit 1 + ;; + l*) + list || exit 1 + ;; + ver*) + version || exit 1 + ;; + v*) + view $2 || exit 1 + ;; + p*) + echo Project: $BUG_PROJECT + ;; + del*) + delete $2 || exit 1 + ;; + create) + create || exit 1 + ;; + e*) + edit $2 || exit 1 + ;; + *) + usage + exit 1 + ;; +esac +exit 0 + +# vim:ts=8:sw=8:noet diff --git a/bin/cfi b/.local/bin/cfi diff --git a/bin/cfp b/.local/bin/cfp diff --git a/.local/bin/checkdwm b/.local/bin/checkdwm @@ -0,0 +1,15 @@ +#!/bin/sh +csum=$(sha1sum $(which dwm)) +new_csum="" +while true +do + if [ "$csum" != "$new_csum" ] + then + csum=$new_csum + dwm + else + exit 0 + fi + new_csum=$(sha1sum $(which dwm)) + sleep 0.5 +done diff --git a/bin/checksunset b/.local/bin/checksunset diff --git a/bin/checktoday b/.local/bin/checktoday diff --git a/bin/dmenumount b/.local/bin/dmenumount diff --git a/bin/dmenuumount b/.local/bin/dmenuumount diff --git a/bin/dwatch b/.local/bin/dwatch diff --git a/bin/editstdout b/.local/bin/editstdout diff --git a/.local/bin/gmks b/.local/bin/gmks @@ -0,0 +1,2 @@ +#!/bin/sh +st -t Gomuks -e /bin/sh -c gomuks diff --git a/.local/bin/irc b/.local/bin/irc @@ -0,0 +1,21 @@ +#!/bin/sh + +DEFHOST="irc.oftc.net" +DEFPORT="6667" + +if ! [ -e $HOME/.sicrc ] +then + touch $HOME/.sicrc + UHOST="$(printf "irc.oftc.net\n" | dmenu -i -p "Hello, what host do you want to connect? (default: irc.oftc.net):")" + [ -n "$UHOST" ] && HOST="$UHOST" || HOST="$DEFHOST" + UPORT="$(printf "6667\n" | dmenu -i -p PORT:)" + [ -n "$UPORT" ] && PORT="$UPORT" || PORT="$DEFPORT" + UNICK="$(printf "$USER\n" | dmenu -i -p NICK:)" + [ -n "$UNICK" ] && NICK="$UNICK" || NICK="$USER" + printf \ +"#!/bin/sh\nHOST=\"$HOST\"\nPORT=\"$PORT\"\nNICK=\"$NICK\"\n" > $HOME/.sicrc + notify-send "Simple IRC Client" "The file has been written to $HOME/.sicrc\n" +fi +. $HOME/.sicrc + +st -t IRC -e /bin/sh -c "sic -n ${NICK} -h ${HOST} -p ${PORT}" diff --git a/bin/lockme b/.local/bin/lockme diff --git a/bin/mpctoggle b/.local/bin/mpctoggle diff --git a/bin/nightmodecheck b/.local/bin/nightmodecheck diff --git a/.local/bin/nightmodetoggle b/.local/bin/nightmodetoggle @@ -0,0 +1,55 @@ +#!/bin/sh + +if [ -e $HOME/.night ] +then + case $1 in + "click") + NIGHT=$(tail -n -1 $HOME/.night) + if [ $NIGHT = 'NIGHT=1' ] + then + NIGHT='NIGHT=0' + else + NIGHT='NIGHT=1' + fi + echo 'CLICK=1' > $HOME/.night + echo $NIGHT >> $HOME/.night + ;; + "disable") + NIGHT=$(tail -n -1 $HOME/.night) + echo 'CLICK=0' > $HOME/.night + echo $NIGHT >> $HOME/.night + $HOME/.local/bin/nightmodetoggle cron + exit + ;; + "cron") + if [ $(head -n +1 $HOME/.night) = "CLICK=1" ] + then + exit + else + [ -e $HOME/.sunset ] && . $HOME/.sunset + [ -z $SUNSET ] && SUNSET=1959 + [ -z $SUNRISE ] && SUNRISE=0600 + if [ `date +%H%M` -gt "$SUNSET" ] || [ `date +%H%M` -lt "$SUNRISE" ] + then + printf "CLICK=0\nNIGHT=1" > $HOME/.night + else + printf "CLICK=0\nNIGHT=0" > $HOME/.night + fi + fi + ;; + *) + printf "Please enter an argument!\ne.g.\nclick\ndisable\ncron\n" + exit + ;; + esac + if [ $(tail -n -1 $HOME/.night) = "NIGHT=1" ] + then + + feh --bg-fill --randomize $HOME/Pictures/Wallpapers/Night/* + else + feh --bg-fill --randomize $HOME/Pictures/Wallpapers/Morning/* + fi +else + touch $HOME/.night + printf "CLICK=0\nNIGHT=0" > $HOME/.night +fi diff --git a/bin/nlr b/.local/bin/nlr diff --git a/bin/powercheck b/.local/bin/powercheck diff --git a/bin/sdmenu b/.local/bin/sdmenu diff --git a/bin/startdwm b/.local/bin/startdwm diff --git a/bin/todo b/.local/bin/todo diff --git a/bin/todoadd b/.local/bin/todoadd diff --git a/bin/todorm b/.local/bin/todorm diff --git a/bin/updot b/.local/bin/updot diff --git a/bin/wallset b/.local/bin/wallset diff --git a/bin/yousure b/.local/bin/yousure diff --git a/bin/yousurereb b/.local/bin/yousurereb diff --git a/.profile b/.profile @@ -4,7 +4,7 @@ export TERMINAL="st" export BROWSER="qutebrowser" export XDG_CONFIG_HOME=$HOME/.config -export PATH=$HOME/bin/:$PATH +export PATH=$HOME/.local/bin/:$PATH export PATH=$HOME/.scripts/:$PATH export PATH=/usr/local/bin/:$PATH export PATH=$HOME/.vim/bundle/vim-live-latex-preview/bin/:$PATH diff --git a/.xinitrc b/.xinitrc @@ -1,6 +1,7 @@ #!/bin/sh +. $HOME/.profile compton & -/home/cem/bin/nightmodetoggle disable & +nightmodetoggle disable & powercheck & # Launch Bar while true : diff --git a/bin/nightmodetoggle b/bin/nightmodetoggle @@ -1,55 +0,0 @@ -#!/bin/sh - -if [ -e $HOME/.night ] -then - case $1 in - "click") - NIGHT=$(tail -n -1 $HOME/.night) - if [ $NIGHT = 'NIGHT=1' ] - then - NIGHT='NIGHT=0' - else - NIGHT='NIGHT=1' - fi - echo 'CLICK=1' > $HOME/.night - echo $NIGHT >> $HOME/.night - ;; - "disable") - NIGHT=$(tail -n -1 $HOME/.night) - echo 'CLICK=0' > $HOME/.night - echo $NIGHT >> $HOME/.night - $HOME/bin/nightmodetoggle cron - exit - ;; - "cron") - if [ $(head -n +1 $HOME/.night) = "CLICK=1" ] - then - exit - else - [ -e $HOME/.sunset ] && . $HOME/.sunset - [ -z $SUNSET ] && SUNSET=1959 - [ -z $SUNRISE ] && SUNRISE=0600 - if [ `date +%H%M` -gt "$SUNSET" ] || [ `date +%H%M` -lt "$SUNRISE" ] - then - printf "CLICK=0\nNIGHT=1" > $HOME/.night - else - printf "CLICK=0\nNIGHT=0" > $HOME/.night - fi - fi - ;; - *) - printf "Please enter an argument!\ne.g.\nclick\ndisable\ncron\n" - exit - ;; - esac - if [ $(tail -n -1 $HOME/.night) = "NIGHT=1" ] - then - - feh --bg-fill --randomize $HOME/Pictures/Wallpapers/Night/* - else - feh --bg-fill --randomize $HOME/Pictures/Wallpapers/Morning/* - fi -else - touch $HOME/.night - printf "CLICK=0\nNIGHT=0" > $HOME/.night -fi