Compare commits

..

24 Commits

Author SHA1 Message Date
Hektor Misplon e771a09fbe
Add 'swallowEventHook' 2024-03-30 16:50:15 +01:00
Hektor Misplon b6ba9ab4ea
Remove ShowWName stuff 2024-03-30 16:27:19 +01:00
Hektor Misplon 09812befdc
Add folds for hooks 2024-03-30 16:26:32 +01:00
Hektor Misplon f98b19f0b1
Add 'myHandleEventHook' 2024-03-30 16:21:22 +01:00
Hektor Misplon d2bf1ed9bd
Add 'myModMask' 2024-03-30 16:17:43 +01:00
Hektor Misplon 3795d10197
Organize imports 2024-03-30 16:15:35 +01:00
Hektor Misplon b0df672009
Fix deprecated 'dynamicPropertyChange' 2024-03-30 16:00:54 +01:00
Hektor Misplon 42df25d5cc
Update '.bash_profile' 2024-01-30 21:51:18 +01:00
Hektor Misplon ac066bb076
Add '1px border <color>' snippets 2024-01-30 21:48:10 +01:00
Hektor Misplon 01842d8f1e
Use polybar config 2024-01-30 15:54:02 +01:00
Hektor Misplon 4b74af8b99
Update readme 2024-01-28 21:21:44 +01:00
Hektor Misplon 28d1e36003
Update 'fzf-book' script 2024-01-28 21:21:33 +01:00
Hektor Misplon 4708739c66
Update anki scripts 2024-01-28 21:20:49 +01:00
Hektor Misplon bb54ec3629
Remove 'prep-duration' argument 2024-01-28 21:20:21 +01:00
Hektor Misplon e9017047cd
Update 'clear' argument 2024-01-28 21:20:05 +01:00
Hektor Misplon 6aefd6bd92
Update pomo directory 2024-01-28 21:19:21 +01:00
Hektor Misplon 71d8b33123
Update drive directory 2024-01-28 21:17:59 +01:00
Hektor Misplon 93f223c1ec
Update 'tmux-workspace' script 2024-01-28 20:34:43 +01:00
Hektor Misplon 3d1fe7b173
Fix shellcheck warning 2024-01-28 20:33:29 +01:00
Hektor Misplon bab4c612f3
Remove 'get-displays' 2024-01-28 20:32:17 +01:00
Hektor Misplon 16c87b6b4c
Use rofi launcher 2024-01-28 20:27:45 +01:00
Hektor Misplon 892ab35612
Update key bindings 2024-01-28 20:26:46 +01:00
Hektor Misplon 958de4e03c
Add 'zk' script 2024-01-26 12:27:41 +01:00
Hektor Misplon fade05a394
Update user-dirs 2024-01-26 12:19:17 +01:00
17 changed files with 290 additions and 110 deletions

View File

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

View File

@ -3,7 +3,9 @@
[[ -f ~/.bashrc ]] && . ~/.bashrc
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"
fi

View File

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

View File

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

View File

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

View File

@ -17,8 +17,8 @@ from plyer import notification
@atexit.register
def clear():
os.system('rm /tmp/pomo')
if os.path.exists('/home/h/.local/share/pomo'):
os.remove('/home/h/.local/share/pomo')
def format_mins_secs(mins, secs):
return f"{mins:02d}:{secs:02d}"
@ -30,7 +30,7 @@ def make_countdown():
mins = duration // 60
secs = duration % 60
time_str = format_mins_secs(mins, secs)
os.system(f'echo -n "{time_str}" > /tmp/pomo')
os.system(f'echo -n "{time_str}" > /home/h/.local/share/pomo')
sleep(1)
duration -= 1
return countdown
@ -68,15 +68,14 @@ def handle_signal(signal, frame):
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('-p', '--prep-duration', type=int,
help='Pre session duration', default=0)
parser.add_argument('-w', '--work-duration', type=int,
help='Session duration', default=25)
parser.add_argument('-b', '--break-duration', type=int,
help='Break duration', default=5)
parser.add_argument('-r', '--repeats', type=int,
help='Numer of sessions', default=1)
parser.add_argument('-c', '--clear', action='store_true',
help='Clear timer')
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
if [ 0 -lt "$(ls $HOME/doc/*.kdbx 2>/dev/null | wc -w)" ]; then
rclone copy "$HOME/doc" google-drive: --include "*.kdbx"
rclone copy "$HOME/doc" google-drive: --include "*.kdbx.key"
rclone copy "$HOME/doc" google-drive:doc --include "*.kdbx"
rclone copy "$HOME/doc" google-drive:doc --include "*.kdbx.key"
else
echo "No password database found, use the following commands to restore"
echo ""
echo "rclone copy google-drive: \"$HOME/doc\" --include \"*.kdbx\""
echo "rclone copy google-drive: \"$HOME/doc\" --include \"*.kdbx.key\""
echo "rclone copy google-drive:doc \"$HOME/doc\" --include \"*.kdbx\""
echo "rclone copy google-drive:doc \"$HOME/doc\" --include \"*.kdbx.key\""
exit 1
fi

View File

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

View File

@ -1,5 +1,5 @@
#!/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"

View File

@ -3,16 +3,11 @@
session="main"
tmux attach-session -t $session || tmux new-session -s $session \; \
rename-window todo \; \
send-keys -t 0 "task" C-m \; \
rename-window task \; \
send-keys -t 1 "task" C-m \; \
new-window -n zk \; \
send-keys -t 0 "nvim $ZK_PATH/index.md" C-m \; \
new-window -n music \; \
send-keys -t 0 "ncspot" C-m \; \
send-keys -t 2 "nvim $ZK_PATH/index.md" C-m \; \
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 \;
new-window -n music \; \
send-keys -t 4 "echo 'TODO: open music player'" C-m \; \
select-window -t 1 \;

