schischi / xcwd Goto Github PK
View Code? Open in Web Editor NEWA simple tool that prints the current working directory of the currently focused window
License: Other
A simple tool that prints the current working directory of the currently focused window
License: Other
Hey there 👋
are the any plans to make a release?
I had an issue with an ignored return value, when compiling xcwd using gcc version 4.6.3-1ubuntu5 (See output below). The problem can be resolved trivially by removing -Werror from the compiler flags in the Makefile and should probably be fixed, since it currently does not compile out of the box with my gcc version (I'd be surprised if that would be an Ubuntu-only issue). However, I wondered how to resolve this with this strict compiler option, since I assumed this was set intentionally.
This stackoverflow article sheds some light on the matter but it seems to imply that the cleanest way is not to use it.
For reference, here is the output of my make invokation:
rm -vf *.o
removed `xcwd.o'
gcc -c xcwd.c -Wall -Werror -Wextra -std=gnu99 -O2 -DLINUX
xcwd.c: In function ‘getProcesses’:
xcwd.c:176:14: error: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Werror=unused-result]
cc1: all warnings being treated as errors
make: *** [xcwd.o] Error 1
runnings multiples gnome-terminal in i3 in several workspaces and I get something like this :
➜ tmp>xcwd
/home/myuser/d1
➜ tmp>pwd
/home/myuser/d2
I get the following errors when trying to 'make' on my 32bit netbook running arch. For what it's worth, compilation happened without any error on my 64bit desktop. The processor architecture is the only difference I can think of between the two machines that might cause this, they both run arch and are both fully up to date.
$ make
rm -vf .o
gcc -c xcwd.c -Wall -Werror -Wextra -pedantic -std=gnu99 -O2
xcwd.c: In function ‘windowStrings’:
xcwd.c:114:17: error: passing argument 10 of ‘XGetWindowProperty’ from incompatible pointer type [-Werror]
&type, &format, size, &after, &data) == Success) {
^
In file included from xcwd.c:14:0:
/usr/include/X11/Xlib.h:2684:12: note: expected ‘long unsigned int *’ but argument is of type ‘size_t *’
extern int XGetWindowProperty(
^
xcwd.c: In function ‘getProcesses’:
xcwd.c:150:5: error: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘size_t’ [-Werror=format=]
LOG("Found %ld processes\n", globbuf.gl_pathc);
^
cc1: all warnings being treated as errors
make: ** [xcwd.o] Error 1
Hello,
I found my problem already addressed in README. But still I would request for an explanation of the issue.
I am using konsole
as my terminal emulator. I have unset this option to "Run all Konsole windows in a single process". And it is verified as I get multiple PID with pgrep konsole
when multiple windows are open.
My issue is that when I do a readlink /proc/$PID/cwd
, it always gives path to $HOME
directory. So why doesn't it get updated there?
To get PID
:
xdotool getwindowpid "$(xdotool getactivewindow)"
Another question which you might be able to answer is in a single instance of urxvt
, pgrep urxvt
gives 2 PIDs (another question, why?), and the actual cwd
is stored in /proc/"$(($FIRSTPID+2))"/cwd
!
This is not an "issue" but some queries which are related to this project. I didn't find appropriate support for these queries till date and stumbled upon this project so thought this might be a good place to ask!
Use-case: Get the working directory of a window that is not currently focused.
Hi, thanks for awesome project!
Feature request:
It would be nice to have an option for inherit all environment variables from the target window as well.
Use case:
You can set some variables like KUBECONFIG
, GOOGLE_APPLICATION_CREDENTIALS
, AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
per session and use xcwd to copy them to new window.
Hey
This scratches a big itch in i3, thanks so much for writing it!
🍻
Trying to compile form here (ubuntu 12.10), I got this error:
$ gcc -Wall -Werror -std=gnu89 -lX11 xcwd.c -o xcwd
/tmp/cc4jSMfF.o: In function `focusedWindow':
xcwd.c:(.text+0x61): undefined reference to `XOpenDisplay'
xcwd.c:(.text+0x98): undefined reference to `XGetInputFocus'
/tmp/cc4jSMfF.o: In function `windowPid':
xcwd.c:(.text+0xc3): undefined reference to `XInternAtom'
xcwd.c:(.text+0xe0): undefined reference to `XInternAtom'
xcwd.c:(.text+0x151): undefined reference to `XGetWindowProperty'
xcwd.c:(.text+0x175): undefined reference to `XFree'
/tmp/cc4jSMfF.o: In function `windowStrings':
xcwd.c:(.text+0x1aa): undefined reference to `XInternAtom'
xcwd.c:(.text+0x21b): undefined reference to `XGetWindowProperty'
xcwd.c:(.text+0x245): undefined reference to `XInternAtom'
xcwd.c:(.text+0x2aa): undefined reference to `XFree'
collect2: error: ld returned 1 exit status
I can compile however by issuing:
gcc xcwd.c -Wall -Werror -std=gnu89 -lX11 -o xcwd
Unfortunately, it does not work for gnome-terminal :-(
Also in urxvt, I found that there is a weird extra character in the output (happens to me at least).
When using dbus server, this program seems not to work. You may wish to deactivate this in the Preferences window of terminator.
I ran into this issue switching from urxvt to lilyterm. Lilyterm by default launches all its terminals as one process (and I guess so do a couple of other emulators). xcwd outputs the working directory of the "first" window typically, which is in general not what you want.
It makes sense that xcwd does not work in this context, however, I think it would probably be worth mentioning (in the readme) that you should configure your emulator to launch separate processes for each shell.
I suppose fixing this issue would require a lot of emulator-specific work and thus is not really an option, is it?
If I'm using zshell with gnome-terminal, it only returns my home directory. I placed the following in my ~/.i3/config:
bindsym $mod+g exec gnome-terminal --working-directory=`xcwd`
However it will only work if I'm running bash in gnome-terminal.
If it helps, my dotfiles are located here:
http://github.com/aarobc/dotfiles
Hi!
xcwd is a great tool. I would like to package it for debian. However there are some things that I would need you to change before I can package it into debian:
["please" implied for all of the following]
Even if you make all these changes, I cannot promise you that it will end up in debian soon, but I will do my best to get an upload.
Please let me know what you think of this... and again, great project 👍
Hello,
I use fish. I start fish by putting this code at the bottom of .bashrc (I also tried to set fish as the default shell to check if it works with xcwd)
if [[ $(ps --no-header --pid=$PPID --format=cmd) != "fish" ]]
then
exec fish
fi
I use I3 and I tried every command possible in the .config after the bindsym
It works with bash.
I can open a new terminal in the same folder if when I'm into a terminal using fish I execute "bash --norc" to start bash and then I do the $mod+o (or whatever bind I created) then it works even when the new terminal opened uses fish as a shell. I noticed it also works if vim is opened inside fish.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.