X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FScripts%2FPublic.git;a=blobdiff_plain;f=wrapper_display;fp=wrapper_display;h=6b304470932b9d443b6c4e336d47be19c56f6498;hp=0000000000000000000000000000000000000000;hb=52b8096cabc7d512f586183266c5167d320b7719;hpb=5172ecf855078938b00e9ac7f8dee2c2676f6e53 diff --git a/wrapper_display b/wrapper_display new file mode 100755 index 0000000..6b30447 --- /dev/null +++ b/wrapper_display @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# The MIT License (MIT) +# +# Copyright (c) 2011-2015 Ismaël Bouya http://www.normalesup.org/~bouya/ +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +eval `tmux show-env DISPLAY | grep -v "^-DISPLAY"` +if `ss -o state established sport = :5901 | grep -q "^tcp"`; then + DISPLAY=:1 +fi + +if [ $# -lt 1 ]; then + echo DISPLAY=$DISPLAY +else + exec "$@" +fi