Compare commits

...

5 commits

18 changed files with 267 additions and 455 deletions

View file

@ -1,2 +0,0 @@
theme.yml
alacritty.yml

View file

@ -1,7 +1,10 @@
---
- name: I3-reload
ansible.builtin.command: i3-msg reload
listen: i3-reload
- name: Shell-reload
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/colorSchemeApply"
listen: shell-reload
- name: Fzf-reload
ansible.builtin.command: source {{ ansible_env.HOME }}/.local/bin/colorSchemeApplyFzf
ansible.builtin.shell: source {{ ansible_env.HOME }}/.local/bin/colorSchemeApplyFzf
listen: fzf-reload

View file

@ -1,7 +0,0 @@
#!/usr/bin/env bash
while true
do
ashuffle
sleep 1
done

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
shopt -s nullglob globstar
profile=$(echo -e "$(autorandr 2>&1 | cut -d' ' -f1)" | rofi -dmenu -p "Default profile" "$@")
[[ -n $profile ]] || exit
autorandr --default "$profile"

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
shopt -s nullglob globstar
profile=$(echo -e "common\nclone-largest\nhorizontal\nvertical\n$(autorandr 2>&1 | cut -d' ' -f1)" | rofi -dmenu -p "Load profile" "$@")
[[ -n $profile ]] || exit
autorandr --load "$profile"

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
shopt -s nullglob globstar
profile=$(echo -e "$(autorandr 2>&1 | cut -d' ' -f1)" | rofi -dmenu -p "Remove profile" "$@")
[[ -n $profile ]] || exit
autorandr --remove "$profile"

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
shopt -s nullglob globstar
profile=$(echo -e "$(autorandr 2>&1 | cut -d' ' -f1)" | rofi -dmenu -p "Save profile" "$@")
[[ -n $profile ]] || exit
autorandr --save "$profile"

View file

@ -1,16 +0,0 @@
#!/bin/bash
# TODO Make a good service out of this
cd /opt/activitywatch # Put your ActivityWatch install folder here
killall aw-server
killall aw-watcher-afk
killall aw-watcher-window
./aw-server/aw-server &
./aw-watcher-afk/aw-watcher-afk &
./aw-watcher-window/aw-watcher-window & # you can add --exclude-title here to exclude window title tracking for this session only
notify-send "ActivityWatch started" # Optional, sends a notification when ActivityWatch is started

View file