View File

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

33
.bin/zk Executable file
View File

@ -0,0 +1,33 @@
#!/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

159
.config/polybar/config.ini Normal file
View File

@ -0,0 +1,159 @@
[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,3 +1,15 @@
XDG_DESKTOP_DIR="$HOME"
# This file is written by xdg-user-dirs-update
# 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_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,6 +1,20 @@
snippet b1r "Red border (1px)"
border: 1px solid red;
$0
snippet b1(\w+) "Border (1px)" r
`!p
import re
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
snippet df "Use flexbox layout"

View File

@ -1,38 +0,0 @@
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.Actions.CopyWindow (copyToAll, killAllOtherCopies)
import XMonad.Actions.FloatSnap
import Control.Monad (liftM2)
import XMonad.Hooks.DynamicProperty
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.OnPropertyChange (onXPropertyChange)
import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP
import XMonad.Hooks.WindowSwallowing (swallowEventHook)
import XMonad.Layout.CenteredIfSingle
import XMonad.Layout.IndependentScreens
import XMonad.Layout.PerScreen
import XMonad.Layout.Renamed
import XMonad.Layout.ShowWName
import XMonad.Layout.ThreeColumns
import qualified XMonad.StackSet as W
import XMonad.Util.EZConfig
import qualified XMonad.Util.Hacks as Hacks
import XMonad.Util.Loggers
import XMonad.Util.Paste
import qualified XMonad.StackSet as W
import qualified XMonad.Util.Hacks as Hacks
-- }}}
@ -67,12 +67,13 @@ shiftAndView = doF . liftM2 (.) W.greedyView W.shift
-- Hooks {{{
-- startupHook
-- startupHook {{{
myStartupHook =
do
spawn "killall polybar && polybar -r"
-- }}}
-- manageHook
-- manageHook {{{
myManageHook :: ManageHook
myManageHook =
composeAll
@ -94,36 +95,28 @@ myManageHook =
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)
]
-- }}}
-- dynamicManageHook {{{
myDynamicManageHook :: ManageHook
myDynamicManageHook =
composeAll
[
title =? "Zettelkasten — Firefox Developer Edition" --> doShift "1_sh"
]
-- }}}
-- 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
-- layoutHook {{{
myLayoutHook =
showWName' myShowWNameConfig $
ifWider smallWidth (
t ||| -- Tiled layouts
c3 ||| -- Column layouts
c3m ||| --
f -- Monocle layouts
) (
t ||| -- Tiled layouts
f -- Monocle layouts
)
ifWider smallWidth (
t ||| -- Tiled layouts
c3 ||| -- Column layouts
c3m ||| --
f -- Monocle layouts
) (
t ||| -- Tiled layouts
f -- Monocle layouts
)
where
smallWidth = 1920
t = renamed [Replace "[]+"] $ ifWider smallWidth (centeredIfSingle 0.8 0.9 $ Tall nmaster delta ratio)
@ -134,6 +127,17 @@ myLayoutHook =
nmaster = 1
ratio = 1 / 2
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
-- }}}
-- }}}
@ -143,12 +147,13 @@ myWorkspaces = [ "sh", "www", "dev", "info", "etc" ]
myWorkspaceKeys = [ "a", "s", "d", "f", "g" ]
mySharedWorkspaces = [ "shared" ]
mySharedWorkspaceKeys = [ "1" ]
-- Use Win key instead of Alt
myModMask = mod4Mask
myConfig =
def
{ terminal = "alacritty",
-- Use Win key instead of Alt
modMask = mod4Mask,
modMask = myModMask,
workspaces = withScreen 1 myWorkspaces ++ withScreen 2 mySharedWorkspaces,
-- Styling
focusedBorderColor = "#000",
@ -158,7 +163,7 @@ myConfig =
startupHook = myStartupHook,
manageHook = myManageHook <+> manageHook def,
layoutHook = avoidStruts myLayoutHook,
handleEventHook = dynamicPropertyChange "WM_NAME" myDynamicManageHook <> handleEventHook def <> Hacks.windowedFullscreenFixEventHook
handleEventHook = myHandleEventHook
}
`removeKeysP` myRemoveKeys
`additionalKeysP` myKeys
@ -196,7 +201,10 @@ myKeys =
("M-S-<XF86MonBrightnessDown>", resetTemp), --
("M-S-b", fullscreenBrowser),
("<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, f) <- zip ["M-", "M-S-"]
@ -205,9 +213,6 @@ myKeys =
(withScreen 1 myWorkspaces)
++ zip mySharedWorkspaceKeys
(withScreen 2 mySharedWorkspaces)
("M-c", windows copyToAll),
("M-S-c", killAllOtherCopies),
("M-S-<Delete>", kill)
]
zipKeyPrefixes :: [String] -> [String] -> [String]
@ -242,8 +247,9 @@ spawnKeepassXC = spawn "keepassxc"
fullscreenBrowser :: X ()
fullscreenBrowser = spawn "firefox --fullscreen"
spawnLauncher :: X ()
spawnLauncher = spawn "albert toggle"
spawnLauncher, spawnClipManager, spawnCalculator :: X ()
spawnLauncher = spawn "rofi -show drun -show-icons"
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"
printScreen :: X ()