Compare commits

..

No commits in common. "e771a09fbead2656d8733bd44d466277fda6b904" and "e11085ca91d1d0f4506fc7dd95225f975acc892e" have entirely different histories.

17 changed files with 110 additions and 290 deletions

View File

@ -51,6 +51,7 @@ alias path='echo -e ${PATH//:/\\n}' # Pretty print path variables
# Programs # Programs
alias o="xdg-open" alias o="xdg-open"
alias v="nvim" alias v="nvim"
alias zk='cd ~/.zk && nvim "$(cat ~/.zk/current-zettel.txt)"'
alias g='git' alias g='git'
alias t=' task' alias t=' task'
alias tsh='tasksh' alias tsh='tasksh'

View File

@ -3,9 +3,7 @@
[[ -f ~/.bashrc ]] && . ~/.bashrc [[ -f ~/.bashrc ]] && . ~/.bashrc
export SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/ssh-agent.socket" export SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/ssh-agent.socket"
export _JAVA_AWT_WM_NONREPARENTING=1
if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then
if [[ -z "${DISPLAY}" ]] && [[ "${XDG_VTNR}" -eq 1 ]]; then
exec startx "$HOME/.config/X11/xinitrc" exec startx "$HOME/.config/X11/xinitrc"
fi fi

View File

@ -20,7 +20,7 @@ chmod +x <script>
## Notes ## Notes
Statusbar scripts are prefixed with `sb` under the assumption you're using Statusbar scripts are prefixed with `sb` under the assumption you're using
`polybar` (scripts my need changes to be used with different statusbars). `dwmblocks` (scripts my need changes to be used with different statusbars).
Some scripts have dependencies (e.g. `fzf`, `jq`, `xclip`, ...), make sure you Some scripts have dependencies (e.g. `fzf`, `jq`, `xclip`, ...), make sure you
have them installed. have them installed.

View File

@ -22,5 +22,3 @@ case "$1" in
--help) printf "open \n" >&2 ;; --help) printf "open \n" >&2 ;;
*) open "$(select_file)" ;; *) open "$(select_file)" ;;
esac esac
[[ -n "$selected" ]] && xdg-open "$selected" &> /dev/null & disown

View File

@ -1,3 +1,3 @@
#!/usr/bin/env bash #!/usr/bin/env bash
curl 127.0.0.1:8765 -X POST -d '{"action": "deckNames", "version": 6}' | jq '.result[]' -r curl localhost:8765 -X POST -d '{"action": "deckNames", "version": 6}' | jq '.result[]' -r

View File

@ -17,8 +17,8 @@ from plyer import notification
@atexit.register @atexit.register
def clear(): def clear():
if os.path.exists('/home/h/.local/share/pomo'): os.system('rm /tmp/pomo')
os.remove('/home/h/.local/share/pomo')
def format_mins_secs(mins, secs): def format_mins_secs(mins, secs):
return f"{mins:02d}:{secs:02d}" return f"{mins:02d}:{secs:02d}"
@ -30,7 +30,7 @@ def make_countdown():
mins = duration // 60 mins = duration // 60
secs = duration % 60 secs = duration % 60
time_str = format_mins_secs(mins, secs) time_str = format_mins_secs(mins, secs)
os.system(f'echo -n "{time_str}" > /home/h/.local/share/pomo') os.system(f'echo -n "{time_str}" > /tmp/pomo')
sleep(1) sleep(1)
duration -= 1 duration -= 1
return countdown return countdown
@ -68,14 +68,15 @@ def handle_signal(signal, frame):
if __name__ == '__main__': if __name__ == '__main__':
parser = ArgumentParser() parser = ArgumentParser()
parser.add_argument('-p', '--prep-duration', type=int,
help='Pre session duration', default=0)
parser.add_argument('-w', '--work-duration', type=int, parser.add_argument('-w', '--work-duration', type=int,
help='Session duration', default=25) help='Session duration', default=25)
parser.add_argument('-b', '--break-duration', type=int, parser.add_argument('-b', '--break-duration', type=int,
help='Break duration', default=5) help='Break duration', default=5)
parser.add_argument('-r', '--repeats', type=int, parser.add_argument('-r', '--repeats', type=int,
help='Numer of sessions', default=1) help='Numer of sessions', default=1)
parser.add_argument('-c', '--clear', action='store_true',
help='Clear timer')
args = parser.parse_args() args = parser.parse_args()

