From 7cf5bf0aed2dea19249f0a8095f3cb4fbf5d5ad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Dudr?= Date: Thu, 2 Jan 2025 09:01:56 +0100 Subject: [PATCH] hlwm: oncall menu --- bin/executable_oncall-menu | 28 +++++++++++++++++++ .../herbstluftwm/executable_autostart.tmpl | 1 + .../herbstluftwm/executable_panel-handler | 9 ++++-- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 bin/executable_oncall-menu diff --git a/bin/executable_oncall-menu b/bin/executable_oncall-menu new file mode 100644 index 0000000..e5cb73f --- /dev/null +++ b/bin/executable_oncall-menu @@ -0,0 +1,28 @@ +#!/bin/zsh +# set -x + +auth="$(gopass metrans/oncall-apikey)" +if test -z $ROFI_RETV +then + rofi -show oncall -modi "oncall:$0" \ + -kb-accept-custom "" \ + -kb-accept-alt "" \ + -kb-custom-1 "Shift+Return" \ + # -sidebar-mode \ + -kb-custom-2 "Control+Return" + +fi + +case "$ROFI_RETV" in + 0) echo -e "\0use-hot-keys\x1ftrue\n" + echo -e "\0message\x1fConfirm to open, Shift-Enter to ack, Ctrl-Enter to resolve\n" + curl -s --header "Authorization: $auth" 'https://oncall.corp.metrans.cz/api/v1/alert_groups?state=new' | jq -r '.results[] | .title+"\u0000info\u001f"+.permalinks.web+"|"+.id' + ;; + 1) ( handlr open "${ROFI_INFO/|*}" ) & ;; + 10) ( + curl -s --request POST --header "Authorization: $auth" "https://oncall.corp.metrans.cz/api/v1/alert_groups/${ROFI_INFO/*|}/acknowledge" + ) & ;; + 11) ( + curl -s --request POST --header "Authorization: $auth" "https://oncall.corp.metrans.cz/api/v1/alert_groups/${ROFI_INFO/*|}/resolve" + ) & ;; +esac diff --git a/dot_config/herbstluftwm/executable_autostart.tmpl b/dot_config/herbstluftwm/executable_autostart.tmpl index 426bb91..e0ac777 100644 --- a/dot_config/herbstluftwm/executable_autostart.tmpl +++ b/dot_config/herbstluftwm/executable_autostart.tmpl @@ -34,6 +34,7 @@ hc keybind $Mod-Shift-x spawn systemd-run --scope --user rofi -show fb -modi "fb hc keybind $Mod-z spawn systemd-run --scope --user rofi -modi "clipboard:greenclip print" -show clipboard -run-command '{cmd}' hc keybind $Mod-c spawn systemd-run --scope --user rofi -lines 0 -show calc -modi calc -no-show-match -no-sort -no-history -calc-command "echo -n '{result}' | xclip" hc keybind $Mod-a spawn systemd-run --scope --user ~/bin/gopassmenu +hc keybind $Mod-v spawn systemd-run --scope --user ~/bin/oncall-menu hc keybind $Mod-Shift-a spawn systemd-run --scope --user rofi -show pb -modi "pb:$HOME/.config/herbstluftwm/passboltmenu2" hc keybind $Mod-m spawn systemd-run --scope --user ~/.config/herbstluftwm/pmount-dmenu hc keybind $Mod-Escape spawn systemd-run --scope --user dunstctl close diff --git a/dot_config/herbstluftwm/executable_panel-handler b/dot_config/herbstluftwm/executable_panel-handler index df4b74d..bd281db 100644 --- a/dot_config/herbstluftwm/executable_panel-handler +++ b/dot_config/herbstluftwm/executable_panel-handler @@ -11,7 +11,7 @@ panel_height=18 # bgcolor=$(hc get frame_border_normal_color) # selbg=$(hc get window_border_active_color) # selfg='#282828' -# fg='#fbf1c7' +# fg='#fbf1c7' # bgcolor='#282828' # selsecbg='#ebdbb2' @@ -118,7 +118,7 @@ hc --idle | { ### center #echo -n "%{c}%{U${colors[bright_orange]}}${windowtitle:0:150}%{U-}" ### print the right - res+="%{r}$memory$df$playing$volume$wifi$network$temperature$load $separator$date $separator%{U#f2f229}$charge%{U-}$separator" + res+="%{r}$alerts$memory$df$playing$volume$wifi$network$temperature$load $separator$date $separator%{U#f2f229}$charge%{U-}$separator" #echo -en "%{r}$right $separator %{U#f2f229}$charge%{U-} $separator" done @@ -192,6 +192,11 @@ hc --idle | { # notify "Player: ${cmd[1]}" "${cmd[2]}" # player_status[${cmd[1]}]="${cmd[2]}" ;; + + alerts) + alerts=" ${cmd[1]} $separator" + ;; + battery) #echo "battery" >&2 batt_perc="${cmd[1]}"