summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-05-17 10:15:42 +0300
committerThanos Apollo <[email protected]>2024-05-17 10:15:42 +0300
commit0be1080c44190eaba6e352d858a7b9fc6186bdc3 (patch)
tree6917262fd96ac17fd528c939b2bcd129cb92d081
parent95401ae3d97e3ff3a285ad634e2fce6b941a0a14 (diff)
emacs+sway: Use emacs to set wallpaper on startup
-rw-r--r--.config/emacs/init.el45
-rw-r--r--.config/sway/config19
2 files changed, 47 insertions, 17 deletions
diff --git a/.config/emacs/init.el b/.config/emacs/init.el
index 7c88626..4d88c34 100644
--- a/.config/emacs/init.el
+++ b/.config/emacs/init.el
@@ -251,7 +251,6 @@
("b" . "src bash")
("q" . "QUOTE")))
- ;; Export
(add-to-list 'org-latex-classes
'("article"
"\\documentclass[11pt,a4paper]{article}
@@ -1237,7 +1236,11 @@ Create a temporary frame to execute BODY, which will then be deleted."
;; Theming
-(defvar wallpapers-dir "~/wallpapers/")
+(defvar wallpapers-dir "~/wallpapers/"
+ "Wallpaper directory.")
+
+(defvar wallpaper-current nil
+ "Current wallpaper.")
(defun thanos/load-theme (&optional theme)
"Disable current theme and load a new THEME."
@@ -1265,8 +1268,42 @@ Create a temporary frame to execute BODY, which will then be deleted."
(defun thanos/wallpaper-select ()
"Set wallpaper."
(interactive)
- (let ((wallpaper (completing-read "Choose wallpaper: " (directory-files wallpapers-dir nil "^[^.].*"))))
- (thanos/wallpaper-set (format "%s%s" wallpapers-dir wallpaper))))
+ (let ((wallpaper (format "%s%s" wallpapers-dir
+ (completing-read "Choose wallpaper: "
+ (directory-files wallpapers-dir nil "^[^.].*")))))
+ (thanos/wallpaper-set wallpaper)
+ (setf wallpaper-current wallpaper)))
+
+(defun thanos/wallpaper-watcher (_symbol new-value _where _environment)
+ "Watch for wallpaper changes."
+ (with-temp-buffer (find-file (expand-file-name "wallpaper" user-emacs-directory))
+ (erase-buffer)
+ (setf wallpaper-current new-value)
+ (insert (pp-to-string wallpaper-current))
+ (save-buffer)
+ (kill-buffer)))
+
+(defun thanos/load-wallpaper ()
+ "Load saved wallpaper."
+ (let ((wallpaper-path (expand-file-name "wallpaper" user-emacs-directory)))
+ (if (file-exists-p wallpaper-path)
+ (with-temp-buffer
+ (insert-file-contents wallpaper-path)
+ (goto-char (point-min))
+ (let ((contents (read (current-buffer))))
+ (setf wallpaper-current contents)))
+ (write-region "nil" nil wallpaper-path))))
+
+(defun thanos/wallpaper-startup (&optional image)
+ "Set wallpaper IMAGE on startup."
+ (thanos/load-wallpaper)
+ (let ((image (or image wallpaper-current)))
+ (thanos/wallpaper-set image)))
+
+(add-variable-watcher 'wallpaper-current #'thanos/wallpaper-watcher)
+
+;; Set wallpaper
+(thanos/wallpaper-startup)
(defvar-keymap thanos/applications-map
:doc "Thanos commonly used programs"
diff --git a/.config/sway/config b/.config/sway/config
index caa6114..dc3ceb6 100644
--- a/.config/sway/config
+++ b/.config/sway/config
@@ -1,10 +1,9 @@
## Mod key
set $mod Mod4
-#exec sudo /home/thanos/.local/bin/tailscaled
-exec nm-applet
+
+exec emacs
exec waybar
-exec swayidle -w timeout 360 swaylock before-sleep swaylock
bindsym $mod+z exec swaylock
@@ -15,8 +14,8 @@ bindsym $mod+comma exec grimshot save area
bindsym $mod+Shift+comma exec grimshot save screen
## Setup monitors & wallpapers
-output DP-2 pos 0 0 res 2560x1440 bg ~/wallpapers/colors-fantasy.jpg stretch
-output HDMI-A-1 pos 2560 0 res 2560x1440 bg ~/wallpapers/colors-fantasy.jpg fill transform 270
+output DP-2 pos 0 0 res 2560x1440
+output HDMI-A-1 pos 2560 0 res 2560x1440 transform 270
default_border pixel 3
default_floating_border pixel 3
@@ -33,20 +32,12 @@ smart_borders on
#swaymsg -t get_tree | grep app_id
for_window [app_id="pop-up"] floating enable
for_window [app_id="thanos/pass-launcher"] floating enable
- for_window [app_id="bubble"] floating enable
for_window [app_id="task_dialog"] floating enable
- for_window [app_id="Preferences"] floating enable
for_window [app_id="dialog"] floating enable
- for_window [app_id="menu"] floating enable
for_window [app_id="Organizer"] floating enable
- for_window [app_id="About"] floating enable
for_window [app_id="toolbox"] floating enable
for_window [app_id="page-info"] floating enable
for_window [app_id="webconsole"] floating enable
- for_window [app_id="Authy"] floating enable
- for_window [app_id="termfloat"] floating enable
- for_window [app_id="termfloat"] resize set height 540
- for_window [app_id="termfloat"] resize set width 960
for_window [app_id="mpv"] floating enable
for_window [app_id="mpv"] resize set height 540
for_window [app_id="mpv"] resize set width 960
@@ -274,3 +265,5 @@ bindsym Shift+Ctrl+Left resize shrink width 5 px or 5 ppt
bindsym Shift+Ctrl+Up resize grow height 5 px or 5 ppt
bindsym Shift+Ctrl+Down resize shrink height 5 px or 5 ppt
bindsym Shift+Ctrl+Right resize grow width 5 px or 5 ppt
+
+exec swayidle -w timeout 360 swaylock before-sleep swaylock \ No newline at end of file