View File

@ -10,12 +10,12 @@
# https://unix.stackexchange.com/questions/100871/in-a-bash-if-condition-how-to-check-whether-any-files-matching-a-simple-wildcard # https://unix.stackexchange.com/questions/100871/in-a-bash-if-condition-how-to-check-whether-any-files-matching-a-simple-wildcard
if [ 0 -lt "$(ls $HOME/doc/*.kdbx 2>/dev/null | wc -w)" ]; then if [ 0 -lt "$(ls $HOME/doc/*.kdbx 2>/dev/null | wc -w)" ]; then
rclone copy "$HOME/doc" google-drive:doc --include "*.kdbx" rclone copy "$HOME/doc" google-drive: --include "*.kdbx"
rclone copy "$HOME/doc" google-drive:doc --include "*.kdbx.key" rclone copy "$HOME/doc" google-drive: --include "*.kdbx.key"
else else
echo "No password database found, use the following commands to restore" echo "No password database found, use the following commands to restore"
echo "" echo ""
echo "rclone copy google-drive:doc \"$HOME/doc\" --include \"*.kdbx\"" echo "rclone copy google-drive: \"$HOME/doc\" --include \"*.kdbx\""
echo "rclone copy google-drive:doc \"$HOME/doc\" --include \"*.kdbx.key\"" echo "rclone copy google-drive: \"$HOME/doc\" --include \"*.kdbx.key\""
exit 1 exit 1
fi fi

View File

@ -5,7 +5,7 @@
num_to_review=200 num_to_review=200
# Get current card count from Anki # Get current card count from Anki
count=$(curl -s 127.0.0.1:8765 -X POST -d '{"action": "getNumCardsReviewedToday", "version": 6}' | jq '.result') count=$(curl -s localhost:8765 -X POST -d '{"action": "getNumCardsReviewedToday", "version": 6}' | jq '.result')
if [ -z "$count" ] if [ -z "$count" ]
then then

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
ssh_hosts="$(grep -E 'Host [a-z0-9\-]*$' ~/.ssh/config | awk '{print $2}')" ssh_hosts=$(grep -E 'Host [a-z0-9\-]*$' ~/.ssh/config | awk '{print $2}')
echo "$ssh_hosts" echo "$ssh_hosts"

View File

@ -3,11 +3,16 @@
session="main" session="main"
tmux attach-session -t $session || tmux new-session -s $session \; \ tmux attach-session -t $session || tmux new-session -s $session \; \
rename-window task \; \ rename-window todo \; \
send-keys -t 1 "task" C-m \; \ send-keys -t 0 "task" C-m \; \
new-window -n zk \; \ new-window -n zk \; \
send-keys -t 2 "nvim $ZK_PATH/index.md" C-m \; \ send-keys -t 0 "nvim $ZK_PATH/index.md" C-m \; \
new-window -n term \; \
new-window -n music \; \ new-window -n music \; \
send-keys -t 4 "echo 'TODO: open music player'" C-m \; \ send-keys -t 0 "ncspot" C-m \; \
select-window -t 1 \; new-window -n term \; \
new-window -n make \; \
split-window -h \; \
split-window -h \; \
send-keys -t 0 'cd "$ZK_PATH" && ./entr' C-m \; \
send-keys -t 1 'cd "$ZK_PATH" && live-server . --watch=*.html' C-m \; \
select-window -t 2 \;

3
.bin/xrandr/get-displays Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
xrandr -q --current | sed -n 's/^\([^ ]\+\) connected .*/\1/p'

33
.bin/zk
View File

