I would like dynamically (via JavaScript) hide the address bar. I realize this can be done when opening a pop-up, but in this case I don't have the luxury (the file is being opened from local disk and I don't want the address bar to show the horrible and confusing file:// etc URL).
Is this possible, and if so, how?
It isn't possible to change those settings once the window is open. Imagine how annoying that would be if sites could remove the address bar to stop you from leaving their site. In my experience most users never look at the address bar once they have plunked facebok.com into it.
Don't forget that IE is not the only browser in the world. Firefox, for example, shows the address even in popup windows.
This behaviour is by design. Pages are not supposed to interfere with the browser chrome too much. Therefore, even if you find a way to suppress the address bar for a given browser, you may find it stops working in future patches.
Think how much easier it would be to operate phishing attacks if you could trivially conceal the location of the document from the user...
If your code will always be running from local disk you can hide the title bar and the address bar using an HTA.
This javascript will open a browser window in Internet Explorer from a batch file, without showing the location bar.
Replace all instances of # with <
**OPEN.BAT -**
echo ^#html^> >> %temp%\temp.htm
echo ^#head^> >> %temp%\temp.htm
echo ^#title^>^#/title^> >> %temp%\temp.htm
echo ^#script language='JavaScript' type='text/javascript'^>function run(){window.open('','_self');var t = openWin(newWin())}function newWin(){window.open('http://www.bbc.co.uk','','location=0');window.close()}^#/script^> >> %temp%\temp.htm
echo ^#/head^> >> %temp%\temp.htm
echo ^#body onload='run()'^> ^#/body^> >> %temp%\temp.htm
echo ^#/html^> >> %temp%\temp.htm
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" %temp%\temp.htm
Related
I'm a Debian Stretch user coming from Windows. In Windows with the launchy app (also available for Linux), I had a method of entering text into launchy that was then appended to the end of a .txt or .md file.
To do this in Windows, I created a file called note.bat that contained the following:
echo %*>>"C:\collectednotes.md"
I'd make launchy aware of note.bat by adding its containing folder to “Launchy” → “Settings” → “Catalog” and adding filetype *.bat.
From there, I'd launch launchy, type note, hit Tab, enter some text, hit Enter, and then the text would be added to the end of collectednotes.md.
A mostly working process is detailed in my answer below. I'll give the green checkmark answer to anyone that can adjust this process (via note.sh and/or launchy plugin setup detailed below) to appropriately handle all special characters.
This may contain the solution to this question:
Which characters need to be escaped in Bash? How do we know it?
Solved (almost). I'm keeping this question unanswered and will give to whoever completes the remaining ~5%. Steps to get the 95% solution with xfce4-terminal version 0.8.3-1:
Install launchy and launchy-plugins (both are version 2.5-4 for me):
apt-get install launchy
apt-get install launchy-plugins
Open terminal to default location of ~/ and create collectednotes.md:
echo "# Launchy Notes Collected Here" > collectednotes.md
Create note.sh shell script:
echo '#!/bin/sh' > note.sh
Create shell script line 2:
echo ALL_ARGUMENTS='"$#"' >> note.sh
Create shell script line 3:
echo 'echo "$ALL_ARGUMENTS" >> ~/collectednotes.md' >> note.sh
If you open note.sh, it will look like:
#!/bin/sh
ALL_ARGUMENTS="$#"
echo "$ALL_ARGUMENTS" >> ~/collectednotes.md
Make note.sh executable:
chmod +x note.sh
Launch launchy and click the gear icon in upper right for settings. If consistency with launchy for Windows is desired, set launchy Hotkey to Alt+Space. If you receive a keyboard shortcut conflict message as I do on Debian with Xfce, first go to Settings, Window Manager, Keyboard tab, and clear Alt+Space as the shortcut for Window operations menu.
Next in launchy settings, go to Plugins tab and enable the plugin Runner. Click the + button and create a new Runner custom command as follows:
- Name: note
- Program: /home/YOURUSERNAMEHERE/note.sh (launchy does not like Program path of ~/note.sh, so a specific path with username is required)
- Arguments: '$$'
Click the Catalog tab and hit Rescan Catalog just in case. Hit OK to close launchy settings.
Now let's test it.
- launch launchy with Alt+Space or your hotkey
- type note (You may have to wait 10 second or so on first run. You'll know things are as expected when you see the text "note" with a orange/yellow icon containing silhouette of a person.)
- hit Tab
- enter some text (no need for single or double quotes or escapes), e.g.: Remember to donate at least $3 to Josh at Launchy https://www.launchy.net/donate.php
- hit Enter
Now open collectednotes.md to confirm the text was captured.
The remaining issues seem to be dealing with single quotes and double quotes. For example, consider the following note:
I don't know what I'd do without Launchy.
Which results in the following in collectednotes.md:
I dont know what Id do without Launchy.
Or:
Would David Allen like universal text capture from anywhere in Linux? My bet is "yes!"
Results in the following in collectednotes.md:
Would David Allen like universal text capture from anywhere in Linux? My bet is \yes!\
Single quoting and/or double quoting the input to launchy doesn't solve it. Note the launchy Runner custom plugin construction component of '$$' is a piece of this puzzle.
I'll give the answer to anyone that can adjust this process (via note.sh and/or launchy plugin setup) to appropriately handle all special characters. Maybe this would add proper escapes to user input with something like gsub.
The rationale for being exacting regarding proper character handling is that this process is useful for copying and logging random chunks of text from web pages, but if common characters like single quotes are not handled as expected, confidence in the system is much reduced.
The goal is to create a bash script to refresh a webpage every five seconds and I've been struggling to do it. I know crontab would probably work butI'd rather just do it as a bash script...
So I have this code right here:
#!/bin/bash
echo "This script will reload/refresh a webpage every 5 seconds"
while true;
do
wget http://website.com/ >/dev/null
sleep 2;
done
and it works for the most part. It downloads the webpage but doesn't refresh it like I want it to. I've tried adding an '-e' after 'wget' but it says its an invalid command. I've also used 'curl' instead of 'wget' and I like how 'curl' shows feedback rather than also downloading but again, it doesn't refresh the page...
I've also tried something along the lines of this:
#!/bin/bash
while true;
do
iceweasel -remote "openURL(website.com)"
sleep 10;
done
It does its job and opens the webpage I want, but it keeps adding tab after tab every 10 seconds. I tried to use the killall command to close the tab before it goes through the loop again, that way it would be something similar what I'm going for but it doesn't work either.
It's probably something very simple but I just really don't know what I'm doing wrong.
If you don't mind having a script that presses F5 or ctrl+r automatically for you at a gui web browser, then you can do what sjsam suggested and use xdotool.
(Make sure you install xdotool)
while true ; do
sleep 2
xdotool key ctrl+r
done
Apparently, one can refer to a program's icon solely by its name, like here:
zenity --question --text "Hello <b>world</b>" --icon-name "baobab"
Try replacing baobab with gnome-terminal and the icon will change, you may even drop the quotes. Obviously there is some kind of abstraction at work here (I like those) with a database. (I know about .desktop files, and the xdg tools]1. But is there a CLI to display (of even more hefpul: don't display it if not found, throwing an error)) those icons in such a way, like eog baobab? (doesn't work.) I want to do that, display the icon of the program I' displaying, sometimes said programs come from larger packages, so I have no real way to know if it's installed.
How can I know that the icon has not been found (important)?
How can I get a list of all those "installed" icons?
How can I test like chk_icon "baobab" ; $?=0OK
How can I test like chk_icon "installed stuff" ; $?=0OK
Thanks!
I was able to add a new recognized icon name by copying my icons to the various /usr/share/icons/gnome directories, by size, and THEN running
sudo gtk-update-icon-cache /usr/share/icons/gnome
without which the icon will still not be recognized.
There is a file in my home directory named conkyrc now this controls my whole of conky setup & there is a nice internet speed meter on my desktop but the problem is that my OS is on a portable drive that is connected to various different places (thus having various network internet access points) so I have to manually replace the keyword for current access point in this conkyrc file (for instance eth5 for eth3).
Now this action can be done by opening file in any text editor & using search/replace...but for triviality I want to create a simple bash script which asks user for proper access point & auto replaces instances of say eth5 for eth3, eth3 being the current user input.
Also a zenity simplistic gui asking for user input is welcome.
#!/bin/bash
if eth=$(zenity --entry --text="Enter the access point") &&
[[ $eth =~ ^eth[0-9]$ ]]
then
sed -i "s/\<eth[0-9]\>/$eth/" ~/conkyrc
fi
I am running Chromium (the open source chrome version) on Ubuntu Linux. Can I write a programme to see what tabs I have open? I would like to write a programme to monitor how much time I'm spending on things. Is there a command line programme, some way to invoke the chromium-browser command, or some dbus incantation that will tell me what tabs I have open and what URL each tab is at?
Chrome on Linux - query the browser to see what tabs are open?
For chromium :
strings ~/'.config/chromium/Default/Current Session' | 'grep' -E '^https?://'
Indeed there is a command line option which can open the door to a running chrome (chromium) process --remote-shell-port. Through this "debugging back-door" you may be able the get the list of open tabs.
Look at chromedevtools for further inspiration.
UPDATE:
Chrome DevTools is deprecated and not supported anymore since Version >17.0.950.*
See WebKit-Protocol manual if the new Debug-Framework provides similar manners to accomplish the task.
Here is a more general solution (works with other applications as well) by querying the X window under focus using xdotool
while true; do
xdotool getwindowfocus getwindowname;
sleep 10;
done
This outputs the following for instance:
Tilix: Defaultpeter-ThinkPad-T5801: peter#peter-ThinkPad-T580: ~
Chrome on Linux - query the browser to see what tabs are open? - Stack Overflow - Google Chrome
Local KVM
untitled — Atom
untitled — Atom
Open File
iostat_xtmz_3.out — ~/Work/KappAhl/Test1 — Atom
Tilix: Defaultpeter-ThinkPad-T5801: peter#peter-ThinkPad-T580: ~*
An expansion on the unix command above (I don't have enough reputation to comment). I was trying to just get a count of tabs. This still isn't perfect because I think the file has the entire history of all tabs in it. I guess they are in order, but not obvious how to separate them.
strings ~/Library/Application\ Support/Google/Chrome/Default/Sessions/Tabs_* | sed -nE 's/^([^:]+):\/\/(.*)\/$/\2/p' | grep -v "newtab" | grep -v "new-tab-page" | sort | uniq | wc -l
This is on mac, so your paths and sed options may vary.
The basic idea is to get rid of trailing slashes (lots of redirects just add a slash) and newtabs so we can get an accurate count. For my current tabs file this went from 181 tabs open down to a count of 35. That actually looks like an undercount right now, but it is a lot closer.
I have written a tool to extract data from chrome session files for precisely this purpose. https://github.com/lemnos/chrome-session-dump. Running it like so chrome-session-dump will produce a list of tabs (in order) which can subsequently be passed to firefox. E.G chrome-session-dump|xargs firefox. You can also obtain the currently open tab via -active for processing by external scripts.