As some of you might be aware, there's a bug with either Conky or PCManFM (the desktop manager aspect of it) that makes the Conky window disappear in one of these situations:
Setting "own_window_type override" in .conkyrc (the usual configuration for Nautilus) flat out doesn't show the Conky window at all.
Setting "own_window_type desktop" in .conkyrc shows the Conky window, but it disappears if you click on the desktop.
Setting "own_window_type normal" in .conkyrc shows the Conky window, it doesn't disappear when clicking on the desktop, BUT... it disappears if you use LXPanel's "Minimize all windows" plugin ("Show desktop" equivalent). This happens if using the keyboard shortcut as well.
There are some workarounds to this, such as deactivating PCManFM's desktop management (and using feh for setting the wallpaper and, presumably, iDesk for the icons) or using another file manager altogether, but I've come to notice these are all subpar solutions. I really like PCManFM and I really like Conky. What's a guy to do? :-/
So I dug in LXPanel's source and found a relevant piece of code that might house my fix. The file is src/plugins/wincmd.c .
The idea I have is that when the "Minimize all windows" button is clicked, all windows (class) names would be compared to a static string "Conky" and if it matches, it simply wouldn't minimize that window. Simple, and it should work. But the problem is it has been a few years since I've touched any C code and I haven't really played with Xlib that much.
So far, I have done the following changes:
19a20
> #include <string.h>
77a79,82
>
> /* Getting window's class name */
> XClassHint class;
> XGetClassHint(GDK_DISPLAY(), client_list[i], &class);
81c88
< if (((task_desktop == -1) || (task_desktop == current_desktop))
---
> if (((task_desktop == -1) || (task_desktop == current_desktop) || strcmp(class.res_name, "Conky") != 0)
This compiles correctly, but when I run the new lxpanel and click on "Minimize all windows", Conky still disappears as before.
If someone can look into this file and see if my changes make sense, I'd be very grateful.
Thanks SO! :)
This is still impossible afaik. I made this quirky workaround. Just use the own_window_type normal mode where you cannot use the Win+D desktop shortcut, and fix conky on show desktop.
First I thought, just remapping the conky window will do the trick. But I found out that as long as the desktop is focussed, nothing will get drawn over it. Then I thought, just kill and restart conky. But while in show desktop mode, it will get created in the background.
So in order to get conky back:
The desktop must be unfocussed
restart conky or remap the window
Install xdotool; apt-get install xdotool
Create a script, e.g. /usr/local/bin/conky-remap.sh:
#!/usr/bin/env bash
zenity --info --text "Remapping Conky..." &
pid=$!
sleep 0.3
kill $pid
xdotool windowmap `xdotool search --classname 'conky'`
Edit ~/.config/openbox/lxde-rc.xml (or wherever shortcuts are in your distro).
Find:
<keybind key="W-d">
<action name="ToggleShowDesktop"/>
</keybind>
Change to:
<keybind key="W-d">
<action name="ToggleShowDesktop"/>
<action name="Execute">
<execute>conky-remap.sh</execute>
</action>
</keybind>
Activate the new keyboard shortcut configuration:
openbox --reconfigure
Press Win+D. You'll see a flash and conky is back!
This quirky solution is the only solution in the universe according to a week of google, so improving on it is encouraged.
Explanation:
zenity --info --text "Remapping Conky..." &
We need to create a random window to unfocus the desktop. Conky itself doesn't work. :(
We also need the script to continue, so use &
pid=$!
Get the pid of that last process
sleep 0.3
Sleep any less (slow HTPC) and the window is killed before it is created.
kill $pid
Kill the window as soon as it has performed its function.
xdotool windowmap xdotool search --classname 'conky'
Now finally, we can raise (remap) conky.
Quirks:
Desktop is not focussed, so you cannot use the arrows to navigate desktop icons
Can we refocus the desktop? As long as the windows are not programatically minimized, conky will stay put.
300 ms delay, and a flash of the dialog box.
Pressing Win+D for a second time to go back ('unshow desktop')
We would need a way to detect if the desktop is already in show-desktop-mode, in which case the script should exit 0
The simplest solution working perfectly with Openbox (and should work with other WMs too):
In your .conkyrc file:
own_window yes
own_window_type desktop
own_window_class Conky
The "desktop" window type prevents conky from being minimized when show desktop is executed. Moreover your windows will be restored by executing "show desktop" again
Install xdotool package (it's very lightweight, don't worry), in terminal emulator run the following:
xdotool search --class "Pcmanfm" behave %# focus windowraise $(xdotool search --class "Conky")
and make sure your conky doesn't hide when you focus a desktop
If everything is okay, interrupt xdotool by pressing Ctrl+C in your terminal and place the code above in autostart. It probably won't start right away, so you have to create a simple script (e.g. "show_conky.sh") containing
#!/bin/sh
sleep 5
xdotool search --class "Pcmanfm" behave %# focus windowraise $(xdotool search --class "Conky")
The minimal required sleep time should be defined accordingly to your system. To be sure, conky won't hide at the first launch before "show_conky.sh" is executed, you can also create another script with xdotool focus windowraise $(xdotool search --class "Conky") command and proper sleep time in it (or try to add it between "sleep" and "xdotool behave" commands it "show_conky.sh").
Restart your Xorg server. Enjoy! :)
I personally advice you using SpaceFM for managing desktop icons. It allows you to set margins for the desktop area, so conky never covers icons. Pcmanfm looks more friendly as an explorer, but you can use both of them: spacefm can open directories located on the desktop with other application. Its desktop behavior is identical to pcmanfm, so you should simply replace "Pcmanfm" in the code above with the "Spacefm"
This is an old "question", but it came up fairly high in Google hits when I searched for "Conky LXDE", because I couldn't get Conky to work in Lubuntu. But there is no need to hack LXPanel!
After MUCH searching and false trials and trails, I found a .conkyrc file in the "PCLinuxOS-Forums" that Just Worked™. It has proved to be an excellent base to tweak from on Lubuntu 11.10.
I now use the same set up on Linux Mint 13 LTS "Maya" Xfce (based on Ubuntu 12.04), and it continues to meet my (very simple) Conky requirements. The current form of my .conkyrc file is saved in a Gist if anyone is thinks it might help them. (The original source link for the forum is commented into the rc file.)
The solution is:
NetWMState nws;
guint task_desktop = get_net_wm_desktop(client_list[i]);
get_net_wm_state(client_list[i], &nws);
if (((task_desktop == -1) || (task_desktop == current_desktop))
&& ( ( ! nwwt.dock) && ( ! nwwt.desktop) && ( ! nwwt.splash)
&& ( ! nws.skip_pager) )
To build on Redsandro's solution:
Follow Redsandro's advice and sudo apt-get install xdotool and create some conky-remap.sh (or whatever) script in your /usr/local/bin (or wherever) directory. Also, install wmctrl if you do not already have it. We will be using this to make Conky active (I know this is different than mapping, but it behaves as I expect it to, so I'm not worried.)
run wmctrl -l to list all windows while Conky is running and take note of Conky's title (mine was something like Conky (<my-machine-name>).
While you're at it create another file in which we will save the current state of the desktop (0=not show-desktop-mode, 1=show-desktop-mode... almost) called something like .conky_desktop_state. I have put this into /usr/local/bin as well. Now back to conky-remap.sh:
#!/usr/bin/env bash
state=$(cat /usr/local/bin/.conky_desktop_state)
dt=$(xdotool get_desktop)
if (( $state == 1 )) ; then
echo 0 > /usr/local/bin/.conky_desktop_state
wmctrl -a "Conky (<my-machine-name>)"
else
echo 1 > /usr/local/bin/.conky_desktop_state
wmctrl -a "Conky (<my-machine-name>)"
xdotool search --desktop $dt . windowmap %#
fi
wmctrl's command to activate a window doesn't care about the desktop being in focus or not, so we don't need to sleep or flash a dialog window to the screen. $state and $dt are the variables which hold the current state of the desktop (again, kind of) and the current desktop id number.
xdotool search --desktop $dt . windowmap %# maps all of the windows from the current desktop back to the screen and leaves other desktops alone.
Edit ~/.config/openbox/lubuntu-rc.xml or wherever to execute the script when Win+D is pressed.
<keybind key="W-d">
<action name="ToggleShowDesktop"/>
<action name="Execute">
<command>conky-remap.sh</command>
</action>
</keybind>
openbox --reconfigure to refresh keybindings and you should be good to go.
With Win-D to show desktop, the desktop is focused, so you may use arrow keys to navigate desktop icons.
This solution does have its own set of quirks:
A second pressing of Win+D brings up all windows of the current desktop, not just the ones which were active before showing the desktop.
A toggle is stored in .conky_desktop_state, but it doesn't really match up with show-desktop-mode since it only toggles when the script is executed. This means it is possible to have one desktop shown and the other not. In this case, the desktop will be shown briefly and then all windows will be brought active. One more pressing Win+D will show the desktop.
Sometimes the whole thing fails and Conky disappears with all of the other windows, albeit rarely. Just cat /usr/.../.conky_desktop_state and toggle the opposite value in (ie- echo 1 > /usr/.../.conky_desktop_state)
Although most of the time the last active window before Win+D is on top after a second Win+D, it is not necessarily active, meaning you may have to click in the window or Alt+Tab to it to start typing in it. This generally is the case with terminal windows.
Ideally, we would be able to look at all active (mapped) windows on each desktop individually and execute one or the other command based on if Conky is the only active window, but I wasn't smart (dedicated) enough to do that, so here is my contribution. Please build on it and reply.
Simplifying #imiric's answer:
Openbox RC.xml (e.g. ~/.config/openbox/lxde-rc.xml):
<keybind key="W-d">
<action name="ToggleShowDesktop"/>
<action name="Execute">
<command>wmctrl -a "Conky (hostname)"</command>
</action>
</keybind>
~/.conkyrc:
own_window yes
own_window_type normal
own_window_class conky-semi
own_window_transparent yes
own_window_hints undecorated,sticky,skip_taskbar,skip_pager
own_window_argb_visual yes
got success with conky transparency in LXDE on debian squeezy, with pcmanfm running.
In the conky config file (i.e. .conkyrc) I removed all 'own_window' lines, except the following:
own_window yes
own_window_class conky
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,sticky,skip_pager
Adding again some often used lines caused transparency to fail, or conky wouldn't start at all. Very strange...
Related
My problem is that I need to send a shutdown command to my NAS when the UPS tells my home server that there's a power cut. I want to do this by using the (Windows 10 Home) PC server's closedown notification, which can trigger a batch file as part of the closedown event, rather than by using extra hardware. I have determined that opening a particular URL will cause the NAS to close down gracefully.
https://192.168.1.10/get_handler?PAGE=System&OUTER_TAB=tab_shutdown&INNER_TAB=NONE&shutdown_option1=1&command=poweroff&OPERATION=set
The problems seem to be related to trying to bypass dialogues that result in the browser. First it asks for credentials. I can bypass this one by including them in the URL call, like this:
start "" "C:\Program Files\Mozilla Firefox\firefox.exe"
"https://username:password#192.168.1.10/get_handler?PAGE=System&OUTER_TAB=tab_shutdown&INNER_TAB=NONE&shutdown_option1=1&command=poweroff&OPERATION=set"
Now it pops up a dialogue asking me to confirm that I want to log on as "username", again defeating my attempt to make this run unattended (I might be anywhere when a power cut strikes). Is there a way around this? Just FYI, I gave up trying to work with Microsoft Edge as it kept cutting the URL paramaeters into pieces by inserting spaces everywhere. It also kept manually complaining about the security certificate each and every time I tried it. I think I'll have the same confirmation request problems with that browser too. So I need a way to surpress all these dialogues and just make the URL call. Any thoughts please?
The lack of any answers after this question had been posted over 24 hours told me that this was a tricky one & kept me trying. After I tried everything I could think of to solve it with Window's own tool set and finding nothing worked I realised I'd need something additional to solve the problem. Finally I gave up and installed the free Autohotkey and wrote a script to do the entire job, including handling the dialogue boxes. Once it was all working I made an executable from the script for convenience so I can easily call it from the close down batch (.bat) file. This solution works. Here is the script for anyone who needs to solve a similar problem:
> runWait, C:\Program Files\Mozilla Firefox\firefox.exe
> https://admin:password#192.168.1.10/get_handler?PAGE=System&OUTER_TAB=tab_shutdown&INNER_TAB=NONE&shutdown_option1=1&command=poweroff&OPERATION=set
>
> #Persistent SetTimer, MsgBoxCheck, 3000 return
>
> MsgBoxCheck: If WinExist("ahk_class MozillaDialogClass") {
> SetControlDelay -1 ControlClick, , Confirm, SetTimer,
> MsgBoxCheck, off exitApp } else { SetTimer, MsgBoxCheck, off
> MsgBox, 4, , Debug - No Confirm Window Found. exitApp } return
Please note, to make this work with non-Mozilla programs you will need to change the ahk_class parameter. I suggest you use Windows Spy to determine the class of window you want to close. You will also need to change 'Confirm' to whatever your window's title might be.
I'm trying to make a login batch file that starts a few services but in a way that the user knows they are being started. So I thought I'd use a batch script for that.
The script is working fine, but I wanted to embellish it a bit more using the logo in ASCII and use colors. Everything is working fine on my development PC (Windows 10 64-bit), but on the user machines (Windows 7 64-bit) the colors are not being shown.
I'm using:
echo <ESC>[93m Logging in
But when I run it, I displays:
←[93m Logging in
So it's not treating the ESC properly.
The issue has to be PC based because it's working on another machine, but I don't know how to solve this.
Only console of Windows 10 supports ESC sequences as documented on MSDN page Console Virtual Terminal Sequences. Console host of previous Windows versions don't support ANSI ESC sequences.
There is the command COLOR to define text color and background color.
Open a command prompt window and run color /? for help on this command.
Hundreds of batch file examples on how to use COLOR can be found on Stack Overflow for example with the search term [batch-file] color.
As mented befoer me, windows prior 10 does not support escape sequences. You could try ANSICON
the old ANSI.SYS, which was loaded at boot time would interpret color commands
such as [esc][1;33;40m (where [esc] was a small arrow) as the foreground and
background colors for text in the DOS prompt window, or outside of windows in
a DOS session. (Worked in Windows 3.1x, Win 95, Win 98 1st and 2nd, Win ME and
perhaps even 32 bit Win XP.)
However,after the introduction of 64-bit systems, ANSI.SYS no longer works as before.
The command "color" in a Windows 7 cmd.exe window colors the ENTIRE window text, not
just the part you want to color. I understand some of this has been alleviated in
Win 10 cmd.exe, but except for that...
There may be a possible solution:
called "CoColor" by Horst Schaeffer
Freeware © Horst Schaeffer -- Contact: horst.schaeffer#gmail.com
http://www.horstmuc.de/wcon.htm
Here is what he says about it:
CoColor 2.1 Change console output color Download 32 bit (6Kb)
Download 64 bit (7Kb)
CoColor changes the console color for the succeeding console output, not for the entire window, like the built-in COLOR command. CoColor uses the same color codes as COLOR.
CoColor also accepts a sequence of color codes and text strings (each in double quote marks), making it a colorful ECHO replacement. Non-ASCII characters will be handled the same way as by ECHO.
Demo.CMD is included.
(NOTE: After running Demo.cmd you will need to run the command color to return
to the default colors of the screen. He did not include that in his script.)
After scanning the files with Avast Antivirus, SuperAntiSpyware and Malwarebytes,
I ran the CoColor 64-bit version on Win 7 Pro 64-bit and it seems to work well.
I wrote a lot of batches back in the old days with color bars for the lines of
text. They did NOT change the color of the entire screen as does the "color"
command in cmd.exe! COMMAND.COM understood color commands with ANSI.SYS loaded
at boot time in the CONFIG.SYS. This is the closest thing I've seen yet to that
original functionality. Hope this helps.
I need to pin an executable into the new Windows 10 start menu (i.e. creating a tile).
I'm aware of PowerShell scripts that do the job, but I need some instructions to add at the end of an existing batch file (cmd) we already use for installing our applications.
The usual scripts (valid for Windows 8 and 8.1) simply don't work. How can I do this?
This is a kludge work around that Microsoft needs to fix, but it worked for me.
Temporary rename the .bat file to .exe. Then right click on the file name. It will give you the Pin to start option. Pin it to the start menu. It won't work, but there is an option open the file location. Select that and change the name back to .bat. Now it works.
The way it works on Windows 10 after trying almost 15 different methods that didn't work for me
Go to your desktop -> right-click -> Create New Shortcut
In the shortcut target type the following text:
cmd /c "full path to your batch file"
It will look something like this:
cmd /c "C:\Users\Jmeter\Desktop\jmeter.bat"
Name the shortcut.
Right-click on the shortcut -> select Pin to taskbar. If you'd prefer it pinned to your Start menu, select Pin to start instead.
Bonus: Download some .png image -> Go here (https://icoconvert.com/) -> convert to Windows icon file -> set as new icon
Note: I've wrote and tested this on windows 8 - you might face issues on windows 10.
Check this. This a JScript/bat hybrid that uses the shellapplication object and invokeverb function (i.e. emulates right click and chooses some specific actions). It is now compatible with Windows 10.
Use it like this (you can use also a shortcut/.lnk to an exe):
call pinnerJS.bat "%windir%\system32\cmd.exe" startmenu
Follow my original method, and you will get .bat file{s} pinned in Taskbar. WORKS 100%
Step 1: Create shortcut of your .bat file (for example in Desktop “C:\Users\youruser\Desktop\yourfile.bat”). So you will end up with “yourfile.bat – Shortcut.lnk” (you might not see extension “.lnk”).
Step 2: Right Click your shortcut and change your Target field from: “C:\Users\youruser\Desktop\yourfile.bat” to: explorer “C:\Users\youruser\Desktop\yourfile.bat” – note: explorer is the explorer.exe app. You can also write the full Path: C:\Windows\explorer.exe, for no confusion.
Step 3: Now Right Click your shortcut and now you can see the option Pin to Taskbar.
Step 4: Right Click the pinned shortcut, and you will see two options: shortcut itself and unpin option. Right Click the shortcut and select Properties. From Target field delete “C:\Windows\explorer.exe” and leave only “C:\Users\youruser\Desktop\yourfile.bat”, and click OK
Now you can delete your shortcut in Desktop, since now you have your standalone shortcut on Taskbar
Optionaly, if you want to change Icon do Step 4, but now click “Change Icon…” button, and choose your custom Icon, from some other exe file or .ico file.
That’s it!
Now you have fully functional batch file shortcut on Taskbar
Right now, you can't do this with free tools (maybe Windows want to get into the "pay2tile" business model).
One possible option at the moment would be to use Classic Shell.
I just finished writing a program, (download here if you're interested) Basically, it is like an etch-a-sketch. here's a screenshot of version 1:
Version 2 is more like a pixelated painting program. Here's a screenshot: As you can see, v2 supports 16 different colors.
Anyway, I want the users to be able to "save" their creations. I know that I can highlight everything, and copy it into a text file, but this does not get the colors, and there isn't a clean way to do this (that I know of).
Is there a command line tool that I can download to save screen output as an image? Or am I screwed?
By the way, This is just a batch file, compiled with This program. It only works compiled, because the compiler features advanced commands, the kind that allow me to have multiple colors in one window. You can check out the source code here. All lines starting with REM are the "advanced commands".
:edit
I was originally just going to go with a method that saves all of the text, but when I add colors, it looks something like this. Here is what it should look like:
You can use this commandline tool (I made it in AutoIt):
Capture.exe
Use :
capture.exe outputFile.jpg (png,bmp)
It will capture the entire screen.
EDIT :
You can use THIS new one :
Use :
Capture.exe "Title_of_the_Windows"
So in your bat, give a title to your CMD windows, using :
Title capture
and then display your colored text, and just make a :
Capture.exe "Capture"
This will create Output.jpg.
you can do this without external tools ,but you'll need .net framework (installed on windows from vista and above by default) and screenCapture.bat
call screenCapture screen.png png n
Is there an applescript command that will make the desktop items disappear (without trashing them, moving them or quitting finder)?
Thanks,
Eric
[I'm ] Not yet on Mavericks (how embarrassing), but this works on 10.6.8:
do shell script "defaults write com.apple.finder CreateDesktop -bool false"
quit application "Finder"
delay 0.5
tell application "Finder" to activate
--and of course change false to true to re-activate the icon visibility
[edit] This solution works on Mavericks as well, and I assumed the request for a solution "without quitting finder" does not mean temporarily quitting the Finder, which is a necessary step.