@ -1,33 +0,0 @@
#!/usr/bin/env bash
if [ "$TERM_PROGRAM" = tmux ]; then
cd ~/.zk && $EDITOR "$(cat ~/.zk/current-zettel.txt)"
else
echo 'Not in tmux'
echo 'Choose an option:'
echo '1. Open in tmux'
echo '2. Open in current terminal'
read -r -p 'Enter your choice: ' choice
case $choice in
1)
# Check if a tmux session is running with a window named zk
if tmux list-windows -F '#{window_name}' | grep -q zk; then
# Attach to the session containing the 'zk' window
session="$(tmux list-windows -F '#{window_name} #{session_name}' | grep zk | head -n 1 | awk '{ print $2 }')"
tmux attach -t "$session"
else
# Create session with a window named 'zk' and start nvim
tmux new-session -s zk -n zk -d
tmux send-keys -t zk:zk "cd ~/.zk && $EDITOR \"\$(cat ~/.zk/current-zettel.txt)\"" Enter
tmux attach -t zk
fi
;;
2)
cd ~/.zk && $EDITOR "$(cat ~/.zk/current-zettel.txt)"
;;
*)
echo 'Not opening Zettelkasten'
exit 1
;;
esac
fi

View File

@ -1,159 +0,0 @@
[colors]
background = #cccccc
background-alt = #aaaaaa
foreground = #111111
primary = #111111
secondary = #555555
disabled = #888888
[bar/example]
height = 16pt
radius = 0
background = ${colors.background}
foreground = ${colors.foreground}
padding-left = 0pt
module-margin = 1
separator = " "
separator-foreground = ${colors.disabled}
font-0 = Iosevka Term SS08:size=12;4
modules-left = xworkspaces xwindow
modules-center = project pomo
modules-right = filesystem pulseaudio memory cpu wlan eth date dunst-snooze xkeyboard battery
cursor-click = pointer
cursor-scroll = ns-resize
enable-ipc = true
[module/xworkspaces]
type = internal/xworkspaces
label-active = %name%
label-active-background = ${colors.background-alt}
label-active-underline= ${colors.primary}
label-active-padding = 4pt
label-occupied = %name%
label-occupied-padding = 4pt
label-urgent = %name%
label-urgent-background = ${colors.alert}
label-urgent-padding = 4pt
label-empty = %name%
label-empty-foreground = ${colors.disabled}
label-empty-padding = 4pt
[module/xwindow]
type = internal/xwindow
label = %title:0:60:...%
[module/filesystem]
type = internal/fs
interval = 25
mount-0 = /
label-mounted = %mountpoint% %percentage_used%%
label-unmounted = %mountpoint% not mounted
label-unmounted-foreground = ${colors.disabled}
[module/pulseaudio]
type = internal/pulseaudio
format-volume-prefix = "VOL "
format-volume-prefix-foreground = ${colors.primary}
format-volume = <label-volume>
label-volume = %percentage%%
label-muted = muted
label-muted-foreground = ${colors.disabled}
[module/memory]
type = internal/memory
interval = 2
format-prefix = "RAM "
format-prefix-foreground = ${colors.primary}
label = %percentage_used:2%%
[module/cpu]
type = internal/cpu
interval = 2
format-prefix = "CPU "
format-prefix-foreground = ${colors.primary}
label = %percentage:2%%
[network-base]
type = internal/network
interval = 5
format-connected = <label-connected>
format-disconnected = <label-disconnected>
label-disconnected = %ifname% disconnected
[module/wlan]
inherit = network-base
interface-type = wireless
label-connected = %ifname% %local_ip% %essid%
[module/eth]
inherit = network-base
interface-type = wired
label-connected = %ifname% %local_ip%
[module/date]
type = internal/date
interval = 1
date = W%V %d %b %H:%M
date-alt = %Y-%m-%d %H:%M:%S
label = %date%
label-foreground = ${colors.primary}
[module/pomo]
type = custom/script
exec = ~/.bin/sb-pomo
label-background = #fff
interval = 1
[module/focus-mode]
type = custom/script
exec = [[ -f /tmp/focus-mode ]] && echo "Focus"
label-background = #af0
interval = 1
[module/project]
type = custom/script
exec = cat ~/.project
label-background = #fa0
interval = 1000
[module/xkeyboard]
type = internal/xkeyboard
label-layout = %name% %variant%
blacklist-0 = num lock
blacklist-1 = scroll lock
[module/battery]
type = internal/battery
full-at = 99
low-at = 20
battery = BAT0
adapter = ADP1
poll-interval = 5
label-charging = .%percentage%++
format-low = <label-low><animation-low>
label-discharging = .%percentage%-- %time% %consumption%W
animation-low-0 = !
animation-low-1 = .
animation-low-framerate = 200
[settings]
screenchange-reload = true
pseudo-transparency = true
; vim:ft=dosini

