siduck76 3 жил өмнө
parent
commit
515558d1a5

+ 2 - 3
.dwm/autostart

@@ -11,8 +11,7 @@ cp -r ~/Public/theme\ and\ icons/flux/settings.ini  ~/.config/gtk-3.0/ &
 cp -r ~/Public/rofi/dwm_nord/rofi/ ~/.config/ &
 
 xbacklight -set 10 &
-xmodmap ~/.xmodmap-sid &
-
-# Dont remove these!
 ~/.dwm/bar &
+
+xmodmap ~/.xmodmap-sid &
 dwm

+ 1 - 1
.dwm/bar

@@ -49,7 +49,7 @@ mem() {
 wlan() {
   case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in
   up) printf "^c#3b414d^ ^b#7681c5^ 󰤨 ^d^%s" " ^c#828dd1^Connected" ;;
-  down) printf "^c#3b414d^ ^b#7681c5^ 󰤨 ^d^%s" " ^c#828dd1^Disconnected" ;;
+  down) printf "^c#3b414d^ ^b#7681c5^ 󰤭 ^d^%s" " ^c#828dd1^Disconnected" ;;
   esac
 }
 

+ 12 - 0
.dwm/save_tagpreview

@@ -0,0 +1,12 @@
+#!/bin/sh
+
+preview_dir="$HOME/.dwm/tag_previews/"
+
+current_tag=$(($(wmctrl -d | grep '*' | cut -d ' ' -f1) + 1)) # get tag number, and add 1
+
+save_Screenshot() {
+  file="${preview_dir}${current_tag}.png"
+  maim -u "${file}"
+}
+
+$(save_Screenshot)

+ 15 - 0
.dwm/tag_preview

@@ -0,0 +1,15 @@
+#!/bin/bash
+
+screenshot_dir="$HOME/.dwm/tag_previews/"
+
+if [ "$1" == "--hide" ]; then # If first argument is --hide execute
+  killall rofi 2>/dev/null
+  shift # shift the first argument
+fi
+
+if [ "$1" == "--show" ]; then # If first argument is --show execute
+  file="${screenshot_dir}${2}.png"                              # $2 is the tag which will be previewed
+  [ -f $file ] || exit 1                                        # Exit when file does not exist
+  sed -i "s:${HOME}/.*\.png:$file:" $HOME/.config/rofi/tag.rasi #overwrites the tagname in rofi config
+  rofi -show drun -theme tag 2>/dev/null
+fi

+ 1 - 0
chadwm/config.def.h

@@ -134,6 +134,7 @@ static const char *rofi[] = {"rofi", "-show", "drun", NULL };
 static const char *layoutmenu_cmd = "layoutmenu.sh";
 static const char *xi[] = {"xbacklight", "-inc", "7", NULL};
 static const char *xd[] = {"xbacklight", "-dec", "7", NULL};
+static const char *preview_path = "/home/sid/.dwm/tag_preview";
 
 static Key keys[] = {
     /* modifier                     key        function        argument */

+ 40 - 1
chadwm/dwm.c

@@ -310,6 +310,7 @@ static void run(void);
 static void scan(void);
 static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2,
                      long d3, long d4);
+static void sendcommand(int tag);
 static void sendmon(Client *c, Monitor *m);
 static void setborderpx(const Arg *arg);
 static void setclientstate(Client *c, long state);
@@ -329,6 +330,7 @@ static void sigchld(int unused);
 static void sighup(int unused);
 static void sigterm(int unused);
 static void spawn(const Arg *arg);
+static void switchtag(void);
 static Monitor *systraytomon(Monitor *m);
 static void tabmode(const Arg *arg);
 static void tag(const Arg *arg);
@@ -372,6 +374,7 @@ static int screen;
 static int sw, sh;      /* X display screen geometry width, height */
 static int bh, blw = 0; /* bar geometry */
 static int th = 0;      /* tab bar geometry */
+static int preview = 0;
 static int lrpad;       /* sum of left and right padding for text */
 static int (*xerrorxlib)(Display *, XErrorEvent *);
 static unsigned int numlockmask = 0;
@@ -1927,10 +1930,30 @@ monocle(Monitor *m)
 }
 
 void motionnotify(XEvent *e) {
+  unsigned int i, x;
   static Monitor *mon = NULL;
   Monitor *m;
   XMotionEvent *ev = &e->xmotion;
 
+ if (ev->window == selmon->barwin) {
+    i = x = 0;
+    do
+      x += TEXTW(tags[i]);
+    while (ev->x >= x && ++i < LENGTH(tags));
+       if (i < LENGTH(tags)) {
+      i++;
+      if (i != preview)
+	      sendcommand(i);
+      preview = i;
+    } else {
+      sendcommand(0);
+      preview = 0;
+    }
+  } else if (preview != 0) {
+	  preview = 0;
+	  sendcommand(0);
+  }
+ 
   if (ev->window != root)
     return;
   if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
@@ -2248,6 +2271,15 @@ void scan(void) {
   }
 }
 
+void sendcommand(int tag) {
+	char cmd[50];
+	if (tag)
+		snprintf(cmd, sizeof(cmd), "%s --hide --show %d &", preview_path, tag);
+	else
+		snprintf(cmd, sizeof(cmd), "%s --hide &", preview_path);
+	system(cmd);
+}
+
 void sendmon(Client *c, Monitor *m) {
   if (c->mon == m)
     return;
@@ -2599,6 +2631,10 @@ void spawn(const Arg *arg) {
   }
 }
 
+void switchtag(void) {
+	system("~/.dwm/save_tagpreview");
+}
+
 void
 tabmode(const Arg *arg)
 {
@@ -2677,6 +2713,7 @@ void toggleview(const Arg *arg) {
       selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
 
   if (newtagset) {
+         switchtag();
     selmon->tagset[selmon->seltags] = newtagset;
     focus(NULL);
     arrange(selmon);
@@ -2740,7 +2777,8 @@ void updatebars(void) {
   Monitor *m;
   XSetWindowAttributes wa = {.override_redirect = True,
                              .background_pixmap = ParentRelative,
-                             .event_mask = ButtonPressMask | ExposureMask};
+                             .event_mask = ButtonPressMask | ExposureMask | PointerMotionMask};
+
   XClassHint ch = {"dwm", "dwm"};
   for (m = mons; m; m = m->next) {
     if (m->barwin)
@@ -3112,6 +3150,7 @@ void updatewmhints(Client *c) {
 void view(const Arg *arg) {
   if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
     return;
+  switchtag();
   selmon->seltags ^= 1; /* toggle sel tagset */
   if (arg->ui & TAGMASK)
     selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;

+ 13 - 0
rofi/tag.rasi

@@ -0,0 +1,13 @@
+configuration {
+    location: 1;
+    xoffset: 51;
+    yoffset: 41;
+  }
+
+window {
+    background-color:  #2E3440;
+    padding: 310px;
+    width: 220px;
+    height: 122px;
+    background-image: url("/home/sid/u.png",width);
+}