services: Add autostarting dropdown-terminal

This commit is contained in:
Marty Oehme 2020-07-29 09:21:46 +02:00
parent 440629f3c3
commit 1c45202f18
No known key found for this signature in database
GPG key ID: 0CCB0526EFB9611A
4 changed files with 46 additions and 9 deletions

View file

@ -90,8 +90,8 @@ bindsym $mod+ctrl+v sticky toggle
# set up scratch pad for todo and 'drop-down' terminal
# call scratchpads to current workspace -- scratchpads started on i3 starting (see end of file)
bindsym $mod+t [class="Alacritty" instance="scratchpad" title="todo.md"] scratchpad show
bindsym $mod+Shift+Return [class="Alacritty" instance="scratchpad" title="dropdown"] scratchpad show
bindsym $mod+t [class="scratchpad" title="dropdown-todo"] scratchpad show
bindsym $mod+Shift+Return [class="scratchpad" title="dropdown-terminal"] scratchpad show
# GAP MANAGEMENT
# disable titles and borders, necessary for i3gaps to work apparently
@ -196,10 +196,13 @@ for_window [class="^spotify$"] move to workspace 10
# set up scratch pad for todo and 'drop-down' terminal
# to be called to current workspace when needed
exec --no-startup-id alacritty --title "todo.md" --class "scratchpad,Alacritty" -e nvim -c ":set nonumber norelativenumber noshowmode noruler laststatus=0 noshowcmd shortmess=F" ~/todo.md
exec --no-startup-id alacritty --title "dropdown" --class scratchpad,Alacritty
for_window [class="Alacritty" instance="scratchpad"] floating enable
for_window [class="Alacritty" instance="scratchpad"] move scratchpad
exec --no-startup-id alacritty --title "dropdown-todo" --class "Alacritty,scratchpad" -e nvim -c ":set nonumber norelativenumber noshowmode noruler laststatus=0 noshowcmd shortmess=F" ~/documents/records/todo.md
# windows with class floating will automatically float
# windows with class scratchpad will automatically float and be sent to the scratchpad
for_window [class="floating"] floating enable
for_window [class="scratchpad"] floating enable
for_window [class="scratchpad"] move scratchpad
# autostart often used apps
# needs to be done like this to both automatically start the apps on correct workspace

View file

@ -0,0 +1 @@
../dropdown-terminal.service

View file

@ -0,0 +1,11 @@
[Unit]
Description=Alacritty window hidden on i3 scratchpad
[Service]
Type=simple
# workaround to allow relative executable invocation (i.e. current users' home dir)
ExecStart=/bin/bash -c 'alacritty --title "dropdown-terminal" --class Alacritty,scratchpad'
Restart=always
[Install]
WantedBy=default.target

View file

@ -3,8 +3,13 @@
This module uses `systemd` to provide various services for the user running the dotfiles.
The services will get moved into the correct `.config` directory for `systemd` to pick them up as user services.
They will, for now, *not* be automatically enabled when installing the dotfiles. This is pending changes.
They can be enabled as needed by invoking `systemctl --user enable [service]`. Be aware that
They are, for now, *automatically* enabled when installing the dotfiles. This is pending changes.
They can be enabled or disabled as needed by invoking `systemctl --user enable|disable [service]`.
Be aware that, for the services to work correctly out of the box all the following applications have to exist on the system:
`an2linuxserver`, `dunst`, `greenclip`, `keybase`, `redshift`.
If they are not found, their service will fail silently (well, with a systemd error log, but who checks *those* first thing...)
Lastly, the directory `~/documents/notes/uni` will begin to be synced with `git`, so will need a) `git` installed, b) the directory to exist as a `git` directory, c) to be disabled if you do not want this directory to be continually synced.
## Why systemd
@ -25,9 +30,18 @@ So what that essentially means: this service module uses `systemd` *for now*.
It might change to something else in the future.
It might also not be written very well, since I am using it to adopt a mental mapping of `systemd` at the same time.
## Drop-in Changes to services
There are, for now, small changes to the services that get installed by default with their arch packages: `greenclip` and `redshift`.
Both need a running X server for their program to start successfully, and both are repeatedly run way too fast by systemd by default and would crash.
I have not yet created a new target solely for X having started
(and by default you can not access system-wide systemd targets from a user-wide service),
so in the meantime these changes simply make the programs wait longer before trying to restart.
This generally gives ample time for the services to start correctly by themselves.
## Commit Notes service
This service keeps my university note directory in sync with a remote origin.
This service `uni_notes_sync.service` keeps my university note directory in sync with a remote origin.
The script behind it (`git-sync`) can be used more generally to keep any git directory in sync.
The idea behind the services is: commit asap, push when finished.
@ -38,3 +52,11 @@ In effect this means, using the default values, the service will commit any chan
The two cycles can be changed independently from each other via the environment variables mentioned above so that, for example, the repository can be pushed every single time a commit takes place, or commits can be checked for on faster or shorter intervals.
As another example, if you want to check for changes every 30 seconds but still push every hour, you would do `GS_TIME_TO_COMMIT=30` and `GS_UNCHANGED_RUNS_TO_PUSH=120`.
## Dropdown Terminal service
The `dropdown-terminal.service` is very simple, and always keeps a (`alacritty`) terminal window running.
The program is started with a `scratchpad` class, which is picked up by [`i3`](i3) and automatically hidden.
You can then show/hide the terminal as a floating overlay as you need, mimicking a floating terminal
(by default with `super + shift + return`, though this may change).
When you close the window in any way, systemd automatically restarts it in the background.