View File

@ -1,15 +1,3 @@
# This file is written by xdg-user-dirs-update XDG_DESKTOP_DIR="$HOME"
# If you want to change or add directories, just edit the line you're
# interested in. All local changes will be retained on the next run.
# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
# absolute path. No other format is supported.
#
XDG_DESKTOP_DIR="$HOME/"
XDG_DOWNLOAD_DIR="$HOME/dl" XDG_DOWNLOAD_DIR="$HOME/dl"
XDG_DOCUMENTS_DIR="$HOME/doc" XDG_DOCUMENTS_DIR="$HOME/doc"
XDG_PUBLICSHARE_DIR="$HOME/"
XDG_MUSIC_DIR="$HOME/"
XDG_PICTURES_DIR="$HOME/"
XDG_TEMPLATES_DIR="$HOME/"
XDG_VIDEOS_DIR="$HOME/"

View File

@ -1,20 +1,6 @@
snippet b1(\w+) "Border (1px)" r snippet b1r "Red border (1px)"
`!p border: 1px solid red;
import re $0
colors = {
'r': 'red',
'g': 'green',
'b': 'blue',
'y': 'yellow',
'o': 'orange',
'p': 'purple',
'c': 'cyan',
'm': 'magenta',
'w': 'white',
}
color = colors.get(match.group(1), 'black')
snip.rv = f"border: 1px solid {color};"
`$0
endsnippet endsnippet
snippet df "Use flexbox layout" snippet df "Use flexbox layout"

38
.xmobarrc Normal file
View File

@ -0,0 +1,38 @@
Config { overrideRedirect = False
, font = "Iosevka Term SS08 12"
, textOffset = 1
, bgColor = "#cccccc"
, fgColor = "#111"
, position = TopH 20
, commands = [ Run Cpu
[ "-L", "3"
, "-H", "50"
, "--high" , "red"
] 10
, Run Battery [
"-t", "<acstatus>〈<left>% <timeleft>〉 ",
"--",
--"-c", "charge_full",
"-O", "AC",
"-o", "Bat",
"-h", "green",
"-l", "red"
] 10
, Run Alsa "default" "Master"
[ "--template", "V〈<volumestatus>〉 "
, "--suffix" , "True"
, "--"
, "--on", ""
]
, Run Memory ["--template", "Mem: <usedratio>%"] 10
, Run Date "W%V %a %b %d %H:%M" "date" 10
, Run Com "sb-pomo" [] "pomo" 10
, Run Com "sb-anki" [] "anki" 10
, Run Com "sb-tasks" [] "tasks" 300
, Run Com "sb-project" [] "proj" 300
, Run XMonadLog
]
, sepChar = "%"
, alignSep = "}{"
, template = "%XMonadLog% %anki% }%pomo% %proj% { %alsa:default:Master% %battery% %date%"
}

View File

