I am trying to force a particular window to be always on top:
xprop -id 0x3800154 -set _NET_WM_STATE\(ATOM\) = _NET_WM_STATE_ABOVE
Debian buster reports:
xprop: error: unsupported conversion for _NET_WM_STATE(ATOM)
I have read https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm45408774010480
but cannot get my head around it.
Your command is almost correct, it should be:
xprop -f _NET_WM_STATE 32a -id 0x3800154 -set _NET_WM_STATE _NET_WM_STATE_ABOVE
The most notable addition is the -f parameter. It specifies the format of the field _NET_WM_STATE. If this is not given, xprop does not know how to interpret the desired property value (_NET_WM_STATE_ABOVE).
According to the specification you provided, _NET_WM_STATE is a 32bit ATOM value (-f _NET_WM_STATE 32a).
The equals sign and \(ATOM\) are not required
A sidenote that might be useful: You can also specify multiple STATE values by comma-separating them, e.g.
xprop -f _NET_WM_STATE 32a -id 0x3800154 -set _NET_WM_STATE _NET_WM_STATE_ABOVE,_NET_WM_STATE_FULLSCREEN
Related
I am on Qubes OS. That means fedora-25 as dom0. I would like to change the configs for "notification area" alias "systray" plugin of xfce. How can I do it. I would like to delete/add one item.
The Gui only gives me the option to hide with ugly arrow on the side or to "clear all known applications". However, regarding the last option I am afraid to lose the notification area as it is and never get it back.
I looked with the "find" command for "xfce4" and "xfce4-plugins" and so on. All the files I could find, e.g. in ~/.config/xfce4, could not help me. I can nowhere find a config file for the plugin.
Thanks in advance :)
Known applications is stored as an array in xfconf, in the xfce4-panel channel and under the property /plugins/plugin-[id]/known-items, where the plugin id is dynamic and depends on the order plugins were added to panel.
You could hack your way messing with ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml but I strongly advise you not to, instead use xfconf-query to read and set values.
I'm going to write down some snippets below so you can use them to craft a script that suits your needs:
# Find the plugin id, can be empty if systray is not present
xfconf-query -c xfce4-panel -p /plugins -l -v | grep systray | grep -Po "plugin-\\d+" | head -n1
# Get array of current known apps
xfconf-query -c xfce4-panel -p /plugins/$PLUGIN_ID/known-items | tail -n +3
# Set array of known apps
xfconf-query -c xfce4-panel -p /plugins/$PLUGIN_ID/known-items -t string -s value1 -t string -s value2 ...
So I did an OS version-up in a linux server, and was seeing if any setting has been changed.
And when I typed "sysctl -a | grep "net.ipv4.ip_forward"
The following line was added,
net.ipv4.ip_forward_use_pmtu = 0
I know that this is because this parameter is in /proc/sys.
But I think if the result of sysctl before upload did not show this line, it was not in /proc/sys before as well, right ?
I know that 0 means " this setting is not applied...So basically it does not do anything.
But why this line is added.
The question is
Is there any possible reason that can add this line?
Thank you, ahead.
Even the question itself "added in the result of sysctl in linux server" is wrong here.
sysctl in the way you invoked it, lists all the entries.
grep which you used to filter those entries "selects" matching texts, if you'd run grep foo against the list:
foo
foobar
both items would be matched. That's exactly what you see but the only difference is instead of "foo" you have "net.ipv4.ip_forward".
Using --color shows that clearly:
Pay attention to the use of fgrep instead of grep because people tend to forget that grep interprets some characters as regular expressions, and the dot . means any character, which might also lead to unexpected matches.
I'm a beginner and not a native english speaker please excuse my clumsiness.
I'm trying to make a linux install script for personal use (and to learn more about linux and bash scripting) but I'm struggling on finding a way to create a disk selection menu :
I wish to make a list witch would look like that :
NAME SIZE DEVICES
sda 256gib intel-ssdx
sdb 1000gib TLxxxxxxxx
nvme0n1 128gib WDxxxxxxxx
So far i've tried to echo fdisk -l and lsblk in text file and use cat to prompt it
Code :
lsblk
Set DiskLayout=("Automatic Install" "Manual Install" "Check pending change" "Quit")
select DiskLayoutopt in "${DiskLayout[#]}"
do
case $DiskLayoutopt in
"Automatic Install")
read Sdsk -p "Select drive"
;;
"Manual Install")
parted -a optimal
;;
"Check pending change")
echo ""
"Quit")
exit 1
;;
*) echo "invalid option $REPLY";;
esac
done
The following code will get your menu:
#!/usr/bin/env bash
disk=()
size=()
name=()
while IFS= read -r -d $'\0' device; do
device=${device/\/dev\//}
disk+=($device)
name+=("`cat "/sys/class/block/$device/device/model"`")
size+=("`cat "/sys/class/block/$device/size"`")
done < <(find "/dev/" -regex '/dev/sd[a-z]\|/dev/vd[a-z]\|/dev/hd[a-z]' -print0)
for i in `seq 0 $((${#disk[#]}-1))`; do
echo -e "${disk[$i]}\t${name[$i]}\t${size[$i]}"
done
This is some tough bash script... Hope you'll learn quick.
Here's some help:
First line is a shebang to tell your system which interpreter is needed for that script. Indeed, this script only works with bash.
Try running with bash myscript.sh on systems that don't work (ie BSD).
variable=() is an array.
Adding something to that array is done by variable+=("my value")
The while loop reads variable device from what it gets from find command
while read device; do
something
done < <(find)
The find command uses a regular expression that says anything like /dev/sdX where X goes from a to z, or anything like /dev/vdX or anything like /dev/hdX (where X still goes from a to z).
The or operator is a pipe | which has to be escaped with an antislash, hence giving \|.
The devices read by the while look look like '/dev/sda' so we need so strip '/dev/' out of it using the following:
device=${device/\/dev\//}
This is a bash substitution which works the following way:
variable="my foo function"
echo ${variable/foo/bar}
This outputs my bar function.
Indeed, we still need to escape / since this is the separator character for the substition, so it becomes \/.
Getting the disk name via
"`cat "/sys/class/block/$device/device/model"`"
cat "/sys/class/block/sda/device/model" gives the disk model.
In order to get the result into a variable, we'll need to quote it with ` sign, eg:
myvar=`cat /var/file`
Last but not least, the for loop part:
for i in seq 0 $((${#disk[#]}-1)); do
echo -e "${disk[$i]}\t${name[$i]}\t${size[$i]}"
done
${#disk[#]} is the number of elements in array disk.
Actually ${#var} is the number of elements in var, which when being a string, is the number of characters. ${var[#]} means all elements of an array.
seq 0 X returns a sequence of 0 to X numbers, in order to construct the for loop.
Using echo -e translates escaped characters into litterals. In our case '\t' become tabs.
Last but not least, showing ${disk[$i]} is disk array value of index $i where $i is an integer.
Btw, bash is quite limited to do these tasks, but really fun to learn in the first place.
Harder tasks might be better accomplished in a higher level scripting language like Python. Anyway, have fun learning bash, it's a life saver in sysadmin's career.
my purpose is to make a certain vim window as a dock (stay on all screens, fixed location, won't be affected by XMonad layout, etc). So i used xprop to set a window as dock type. But XMonad did not seem to honor it. What else should I do?
The xprop command:
$ xprop -id 0x2400001 -f _NET_WM_WINDOW_TYPE 32a -set _NET_WM_WINDOW_TYPE _NET_WM_WINDOW_TYPE_DOCK
$ xprop -id 0x2400001 | grep TYPE
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DOCK
https://askubuntu.com/a/732058/585364
You also need to set a strut property: xprop -f _NET_WM_STRUT 32c -set _NET_WM_STRUT 0,300,0,0
And you probably also need to 'move' the window to that location.
This does require an xmonad restart to take effect when I tested it.
My project requires "Top" out to be redirect in a file.
I am running couple of application. When I tun top on telnet I am getting full path of one of my application. It looks like as follows
2079 1952 root R 12296 2% 0% -s=1 -PrjPath="/usr/local/Myproject/Application" -stgMode=1
But when I use following command to redirect the out put to file it gets truncated.
Command:
tope -b -n1
Out put:
2079 1952 root R 12296 2% 0% -s=1 -PrjPath="/usr/local/Myproject/Appl
Can any one tell me why it is truncated ?
How to get it full.
Following is my environment.
Embedded linux kernel v2.6.29.
busyboxy v1.10.4
"top" command is part of busybox.
Thanks in Advance
Bhargav Vyas
Use can use "-c" parameter to display the complete command, and you need to make sure the screen width is wide enough to display it.
Ex:
COLUMNS=512 top -b -n1 -c
One side effect would be, the complete path of the command will be displayed. This cannot be avoided. You should also consider using ps, which is much more customizable.
To display only the command names:
ps -eo pcpu,pid,user,comm | sort -k 1 -r
To display with arguments and path:
ps -eo pcpu,pid,user,args | sort -k 1 -r
and so on.
I had a truncating issue even after using the
-c :Command-line/Program-name toggle
option in batch mode. So I had to specify the output width with -w, like
top -b -n 1 -c -w 200
for example.
From the man page:
-w :Output-width-override as: -w [ number ]
In Batch mode, when used without an argument top will format output
using the COLUMNS= and LINES= environment variables, if set.
Otherwise, width will be fixed at the maximum 512 columns. With an
argument, output width can be decreased or increased (up to 512) but
the number of rows is considered unlimited.
In normal display mode, when used without an argument top will attempt
to format output using the COLUMNS= and LINES= environment variables,
if set. With an argument, output width can only be decreased, not
increased. Whether using environment variables or an argument with
-w, when not in Batch mode actual terminal dimensions can never be exceeded.
Note: Without the use of this command-line option, output width is
always based on the terminal at which top was invoked whether or not
in Batch mode.