Fix notify send in ide

main
Julius Riegel 7 months ago
parent 4f0f35484d
commit f332be7c36

@ -85,6 +85,7 @@ if $env.NIX_PATH? != null {
$env.NIX_PATH = $"{{dirs.home}}/.nix-defexpr/channels:($env.NIX_PATH)" $env.NIX_PATH = $"{{dirs.home}}/.nix-defexpr/channels:($env.NIX_PATH)"
} }
{{/if-installed}} {{/if-installed}}
{{#if-installed zoxide}} {{#if-installed zoxide}}
zoxide init nushell | save -f ~/.zoxide.nu zoxide init nushell | save -f ~/.zoxide.nu
{{/if-installed}} {{/if-installed}}

@ -1,8 +1,5 @@
$env.PATH = ( $env.PATH $env.PATH = ( $env.PATH
| prepend $'{{dirs.home}}/.local/bin' | prepend $'{{dirs.home}}/.local/bin'
{{#if-installed cargo}}
| prepend $'{{dirs.home}}/.cargo/bin'
{{/if-installed}}
{{#if-installed nenv}} {{#if-installed nenv}}
| prepend $'{{dirs.home}}/.local/share/nenv/bin' | prepend $'{{dirs.home}}/.local/share/nenv/bin'
{{/if-installed}} {{/if-installed}}
@ -12,4 +9,7 @@ $env.PATH = ( $env.PATH
{{#if-installed nix}} {{#if-installed nix}}
| prepend $'{{dirs.home}}/.nix-profile/bin' | prepend $'{{dirs.home}}/.nix-profile/bin'
{{/if-installed}} {{/if-installed}}
{{#if-installed cargo}}
| prepend $'{{dirs.home}}/.cargo/bin'
{{/if-installed}}
) )

@ -2,6 +2,7 @@
use task.nu use task.nu
use dirs.nu use dirs.nu
use render.nu use render.nu
use ci.nu
const ZELLIJ_LAYOUT = ($dirs.CONFIG | path join zellij/development.toml) const ZELLIJ_LAYOUT = ($dirs.CONFIG | path join zellij/development.toml)
@ -11,8 +12,10 @@ export def --env main [] {
wezterm cli set-tab-title $"IDE (basename)" wezterm cli set-tab-title $"IDE (basename)"
} }
let tmpdir = init let tmpdir = init
ci watch-bg
zellij --layout $ZELLIJ_LAYOUT --session (session-name) zellij --layout $ZELLIJ_LAYOUT --session (session-name)
rm -r $tmpdir rm -r $tmpdir
if $env.WEZTERM_PANE? != null { if $env.WEZTERM_PANE? != null {
wezterm cli set-tab-title "" wezterm cli set-tab-title ""
} }
@ -44,11 +47,12 @@ export def floating-prompt [] {
} }
export def last-notification [] { export def last-notification [] {
let notif = open $env.NOTIFY_FILE | str trim let notif = open $env.NOTIFY_FILE
if ($notif | str length) == 0 { if $notif == null {
return return
} }
let notif = $"(ansi {attr: bi})($notif.title)(ansi reset) ($notif.content)"
$env.NTFY_CHKSUM = (shasum $env.NOTIFY_FILE) $env.NTFY_CHKSUM = (shasum $env.NOTIFY_FILE)
@ -57,12 +61,13 @@ export def last-notification [] {
if not (task group exists $group_name) { if not (task group exists $group_name) {
task group add $group_name -p 4 task group add $group_name -p 4
} }
task spawn -d 10sec -g $group_name { ( task spawn -d 10sec -g $group_name {
if (shasum $env.NOTIFY_FILE) == $env.NTFY_CHKSUM { if (shasum $env.NOTIFY_FILE) == $env.NTFY_CHKSUM {
"" | save -f $env.NOTIFY_FILE "null" | save -f $env.NOTIFY_FILE
} }
} } | ignore )
$notif
return $notif
} }
export def `doc-comment java-style` [] { export def `doc-comment java-style` [] {
@ -125,13 +130,13 @@ def create-xdg-open [tmpbin: string] {
} }
def --env create-notify-send [tmpdir: string, tmpbin: string] { def --env create-notify-send [tmpdir: string, tmpbin: string] {
$env.NOTIFY_FILE = ($tmpdir | path join "notifications.txt") $env.NOTIFY_FILE = ($tmpdir | path join "notifications.json")
touch $env.NOTIFY_FILE touch $env.NOTIFY_FILE
let new_ntfy = ($tmpbin | path join "notify-send") let new_ntfy = ($tmpbin | path join "notify-send")
("#!/bin/env nu ("#!/bin/env nu
def main [title: string, content: string] { def main [title: string, content: string] {
$\"(ansi {attr: bi})($title)(ansi reset) ($content)\\n\" | save -f $env.NOTIFY_FILE {title: $title, content: $content} | to json | save -f $env.NOTIFY_FILE
} }
" | save -f $new_ntfy) " | save -f $new_ntfy)
chmod +x $new_ntfy chmod +x $new_ntfy

@ -56,7 +56,7 @@ export def spawn [
) )
| save --force $source_path | save --force $source_path
(pueue add --print-task-id ...$args $"nu --config '($nu.config-path)' --env-config '($nu.env-path)' ($source_path)") (pueue add --print-task-id ...$args $"nu --config '($nu.config-path)' --env-config '($nu.env-path)' ($source_path)" | complete | get stdout)
} }
# Remove tasks from the queue. # Remove tasks from the queue.

@ -1,6 +1,6 @@
$env.STARSHIP_SHELL = "nu" $env.STARSHIP_SHELL = "nu"
$env.STARSHIP_SESSION_KEY = (random chars -l 16) $env.STARSHIP_SESSION_KEY = (random chars -l 16)
$env.PROMPT_MULTILINE_INDICATOR = (^/usr/bin/starship prompt --continuation) $env.PROMPT_MULTILINE_INDICATOR = (^starship prompt --continuation)
# Does not play well with default character module. # Does not play well with default character module.
# TODO: Also Use starship vi mode indicators? # TODO: Also Use starship vi mode indicators?
@ -9,7 +9,7 @@ $env.PROMPT_INDICATOR = ""
$env.PROMPT_COMMAND = {|| $env.PROMPT_COMMAND = {||
# jobs are not supported # jobs are not supported
let width = (term size | get columns | into string) let width = (term size | get columns | into string)
^/usr/bin/starship prompt $"--cmd-duration=($env.CMD_DURATION_MS)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)" ^starship prompt $"--cmd-duration=($env.CMD_DURATION_MS)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)"
} }
# Not well-suited for `starship prompt --right`. # Not well-suited for `starship prompt --right`.

@ -10,7 +10,7 @@ layout {
format_left "{command_lpl}{tabs}" format_left "{command_lpl}{tabs}"
format_right "{command_rpl}" format_right "{command_rpl}"
format_center "{command_notify}" format_center "{command_notify}"
format_space "#[bg=#181825]" format_space ""
hide_frame_for_single_pane "true" hide_frame_for_single_pane "true"
@ -21,17 +21,17 @@ layout {
tab_active_fullscreen "#[fg=#9399B2,bg=#181825,bold,italic] {index} {name} [] " tab_active_fullscreen "#[fg=#9399B2,bg=#181825,bold,italic] {index} {name} [] "
tab_active_sync "#[fg=#9399B2,bg=#181825,bold,italic] {index} {name} <> " tab_active_sync "#[fg=#9399B2,bg=#181825,bold,italic] {index} {name} <> "
command_notify_command "nu -c \"use ide.nu; ide last-notification\"" command_notify_command "nu --no-newline -c \"use ide.nu; ide last-notification\""
command_notify_format "{stdout}" command_notify_format "{stdout}"
command_notify_interval "1" command_notify_interval "1"
command_notify_rendermode "raw" command_notify_rendermode "raw"
command_lpl_command "nu -c \"use ide.nu; ide zjstatus powerline_left\"" command_lpl_command "nu --no-newline -c \"use ide.nu; ide zjstatus powerline_left\""
command_lpl_format "{stdout}" command_lpl_format "{stdout}"
command_lpl_interval "1" command_lpl_interval "1"
command_lpl_rendermode "raw" command_lpl_rendermode "raw"
command_rpl_command "nu -c \"use ide.nu; ide zjstatus powerline_right\"" command_rpl_command "nu --no-newline -c \"use ide.nu; ide zjstatus powerline_right\""
command_rpl_format "{stdout}" command_rpl_format "{stdout}"
command_rpl_interval "2" command_rpl_interval "2"
command_rpl_rendermode "raw" command_rpl_rendermode "raw"

@ -1,32 +1,36 @@
# if running bash # if running bash
if [ -n "$BASH_VERSION" ]; then if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists # include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc" . "$HOME/.bashrc"
fi fi
fi fi
# set PATH so it includes user's private bin if it exists # set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then if [ -d "$HOME/bin" ]; then
PATH="$HOME/bin:$PATH" PATH="$HOME/bin:$PATH"
fi fi
# set PATH so it includes user's private bin if it exists # set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then if [ -d "$HOME/.local/bin" ]; then
PATH="$HOME/.local/bin:$PATH" PATH="$HOME/.local/bin:$PATH"
fi fi
if [ -d "$HOME/.cargo/env" ]; then if [ -d "$HOME/.cargo/env" ]; then
. "$HOME/.cargo/env" . "$HOME/.cargo/env"
fi fi
# Nix # Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi fi
if [ -e '$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh' ]; then if [ -e '$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh' ]; then
. '$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh' . '$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh'
fi
# set PATH so it prioritizes ./cargo/bin over everything
if [ -d "$HOME/.local/bin" ]; then
PATH="$HOME/.cargo/bin:$PATH"
fi fi
export XDG_DATA_DIRS=$HOME/.nix-profile/share:$HOME/.share:"${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}" export XDG_DATA_DIRS=$HOME/.nix-profile/share:$HOME/.share:"${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}"

@ -60,6 +60,7 @@ config.modules = {
'meld', 'meld',
'pueue', 'pueue',
'parallel', 'parallel',
'bat',
}, },
gui = mod { gui = mod {
'kdePackages.breeze-icons', 'kdePackages.breeze-icons',

Loading…
Cancel
Save