@ -62,105 +62,23 @@ for_window [ title="^pdfpc.*" window_role="presentation" ] move to output right,
# switch to workspace with urgent window automatically
for_window [urgent=latest] focus
# Set shut down, restart and locking features
set $mode_kblock Keyboard lock
mode "$mode_kblock" {
bindsym $mod+Shift+Escape mode "$mode_kblock"
}
"$mod+Shift+Escape" = "mode "$mode_kblock"";
# Set shut down, restart and locking features
set $locker $HOME/.config/i3/lock
set $mode_system [L] Vérouillage [E] Déconnexion [S] Veille [H] Hibernation [R] Redémarrage [P] Extinction
mode "$mode_system" {
bindsym l exec --no-startup-id $locker, mode "default"
bindsym e exit, mode "default"
bindsym s exec --no-startup-id $locker & systemctl suspend, mode "default"
bindsym h exec --no-startup-id $locker & systemctl hibernate, mode "default"
bindsym r exec --no-startup-id systemctl reboot, mode "default"
bindsym p exec --no-startup-id systemctl poweroff -i, mode "default"
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
"$mod+Escape" = "mode "$mode_system"";
# 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 windows width.
# Pressing right will grow the windows width.
# Pressing up will shrink the windows height.
# Pressing down will grow the windows height.
bindsym h resize shrink width 10 px or 10 ppt; exec ~/.config/i3/focus_windows
bindsym j resize grow height 10 px or 10 ppt; exec ~/.config/i3/focus_windows
bindsym k resize shrink height 10 px or 10 ppt; exec ~/.config/i3/focus_windows
bindsym l resize grow width 10 px or 10 ppt; exec ~/.config/i3/focus_windows
## same bindings, but for the arrow keys
#bindsym Left resize shrink width 10 px or 10 ppt
#bindsym Down resize grow height 10 px or 10 ppt
#bindsym Up 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"
}
"$mod+r" = "mode "Resize"";
set $mode_pres_main "Presentation (main display)"
mode $mode_pres_main {
bindsym b workspace $WS3, workspace $WS4, mode $mode_pres_sec
# back to normal: Enter or Escape
bindsym q mode "default"
# bindsym Escape mode "default"
bindsym Return mode "default"
}
set $mode_pres_sec "Presentation (secondary display)"
mode $mode_pres_sec {
bindsym b workspace $WS2, workspace $WS1, mode $mode_pres_main
# back to normal: Enter or Escape
bindsym q mode "default"
# bindsym Escape mode "default"
bindsym Return mode "default"
}
"$mod+Shift+p" = "mode $mode_pres_main";
set $mode_screen Screen setup [A] Auto [L] Load [S] Save [R] Remove [D] Default
"$mod+t" = "mode "$mode_screen"";
mode "$mode_screen" {
bindsym a exec autorandr --change --force, mode "default"
bindsym l exec ~/.config/i3/autorandrloadmenu, mode "default"
bindsym s exec ~/.config/i3/autorandrsavemenu, mode "default"
bindsym r exec ~/.config/i3/autorandrremovemenu, mode "default"
bindsym d exec ~/.config/i3/autorandrdefaultmenu, mode "default"
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
# Screen temperature ("redness") setting
"$mod+y" = "mode "$mode_temp"";
set $mode_temp Temperature [R] Red [D] Dust storm [C] Campfire [O] Normal [A] All nighter [B] Blue
mode "$mode_temp" {
bindsym r exec sct 1000
bindsym d exec sct 2000
bindsym c exec sct 4500
bindsym o exec sct
bindsym a exec sct 8000
bindsym b exec sct 10000
"r" = "exec sct 1000";
"d" = "exec sct 2000";
"c" = "exec sct 4500";
"o" = "exec sct";
"a" = "exec sct 8000";
"b" = "exec sct 10000";
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
"Return" = "mode "default"";
"Escape" = "mode "default"";
}
@ -182,10 +100,8 @@ exec --no-startup-id unclutter -root # Hide mouse cursor after some time
#exec --no-startup-id dunst # Notifications (handled by systemd)
exec --no-startup-id keynav # Keyboard cursor controller
#exec --no-startup-id mpd # Music Player Daemon (handled by systemd)
# exec --no-startup-id ~/.config/i3/ashuffle # MPD Auto-refill
exec --no-startup-id autorandr --change --force # Screen configuration and everything that depends on it
{% if has_battery %}
exec --no-startup-id ~/.config/i3/batteryNotify -d # Battery state notification
{% endif %}
# exec --no-startup-id ~/.config/i3/aw_start # Activity tracker

View file

@ -1,2 +0,0 @@
#!/bin/sh
dmenu -fn 'DejaVu Sans Mono-10' -nb '#48483e' -nf '#f1ebeb' -sb '#8fc029' -sf '#272822' -i -l 8 -f "$@"

View file

@ -1,15 +0,0 @@
#!/bin/sh
cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
if [ -d "$cachedir" ]; then
cache=$cachedir/dmenu_run
else
cache=$HOME/.dmenu_cache # if no xdg dir, fall back to dotfile in ~
fi
(
IFS=:
if stest -dqr -n "$cache" $PATH; then
stest -flx $PATH | sort -u | tee "$cache" | $HOME/.config/i3/dmenu_cmd -p 'Run' "$@"
else
$HOME/.config/i3/dmenu_cmd -p 'Run' "$@" < "$cache"
fi
) | ${SHELL:-"/bin/sh"} &

View file

@ -1,24 +0,0 @@
#!/usr/bin/env bash
# Remove SSH and GPG keys from keystores
ssh-add -D
echo RELOADAGENT | gpg-connect-agent
rm -rf "/tmp/cached_pass_$UID"
dm-tool lock
if [ $? -ne 0 ]; then
if [ -d ~/.cache/lockpatterns ]
then
pattern=$(find ~/.cache/lockpatterns/ | sort -R | head -1)
else
pattern=$HOME/.config/i3/lock.png
fi
revert() {
xset dpms 0 0 0
}
trap revert SIGHUP SIGINT SIGTERM
xset dpms 5 5 5
i3lock --nofork --color 648901 --image=$pattern --tiling --ignore-empty-password
revert
fi

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 B

View file

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" height="50" width="50"><path fill="#82a401" d="M0 50h50V0H0z"/><path d="M0 0l50 50H25L0 25zm50 0v25L25 0z" fill="#466c01"/></svg>

Before

Width:  |  Height:  |  Size: 189 B

View file

@ -1,26 +0,0 @@
#!/usr/bin/env bash
# Send a key event to the current multimedia application or to MPD
# Currently since I did not found a way to test if a keystroke
# is grabbed by a windows or not, we test if MPD is playing
echo 8 "$1" "$2" "$(xdotool getactivewindow)" >> /tmp/dbg
if [ $# != 2 ]; then
echo "Usage: $0 KEY MPC_COMMAND"
exit 1
fi
if [ $(mpc status | wc -l) -ne 1 ]; then
# If mpd is running
mpc $2
else
# If mpd is not running
# echo "$1" "$2" "$(xdotool getactivewindow)" >> /tmp/dbg
xdotool key --window $(xdotool getactivewindow) $1
echo xdotool key --window $(xdotool getactivewindow) $1 >> /tmp/dbg
fi
exit 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 B

View file

@ -1,67 +0,0 @@
#!/usr/bin/env python3
"""
Logs what window is in focus
"""
import csv
import datetime
import os
import typing
import i3ipc
class ScreenTime:
FIELDS = ["date", "type", "class", "role", "instance", "title"]
def write(self, line: typing.Dict) -> None:
now = datetime.datetime.now()
line["date"] = now.timestamp()
print("WROTE", line)
with open(self.csv_path, "a") as typedfd:
writer = csv.DictWriter(typedfd, fieldnames=self.FIELDS)
writer.writerow(line)
def on_window_event(
self, _: i3ipc.connection.Connection, e: i3ipc.events.WindowEvent
) -> None:
focused = self.i3.get_tree().find_focused()
self.write(
{
"type": "window_" + e.change,
"class": focused.window_class,
"role": focused.window_role,
"title": focused.window_title,
"instance": focused.window_instance,
}
)
def on_mode_event(
self, _: i3ipc.connection.Connection, e: i3ipc.events.ModeEvent
) -> None:
self.write({"type": "mode", "title": e.change})
def __init__(self) -> None:
self.i3 = i3ipc.Connection()
self.i3.on(i3ipc.Event.WINDOW, self.on_window_event)
self.i3.on(i3ipc.Event.MODE, self.on_mode_event)
self.csv_path = os.path.join(
os.path.expanduser(os.getenv("XDG_CACHE_PATH", "~/.cache/")),
"screentime.csv",
)
if not os.path.isfile(self.csv_path):
with open(self.csv_path, "w") as typedfd:
writer = csv.DictWriter(typedfd, fieldnames=self.FIELDS)
writer.writeheader()
self.write({"type": "start"})
def main(self) -> None:
self.i3.main()
if __name__ == "__main__":
ST = ScreenTime()
ST.main()

View file

@ -2,7 +2,55 @@
{
xsession.windowManager.i3 = {
enable = true;
config = {
config =
let
# lockColors = with config.lib.stylix.colors.withHashtag; { a = base00; b = base01; d = base00; }; # Black or White, depending on current theme
# lockColors = with config.lib.stylix.colors.withHashtag; { a = base0A; b = base0B; d = base00; }; # Green + Yellow
lockColors = { a = "#82a401"; b = "#466c01"; d = "#648901"; }; # Old
lockSvg = pkgs.writeText "lock.svg" "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 50 50\" height=\"50\" width=\"50\"><path fill=\"${lockColors.a}\" d=\"M0 50h50V0H0z\"/><path d=\"M0 0l50 50H25L0 25zm50 0v25L25 0z\" fill=\"${lockColors.d}\"/></svg>";
lockPng = pkgs.runCommand "lock.png" { } "${pkgs.imagemagick}/bin/convert ${lockSvg} $out";
locker = "exec ${ pkgs.writeShellScript "i3-locker"
''
# Remove SSH and GPG keys from keystores
${pkgs.openssh}/bin/ssh-add -D
echo RELOADAGENT | ${pkgs.gnupg}/bin/gpg-connect-agent
${pkgs.coreutils}/bin/rm -rf "/tmp/cached_pass_$UID"
${pkgs.lightdm}/bin/dm-tool lock
# TODO Does that work for all DMs?
if [ $? -ne 0 ]; then
if [ -d ${config.xdg.cacheHome}/lockpatterns ]
then
pattern=$(${pkgs.findutils} ${config.xdg.cacheHome}/lockpatterns | sort -R | head -1)
else
pattern=${lockPng}
fi
revert() {
${pkgs.xorg.xset} dpms 0 0 0
}
trap revert SIGHUP SIGINT SIGTERM
${pkgs.xorg.xset} dpms 5 5 5
${pkgs.i3lock}/bin/i3lock --nofork --color ${builtins.substring 1 6 lockColors.d} --image=$pattern --tiling --ignore-empty-password
revert
fi
''
}";
focus = "exec ${ pkgs.writeShellScript "i3-focus-window"
''
WINDOW=`${pkgs.xdotool}/bin/xdotool getwindowfocus`
eval `${pkgs.xdotool}/bin/xdotool getwindowgeometry --shell $WINDOW` # this brings in variables WIDTH and HEIGHT
TX=`${pkgs.coreutils}/bin/expr $WIDTH / 2`
TY=`${pkgs.coreutils}/bin/expr $HEIGHT / 2`
${pkgs.xdotool}/bin/xdotool mousemove -window $WINDOW $TX $TY
''
}";
mode_system = "[L] Vérouillage [E] Déconnexion [S] Veille [H] Hibernation [R] Redémarrage [P] Extinction";
mode_resize = "Resize";
mode_pres_main = "Presentation (main display)";
mode_pres_sec = "Presentation (secondary display)";
mode_screen = "Screen setup [A] Auto [L] Load [S] Save [R] Remove [D] Default";
in
{
terminal = "alacritty";
# bars = []; # FIXME lemonbar
colors = let ignore = "#ff00ff"; in
@ -20,15 +68,6 @@
let
mod = config.xsession.windowManager.i3.config.modifier;
rofi = "exec --no-startup-id ${config.programs.rofi.package}/bin/rofi";
focus = "exec ${ pkgs.writeShellScript "i3-focus-window"
''
WINDOW=`${pkgs.xdotool}/bin/xdotool getwindowfocus`
eval `${pkgs.xdotool}/bin/xdotool getwindowgeometry --shell $WINDOW` # this brings in variables WIDTH and HEIGHT
TX=`${pkgs.coreutils}/bin/expr $WIDTH / 2`
TY=`${pkgs.coreutils}/bin/expr $HEIGHT / 2`
${pkgs.xdotool}/bin/xdotool mousemove -window $WINDOW $TX $TY
''
}";
pactl = "exec ${pkgs.pulseaudio}/bin/pactl"; # TODO Use NixOS package if using NixOS
scrot = "${pkgs.scrot}/bin/scrot --exec '${pkgs.coreutils}/bin/mv $f ~/Screenshots/ && ${pkgs.optipng}/bin/optipng ~/Screenshots/$f'";
# TODO nix path and create directory?
@ -56,7 +95,8 @@
# Start Applications
"${mod}+Return" = "exec ${
pkgs.writeShellScript "terminal" "${config.programs.alacritty.package}/bin/alacritty msg create-window || exec ${config.programs.alacritty.package}/bin/alacritty -e zsh"
# TODO Is -e zsh required?
# -e zsh is for systems where I can't configure my user's shell
# TODO Is a shell script even required?
}";
"${mod}+Shift+Return" = "exec ${config.programs.urxvt.package}/bin/urxvt";
"${mod}+p" = "exec ${pkgs.xfce.thunar}/bin/tunar";
@ -85,6 +125,7 @@
"Print" = "exec ${scrot} --focused";
"${mod}+Print" = "exec ${scrot}"; # FIXME Doesn't work at least in the VM
"Ctrl+Print" = "exec ${pkgs.coreutils}/bin/sleep 1 && ${scrot} --select";
# TODO Try using bindsym --release instead of sleep
# change focus
"${mod}+h" = "focus left; ${focus}";
"${mod}+j" = "focus down; ${focus}";
@ -162,6 +203,60 @@
"${mod}+Shift+c" = "reload";
"${mod}+Shift+r" = "restart";
"${mod}+Shift+e" = "exit";
# Modes
"${mod}+Escape" = "mode ${mode_system}";
"${mod}+r" = "mode ${mode_resize}";
"${mod}+Shift+p" = "mode ${mode_pres_main}";
"${mod}+t" = "mode ${mode_screen}";
};
modes = let return_bindings = {
"Return" = "mode default";
"Escape" = "mode default";
}; in
{
"${mode_system}" = {
"l" = "exec --no-startup-id ${locker}, mode default";
"e" = "exit, mode default";
"s" = "exec --no-startup-id ${locker} & ${pkgs.systemd}/bin/systemctl suspend, mode default";
"h" = "exec --no-startup-id ${locker} & ${pkgs.systemd}/bin/systemctl hibernate, mode default";
"r" = "exec --no-startup-id ${pkgs.systemd}/bin/systemctl reboot, mode default";
"p" = "exec --no-startup-id ${pkgs.systemd}/bin/systemctl poweroff -i, mode default";
} // return_bindings;
"${mode_resize}" = {
"h" = "resize shrink width 10 px or 10 ppt; ${focus}";
"j" = "resize grow height 10 px or 10 ppt; ${focus}";
"k" = "resize shrink height 10 px or 10 ppt; ${focus}";
"l" = "resize grow width 10 px or 10 ppt; ${focus}";
} // return_bindings;
"${mode_pres_main}" = {
"b" = "workspace 3, workspace 4, mode ${mode_pres_sec}";
"q" = "mode default";
"Return" = "mode default";
};
"${mode_pres_sec}" = {
"b" = "workspace 1, workspace 2, mode ${mode_pres_main}";
"q" = "mode default";
"Return" = "mode default";
};
"${mode_screen}" =
let
builtin_configs = [ "off" "common" "clone-largest" "horizontal" "vertical" "horizontal-reverse" "vertical-reverse" ];
autorandrmenu = { title, option, builtin ? false }: pkgs.writeShellScript "autorandrmenu"
''
shopt -s nullglob globstar
profiles="${if builtin then lib.strings.concatLines builtin_configs else ""}$(${pkgs.autorandr}/bin/autorandr | ${pkgs.gawk}/bin/awk '{ print $1 }')"
profile="$(echo "$profiles" | ${config.programs.rofi.package}/bin/rofi -dmenu -p "${title}")"
[[ -n "$profile" ]] || exit
${pkgs.autorandr}/bin/autorandr ${option} "$profile"
'';
in
{
"a" = "exec ${pkgs.autorandr}/bin/autorandr --change --force, mode default";
"l" = "exec ${autorandrmenu {title="Load profile"; option="--load"; builtin = true;}}, mode default";
"s" = "exec ${autorandrmenu {title="Save profile"; option="--save";}}, mode default";
"r" = "exec ${autorandrmenu {title="Remove profile"; option="--remove";}}, mode default";
"d" = "exec ${autorandrmenu {title="Default profile"; option="--default"; builtin = true;}}, mode default";
} // return_bindings;
};
};
};
@ -257,7 +352,6 @@
# x11-exclusive
dunst
i3lock
numlockx
# TODO urxvt-resize-font-git
simplescreenrecorder
@ -266,7 +360,6 @@
xautolock
xclip
lemonbar-xft
autorandr
keynav
sct
xorg.xinit