@ -1,26 +1,26 @@
-- {{{ Imports -- {{{
import Control.Monad (liftM2)
import XMonad import XMonad
import XMonad.Actions.CopyWindow (copyToAll, killAllOtherCopies) import XMonad.Actions.CopyWindow (copyToAll, killAllOtherCopies)
import XMonad.Actions.FloatSnap import XMonad.Actions.FloatSnap
import Control.Monad (liftM2)
import XMonad.Hooks.DynamicProperty
import XMonad.Hooks.EwmhDesktops import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.OnPropertyChange (onXPropertyChange)
import XMonad.Hooks.StatusBar import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP import XMonad.Hooks.StatusBar.PP
import XMonad.Hooks.WindowSwallowing (swallowEventHook)
import XMonad.Layout.CenteredIfSingle import XMonad.Layout.CenteredIfSingle
import XMonad.Layout.IndependentScreens import XMonad.Layout.IndependentScreens
import XMonad.Layout.PerScreen import XMonad.Layout.PerScreen
import XMonad.Layout.Renamed import XMonad.Layout.Renamed
import XMonad.Layout.ShowWName
import XMonad.Layout.ThreeColumns import XMonad.Layout.ThreeColumns
import qualified XMonad.StackSet as W
import XMonad.Util.EZConfig import XMonad.Util.EZConfig
import qualified XMonad.Util.Hacks as Hacks
import XMonad.Util.Loggers import XMonad.Util.Loggers
import XMonad.Util.Paste import XMonad.Util.Paste
import qualified XMonad.StackSet as W
import qualified XMonad.Util.Hacks as Hacks
-- }}} -- }}}
@ -67,13 +67,12 @@ shiftAndView = doF . liftM2 (.) W.greedyView W.shift
-- Hooks {{{ -- Hooks {{{
-- startupHook {{{ -- startupHook
myStartupHook = myStartupHook =
do do
spawn "killall polybar && polybar -r" spawn "killall polybar && polybar -r"
-- }}}
-- manageHook {{{ -- manageHook
myManageHook :: ManageHook myManageHook :: ManageHook
myManageHook = myManageHook =
composeAll composeAll
@ -95,28 +94,36 @@ myManageHook =
className =? "KeePassXC" --> doRectFloat (W.RationalRect 0.1 0.1 0.8 0.8), className =? "KeePassXC" --> doRectFloat (W.RationalRect 0.1 0.1 0.8 0.8),
className =? "flameshot" --> doRectFloat (W.RationalRect 0.1 0.1 0.8 0.8) className =? "flameshot" --> doRectFloat (W.RationalRect 0.1 0.1 0.8 0.8)
] ]
-- }}}
-- dynamicManageHook {{{
myDynamicManageHook :: ManageHook myDynamicManageHook :: ManageHook
myDynamicManageHook = myDynamicManageHook =
composeAll composeAll
[ [
title =? "Zettelkasten — Firefox Developer Edition" --> doShift "1_sh" title =? "Zettelkasten — Firefox Developer Edition" --> doShift "1_sh"
] ]
-- }}}
-- layoutHook {{{ -- TODO: Replace showWName by dunst notification
myShowWNameConfig :: SWNConfig
myShowWNameConfig =
def
{ swn_font = "xft:Iosevka Term SS08:size=16",
swn_fade = 0.3,
swn_color = "#111111",
swn_bgcolor = "#cccccc"
}
-- layoutHook
myLayoutHook = myLayoutHook =
ifWider smallWidth ( showWName' myShowWNameConfig $
t ||| -- Tiled layouts ifWider smallWidth (
c3 ||| -- Column layouts t ||| -- Tiled layouts
c3m ||| -- c3 ||| -- Column layouts
f -- Monocle layouts c3m ||| --
) ( f -- Monocle layouts
t ||| -- Tiled layouts ) (
f -- Monocle layouts t ||| -- Tiled layouts
) f -- Monocle layouts
)
where where
smallWidth = 1920 smallWidth = 1920
t = renamed [Replace "[]+"] $ ifWider smallWidth (centeredIfSingle 0.8 0.9 $ Tall nmaster delta ratio) t = renamed [Replace "[]+"] $ ifWider smallWidth (centeredIfSingle 0.8 0.9 $ Tall nmaster delta ratio)
@ -127,17 +134,6 @@ myLayoutHook =
nmaster = 1 nmaster = 1
ratio = 1 / 2 ratio = 1 / 2
delta = 4 / 100 delta = 4 / 100
-- }}}
-- handleEventHook {{{
myHandleEventHook =
handleEventHook def
-- See window swallowing (https://hackage.haskell.org/package/xmonad-contrib-0.18.0/docs/XMonad-Hooks-WindowSwallowing.html)
<> swallowEventHook (className =? "Alacritty") (return True)
<> onXPropertyChange "WM_NAME" myDynamicManageHook
<> Hacks.windowedFullscreenFixEventHook
<> hintsEventHook
-- }}}
-- }}} -- }}}
@ -147,13 +143,12 @@ myWorkspaces = [ "sh", "www", "dev", "info", "etc" ]
myWorkspaceKeys = [ "a", "s", "d", "f", "g" ] myWorkspaceKeys = [ "a", "s", "d", "f", "g" ]
mySharedWorkspaces = [ "shared" ] mySharedWorkspaces = [ "shared" ]
mySharedWorkspaceKeys = [ "1" ] mySharedWorkspaceKeys = [ "1" ]
-- Use Win key instead of Alt
myModMask = mod4Mask
myConfig = myConfig =
def def
{ terminal = "alacritty", { terminal = "alacritty",
modMask = myModMask, -- Use Win key instead of Alt
modMask = mod4Mask,
workspaces = withScreen 1 myWorkspaces ++ withScreen 2 mySharedWorkspaces, workspaces = withScreen 1 myWorkspaces ++ withScreen 2 mySharedWorkspaces,
-- Styling -- Styling
focusedBorderColor = "#000", focusedBorderColor = "#000",
@ -163,7 +158,7 @@ myConfig =
startupHook = myStartupHook, startupHook = myStartupHook,
manageHook = myManageHook <+> manageHook def, manageHook = myManageHook <+> manageHook def,
layoutHook = avoidStruts myLayoutHook, layoutHook = avoidStruts myLayoutHook,
handleEventHook = myHandleEventHook handleEventHook = dynamicPropertyChange "WM_NAME" myDynamicManageHook <> handleEventHook def <> Hacks.windowedFullscreenFixEventHook
} }
`removeKeysP` myRemoveKeys `removeKeysP` myRemoveKeys
`additionalKeysP` myKeys `additionalKeysP` myKeys
@ -201,10 +196,7 @@ myKeys =
("M-S-<XF86MonBrightnessDown>", resetTemp), -- ("M-S-<XF86MonBrightnessDown>", resetTemp), --
("M-S-b", fullscreenBrowser), ("M-S-b", fullscreenBrowser),
("<XF86Calculator>", spawnCalculator), ("<XF86Calculator>", spawnCalculator),
("<XF86PowerOff>", spawn "systemctl suspend"), --TODO: Only enable this on laptop ("<XF86PowerOff>", spawn "systemctl suspend") --TODO: Only enable this on laptop
("M-c", windows copyToAll),
("M-S-c", killAllOtherCopies),
("M-S-<Delete>", kill)
] ++ ] ++
[ (m ++ k, windows $ f w) | [ (m ++ k, windows $ f w) |
(m, f) <- zip ["M-", "M-S-"] (m, f) <- zip ["M-", "M-S-"]
@ -213,6 +205,9 @@ myKeys =
(withScreen 1 myWorkspaces) (withScreen 1 myWorkspaces)
++ zip mySharedWorkspaceKeys ++ zip mySharedWorkspaceKeys
(withScreen 2 mySharedWorkspaces) (withScreen 2 mySharedWorkspaces)
("M-c", windows copyToAll),
("M-S-c", killAllOtherCopies),
("M-S-<Delete>", kill)
] ]
zipKeyPrefixes :: [String] -> [String] -> [String] zipKeyPrefixes :: [String] -> [String] -> [String]
@ -247,9 +242,8 @@ spawnKeepassXC = spawn "keepassxc"
fullscreenBrowser :: X () fullscreenBrowser :: X ()
fullscreenBrowser = spawn "firefox --fullscreen" fullscreenBrowser = spawn "firefox --fullscreen"
spawnLauncher, spawnClipManager, spawnCalculator :: X () spawnLauncher :: X ()
spawnLauncher = spawn "rofi -show drun -show-icons" spawnLauncher = spawn "albert toggle"
spawnClipManager = spawn "rofi -modi 'clipboard:greenclip print' -show clipboard -run-command '{cmd}'"
spawnCalculator = spawn "alacritty --class 'Calculator' -e ipython -i /home/h/.bin/calc.py" spawnCalculator = spawn "alacritty --class 'Calculator' -e ipython -i /home/h/.bin/calc.py"
printScreen :: X () printScreen :: X ()