Skip to content

Commit 24224a7

Browse files
committed
Add missing desktop.el changes after Polybar episode
1 parent 805bba0 commit 24224a7

File tree

2 files changed

+281
-6
lines changed

2 files changed

+281
-6
lines changed

Desktop.org

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ We use the excellent [[https://github.com/ch11ng/exwm][EXWM]] module as the basi
4242
(efs/start-panel)
4343

4444
;; Launch apps that will run in the background
45+
(efs/run-in-background "dunst")
4546
(efs/run-in-background "nm-applet")
4647
(efs/run-in-background "pasystray")
4748
(efs/run-in-background "blueman-applet"))
@@ -191,6 +192,7 @@ We use the excellent [[https://github.com/ch11ng/exwm][EXWM]] module as the basi
191192

192193
#+end_src
193194

195+
194196
* Desktop Environment
195197

196198
** Desktop Key Bindings
@@ -463,3 +465,243 @@ label-warn = %temperature-c%!
463465
label-warn-foreground = ${colors.secondary}
464466

465467
#+end_src
468+
469+
** Desktop Notifications with Dunst
470+
471+
We use an application called [[https://dunst-project.org/][Dunst]] to enable the display of desktop notifications from Emacs and other applications running within EXWM. Consult the [[https://dunst-project.org/documentation/][documentation]] for more details on how to configure this to your liking!
472+
473+
Here are some things you might want to consider changing:
474+
475+
- =format= - Customize how notification text contents are displayed
476+
- =geometry= - Where the notification appears and how large it should be by default
477+
- =urgency_normal=, etc - configures the background and frame color for notifications of different types
478+
- =max_icon_size= - Constrain icon display since some icons will be larger than others
479+
- =icon_path= - Important if your icons are not in a common location (like when using GNU Guix)
480+
- =idle_threshold= - Wait for user to become active for this long before hiding notifications
481+
- =mouse_left/right/middle_click= - Action to take when clicking a notification
482+
- Any of the key bindings in the =shortcuts= section (though these are deprecated in 1.5.0, use =dunstctl=)
483+
484+
#+begin_src conf :tangle ~/.config/dunst/dunstrc :mkdirp yes
485+
486+
[global]
487+
### Display ###
488+
monitor = 0
489+
490+
# The geometry of the window:
491+
# [{width}]x{height}[+/-{x}+/-{y}]
492+
geometry = "500x10-10+50"
493+
494+
# Show how many messages are currently hidden (because of geometry).
495+
indicate_hidden = yes
496+
497+
# Shrink window if it's smaller than the width. Will be ignored if
498+
# width is 0.
499+
shrink = no
500+
501+
# The transparency of the window. Range: [0; 100].
502+
transparency = 10
503+
504+
# The height of the entire notification. If the height is smaller
505+
# than the font height and padding combined, it will be raised
506+
# to the font height and padding.
507+
notification_height = 0
508+
509+
# Draw a line of "separator_height" pixel height between two
510+
# notifications.
511+
# Set to 0 to disable.
512+
separator_height = 1
513+
separator_color = frame
514+
515+
# Padding between text and separator.
516+
padding = 8
517+
518+
# Horizontal padding.
519+
horizontal_padding = 8
520+
521+
# Defines width in pixels of frame around the notification window.
522+
# Set to 0 to disable.
523+
frame_width = 2
524+
525+
# Defines color of the frame around the notification window.
526+
frame_color = "#89AAEB"
527+
528+
# Sort messages by urgency.
529+
sort = yes
530+
531+
# Don't remove messages, if the user is idle (no mouse or keyboard input)
532+
# for longer than idle_threshold seconds.
533+
idle_threshold = 120
534+
535+
### Text ###
536+
537+
font = Cantarell 20
538+
539+
# The spacing between lines. If the height is smaller than the
540+
# font height, it will get raised to the font height.
541+
line_height = 0
542+
markup = full
543+
544+
# The format of the message. Possible variables are:
545+
# %a appname
546+
# %s summary
547+
# %b body
548+
# %i iconname (including its path)
549+
# %I iconname (without its path)
550+
# %p progress value if set ([ 0%] to [100%]) or nothing
551+
# %n progress value if set without any extra characters
552+
# %% Literal %
553+
# Markup is allowed
554+
format = "<b>%s</b>\n%b"
555+
556+
# Alignment of message text.
557+
# Possible values are "left", "center" and "right".
558+
alignment = left
559+
560+
# Show age of message if message is older than show_age_threshold
561+
# seconds.
562+
# Set to -1 to disable.
563+
show_age_threshold = 60
564+
565+
# Split notifications into multiple lines if they don't fit into
566+
# geometry.
567+
word_wrap = yes
568+
569+
# When word_wrap is set to no, specify where to make an ellipsis in long lines.
570+
# Possible values are "start", "middle" and "end".
571+
ellipsize = middle
572+
573+
# Ignore newlines '\n' in notifications.
574+
ignore_newline = no
575+
576+
# Stack together notifications with the same content
577+
stack_duplicates = true
578+
579+
# Hide the count of stacked notifications with the same content
580+
hide_duplicate_count = false
581+
582+
# Display indicators for URLs (U) and actions (A).
583+
show_indicators = yes
584+
585+
### Icons ###
586+
587+
# Align icons left/right/off
588+
icon_position = left
589+
590+
# Scale larger icons down to this size, set to 0 to disable
591+
max_icon_size = 88
592+
593+
# Paths to default icons.
594+
icon_path = /usr/share/icons/Adwaita/96x96/status:/usr/share/icons/Adwaita/96x96/emblems
595+
596+
### History ###
597+
598+
# Should a notification popped up from history be sticky or timeout
599+
# as if it would normally do.
600+
sticky_history = no
601+
602+
# Maximum amount of notifications kept in history
603+
history_length = 20
604+
605+
### Misc/Advanced ###
606+
607+
# Browser for opening urls in context menu.
608+
browser = qutebrowser
609+
610+
# Always run rule-defined scripts, even if the notification is suppressed
611+
always_run_script = true
612+
613+
# Define the title of the windows spawned by dunst
614+
title = Dunst
615+
616+
# Define the class of the windows spawned by dunst
617+
class = Dunst
618+
619+
startup_notification = false
620+
verbosity = mesg
621+
622+
# Define the corner radius of the notification window
623+
# in pixel size. If the radius is 0, you have no rounded
624+
# corners.
625+
# The radius will be automatically lowered if it exceeds half of the
626+
# notification height to avoid clipping text and/or icons.
627+
corner_radius = 4
628+
629+
mouse_left_click = close_current
630+
mouse_middle_click = do_action
631+
mouse_right_click = close_all
632+
633+
# Experimental features that may or may not work correctly. Do not expect them
634+
# to have a consistent behaviour across releases.
635+
[experimental]
636+
# Calculate the dpi to use on a per-monitor basis.
637+
# If this setting is enabled the Xft.dpi value will be ignored and instead
638+
# dunst will attempt to calculate an appropriate dpi value for each monitor
639+
# using the resolution and physical size. This might be useful in setups
640+
# where there are multiple screens with very different dpi values.
641+
per_monitor_dpi = false
642+
643+
[shortcuts]
644+
645+
# Shortcuts are specified as [modifier+][modifier+]...key
646+
# Available modifiers are "ctrl", "mod1" (the alt-key), "mod2",
647+
# "mod3" and "mod4" (windows-key).
648+
# Xev might be helpful to find names for keys.
649+
650+
# Close notification.
651+
#close = ctrl+space
652+
653+
# Close all notifications.
654+
#close_all = ctrl+shift+space
655+
656+
# Redisplay last message(s).
657+
# On the US keyboard layout "grave" is normally above TAB and left
658+
# of "1". Make sure this key actually exists on your keyboard layout,
659+
# e.g. check output of 'xmodmap -pke'
660+
history = ctrl+grave
661+
662+
# Context menu.
663+
context = ctrl+shift+period
664+
665+
[urgency_low]
666+
# IMPORTANT: colors have to be defined in quotation marks.
667+
# Otherwise the "#" and following would be interpreted as a comment.
668+
background = "#222222"
669+
foreground = "#888888"
670+
timeout = 10
671+
# Icon for notifications with low urgency, uncomment to enable
672+
#icon = /path/to/icon
673+
674+
[urgency_normal]
675+
background = "#1c1f26"
676+
foreground = "#ffffff"
677+
timeout = 10
678+
# Icon for notifications with normal urgency, uncomment to enable
679+
#icon = /path/to/icon
680+
681+
[urgency_critical]
682+
background = "#900000"
683+
foreground = "#ffffff"
684+
frame_color = "#ff0000"
685+
timeout = 0
686+
# Icon for notifications with critical urgency, uncomment to enable
687+
#icon = /path/to/icon
688+
689+
#+end_src
690+
691+
We can also set up some functions for enabling and disabling notifications at any time:
692+
693+
#+begin_src emacs-lisp
694+
695+
(defun efs/disable-desktop-notifications ()
696+
(interactive)
697+
(start-process-shell-command "notify-send" nil "notify-send \"DUNST_COMMAND_PAUSE\""))
698+
699+
(defun efs/enable-desktop-notifications ()
700+
(interactive)
701+
(start-process-shell-command "notify-send" nil "notify-send \"DUNST_COMMAND_RESUME\""))
702+
703+
(defun efs/toggle-desktop-notifications ()
704+
(interactive)
705+
(start-process-shell-command "notify-send" nil "notify-send \"DUNST_COMMAND_TOGGLE\""))
706+
707+
#+end_src

desktop.el

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@
1515
;; Open eshell by default
1616
;;(eshell)
1717

18+
;; NOTE: The next two are disabled because we now use Polybar!
19+
1820
;; Show battery status in the mode line
19-
(display-battery-mode 1)
21+
;;(display-battery-mode 1)
2022

2123
;; Show the time and date in modeline
22-
(setq display-time-day-and-date t)
23-
(display-time-mode 1)
24+
;;(setq display-time-day-and-date t)
25+
;;(display-time-mode 1)
2426
;; Also take a look at display-time-format and format-time-string
2527

28+
;; Start the Polybar panel
29+
(efs/start-panel)
30+
2631
;; Launch apps that will run in the background
2732
(efs/run-in-background "nm-applet")
2833
(efs/run-in-background "pasystray")
@@ -109,10 +114,11 @@
109114
;; Set the wallpaper after changing the resolution
110115
(efs/set-wallpaper)
111116

117+
;; NOTE: This is disabled because we now use Polybar!
112118
;; Load the system tray before exwm-init
113-
(require 'exwm-systemtray)
114-
(setq exwm-systemtray-height 32)
115-
(exwm-systemtray-enable)
119+
;; (require 'exwm-systemtray)
120+
;; (setq exwm-systemtray-height 32)
121+
;; (exwm-systemtray-enable)
116122

117123
;; Automatically send the mouse cursor to the selected workspace's display
118124
(setq exwm-workspace-warp-cursor t)
@@ -178,3 +184,30 @@
178184
(desktop-environment-brightness-small-decrement "2%-")
179185
(desktop-environment-brightness-normal-increment "5%+")
180186
(desktop-environment-brightness-normal-decrement "5%-"))
187+
188+
;; Make sure the server is started (better to do this in your main Emacs config!)
189+
(server-start)
190+
191+
(defvar efs/polybar-process nil
192+
"Holds the process of the running Polybar instance, if any")
193+
194+
(defun efs/kill-panel ()
195+
(interactive)
196+
(when efs/polybar-process
197+
(ignore-errors
198+
(kill-process efs/polybar-process)))
199+
(setq efs/polybar-process nil))
200+
201+
(defun efs/start-panel ()
202+
(interactive)
203+
(efs/kill-panel)
204+
(setq efs/polybar-process (start-process-shell-command "polybar" nil "polybar panel")))
205+
206+
(defun efs/send-polybar-hook (module-name hook-index)
207+
(start-process-shell-command "polybar-msg" nil (format "polybar-msg hook %s %s" module-name hook-index)))
208+
209+
(defun efs/send-polybar-exwm-workspace ()
210+
(efs/send-polybar-hook "exwm-workspace" 1))
211+
212+
;; Update panel indicator when workspace changes
213+
(add-hook 'exwm-workspace-switch-hook #'efs/send-polybar-exwm-workspace)

0 commit comments

Comments
 (0)