From 9a46efb2ad5f826c0659f7869c7a40c3344ae63f Mon Sep 17 00:00:00 2001 From: Adrien Schildknecht Date: Mon, 9 Apr 2018 17:20:07 -0700 Subject: Update the README: gnome-terminal --- README.md | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index c176c81..6e50246 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,26 @@ xcwd - X current working directory ================================== -xcwd is a simple tool which print the current working directory of the +xcwd is a simple tool that prints the current working directory of the currently focused window. -The main goal is to launch applications directly into the same directory -as the focused applications. This is especially useful if you want to open -a new terminal for debugging or compiling purpose. +The main goal is to launch applications directly into the same directory as the +focused applications. This is especially useful to open a new terminal or a +file explorer. Disclaimer ---------- +This program is basically a hack, but it works well with my setup and I hope +it will work for you as well :) + This script **can't** retrieve the working directory of a "single instance -application" nor terminal multiplexer, e.g. : +application" nor terminal multiplexer, e.g.: - tmux, screen - lilyterm - konsole - urxvtc with urxvtd - applications with tabs -The application works well with the following terminals : +The application works with the following terminals: - urxvt - xterm - gnome terminal @@ -25,15 +28,15 @@ The application works well with the following terminals : How it works ------------ - - Retrieve the focused window - - Read its attributes to get the PID. If `_NET_WM_PID` is set, xcwd just - read the value. Otherwise it reads the `_NET_WM_CLASS` and compares it to - the name of all the running processes - - Search for the deepest child of the selected PID (to avoid getting the - working directory of the terminal instead of the shell) - - Print the current working directory + - Get the handle of the focused window; + - Try to get the PID of the program using the window's attributes: + - If `_NET_WM_PID` is set, xcwd just reads the value; + - Otherwise it reads the `_NET_WM_CLASS` and compares it to the name of + all the running processes; + - Find the deepest child process; + - Print the working directory of this process to stdout. -If one of those steps fail, xcwd print the content of the `HOME` variable. +If one of these steps fail, xcwd prints the content of the `$HOME` variable. Requirements ------------ @@ -50,13 +53,15 @@ Running xwcd ------------ Simply invoke the 'xcwd' command. -You probably want to use it this way: +Examples: * ``urxvt -cd "`xcwd`" `` * ``xterm -e "cd `xcwd` && /bin/zsh"`` +* ``gnome-terminal --working-directory="`xcwd`"`` * ``pcmanfm "`xcwd`" `` i3 Configuration ---------------- * bindsym $mod+Shift+Return exec ``urxvt -cd "`xcwd`" `` -* bindsym $mod+Shift+Return exec ``xterm -e "cd `xcwd` && /bin/zsh"`` +* bindsym $mod+Shift+Return exec ``xterm -e "cd `xcwd` && $SHELL"`` +* bindsym $mod+Shift+Return exec ``gnome-terminal --working-directory="`xcwd`"`` * bindsym $mod+p exec ``pcmanfm "`xcwd`"`` -- cgit v1.2.3 From e2c777cbf3a226522a4871f97916f0cb0bee3688 Mon Sep 17 00:00:00 2001 From: Jacko Dirks <2016783+jackodirks@users.noreply.github.com> Date: Tue, 1 May 2018 16:07:16 +0200 Subject: Fixes Makefile: sanity, no longer cleans on build (#18) --- Makefile | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index b25eea8..ac57069 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,14 @@ CFILES=xcwd.c CC=gcc CFLAGS=-Wall -Wextra -std=gnu99 -O2 LDFLAGS=-lX11 -EXE="xcwd" +EXE=xcwd prefix=/usr UNAME:=$(shell uname) O=${CFILES:.c=.o} +.PHONY: all clean distclean install +.SUFFIXES: .c .o + ifeq ($(UNAME), Linux) CFLAGS += -DLINUX else @@ -18,12 +21,7 @@ else endif endif -${EXE}: clean ${O} - ${CC} -o $@ ${O} ${CFLAGS} ${LDFLAGS} - -.SUFFIXES: .c .o -.c.o: - ${CC} -c $< ${CFLAGS} +all: ${EXE} clean: rm -vf *.o @@ -34,3 +32,11 @@ distclean: clean install: ${EXE} install -m 0755 ${EXE} $(prefix)/bin + +${EXE}: ${O} + ${CC} -o $@ ${O} ${CFLAGS} ${LDFLAGS} + + +.c.o: + ${CC} -c $< ${CFLAGS} + -- cgit v1.2.3